]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/web/conify/global/config/copy_status.html
Bring i18n to the Conify copy status interface
[working/Evergreen.git] / Open-ILS / web / conify / global / config / copy_status.html
1 <!--
2 # Copyright (C) 2008  Georgia Public Library Service / Equinox Software, Inc
3 # Mike Rylander <miker@esilibrary.com>
4
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
9
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 -->
15 <!DOCTYPE html PUBLIC 
16         "-//W3C//DTD XHTML 1.0 Transitional//EN" 
17         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" [
18         <!--#include virtual="/opac/locale/${locale}/conify.dtd"-->
19 ]>
20 <html xmlns="http://www.w3.org/1999/xhtml">
21         <head>
22                 <title>&conify.copy_status.title;</title>
23
24                 <style type="text/css">
25                         @import url('/js/dojo/dojox/grid/_grid/tundraGrid.css');
26                         @import url('/js/dojo/dojo/resources/dojo.css');
27                         @import url('/js/dojo/dijit/themes/tundra/tundra.css');
28                         @import url('/js/dojo/dojox/widget/Toaster/Toaster.css');
29                 </style>
30
31                 <style>
32                         html, body {
33                                 height: 100%;
34                                 width: 100%;
35                                 margin: 0px 0px 0px 0px;
36                                 padding: 0px 0px 0px 0px;
37                                 overflow: hidden;
38                         }
39
40                         #status_grid {
41                                 border: 0px;
42                                 width: 100%;
43                                 height: 100%;
44                         }
45
46                         #grid_container {
47                                 width: 100%;
48                                 height: 100%;
49                         }
50                 </style>
51
52                 <!-- The OpenSRF API writ JS -->
53                 <script language='javascript' src='/opac/common/js/utils.js' type='text/javascript'></script>
54                 <script language='javascript' src='/opac/common/js/Cookies.js' type='text/javascript'></script>
55                 <script language='javascript' src='/opac/common/js/CGI.js' type='text/javascript'></script>
56                 <script language='javascript' src='/opac/common/js/JSON_v1.js' type='text/javascript'></script>
57
58                 <!-- Dojo goodness -->
59                 <script type="text/javascript" src="../admin.js"></script>
60                 <script type="text/javascript" src="/js/dojo/dojo/dojo.js"></script>
61                 <script type="text/javascript" src="/js/dojo/dijit/dijit.js"></script>
62
63                 <script type="text/javascript" src="copy_status.js"></script>
64
65         </head>
66
67         <body class="tundra" id='pagebody'>
68
69                 <div dojoType="dijit.layout.LayoutContainer" id="grid_container" jsId="grid_container" orientation="vertical">
70                         <script type="dojo/method">
71 <!--
72                                 window.highlighter= {};
73                                 window.highlighter.green = dojox.fx.highlight( { color : '#B4FFB4', node : 'grid_container', duration : 500 } );
74                                 window.highlighter.red = dojox.fx.highlight( { color : '#FF2018', node : 'grid_container', duration : 500 } );
75
76                                 window.dirtyStore = [];
77
78                 pCRUD.request({
79                     method : 'open-ils.permacrud.search.ccs.atomic',
80                     timeout : 10,
81                     params : [ ses, { id : { "!=" : null } }, { order_by : { ccs : 'name' } } ],
82                     onerror : function (r) { status_update(ccs_strings.ERROR_FETCHING_STATUSES) },
83                     oncomplete : function (r) {
84
85                         window._status_list = r.recv().content();
86                         window._status_data = ccs.toStoreData( window._status_list, 'name' );
87                         window.status_store = new dojo.data.ItemFileWriteStore({ data : window._status_data });
88
89                             window.status_store.onSet = function (item, attr, o, n) {
90                             if (attr == 'ischanged') return;
91                             if (n == o) return;
92                             this.setValue( item, 'ischanged', 1);
93
94                             if (attr == 'holdable' && typeof n != 'string')
95                                 this.setValue(item, 'holdable', n ? 't' : 'f');
96
97                             if (attr == 'opac_visible' && typeof n != 'string')
98                                 this.setValue(item, 'opac_visible', n ? 't' : 'f');
99
100                         };
101
102                         dojo.addOnUnload( function (event) {
103
104                             status_store.fetch({
105                                 query : { ischanged : 1 },
106                                 onItem : function (item, req) { try { if (this.isItem( item )) window.dirtyStore.push( item ); } catch (e) { /* meh */ } },
107                                 scope : status_store
108                             });
109
110                             if (dirtyStore.length > 0) {
111                                 var confirmation = confirm(
112                                                                         ccs_strings.CONFIRM_EXIT
113                                 );
114
115                                 if (confirmation) {
116                                     for (var i in window.dirtyStore) {
117                                         window.current_status = window.dirtyStore[i];
118                                         save_status(true);
119                                     }
120                                 }
121                             }
122
123                         });
124                     }
125                 }).send();
126 -->
127                         </script>
128
129                         <div dojoType="dijit.layout.LayoutContainer" orientation="horizontal" style="margin-top: 5px;" layoutAlign="top">
130                                 <span>&conify.copy_status.new_status.label;</span>
131                                 <div dojoType="dijit.form.TextBox" id="new_status_code" jsId="new_status_name" label="&conify.copy_status.new_status.name;"></div>
132                                 <button dojoType="dijit.form.Button" id="save_new_status_code" jsId="save_new_status_name" label="&conify.copy_status.new_status.save;"> 
133                                         <script type="dojo/connect" event="onClick">
134 <!--
135                                                 var new_name = new_status_name.getValue();
136                                                 if (!new_name) return;
137
138                         var new_fm_obj = new ccs().fromHash({
139                                 isnew           : 1,
140                             name            : new_name
141                             });
142     
143                         var err = false;
144                             pCRUD.request({
145                             method : 'open-ils.permacrud.create.ccs',
146                                 timeout : 10,
147                             params : [ ses, new_fm_obj ],
148                                 onerror : function (r) {
149                                 highlighter.red.play();
150                                     status_update( ccs_strings.ERROR_CALLING_METHOD );
151                                 err = true;
152                                 },
153                                 oncomplete : function (r) {
154                                 var res = r.recv();
155                                     if ( res && res.content() ) {
156                                     var new_item_hash = res.content().toHash();
157                                     status_store.newItem( new_item_hash );
158                                                                         status_update( dojo.string.substitute(ccs_strings.SUCCESS_CREATING_STATUS, [new_item_hash.name]) );
159                                                                         status_grid.model.sort(-2);
160                                                                         highlighter.green.play();
161                                 } else {
162                                         highlighter.red.play();
163                                     status_update( ccs_strings.ERROR_CREATING_STATUS );
164                                         err = true;
165                                 }
166                                 }
167                         }).send();
168 --> 
169                         </script>
170                                 </button>
171                         </div>
172
173                         <div dojoType="dijit.layout.ContentPane" style="width:100%; height:100%;" layoutAlign="client">
174                                 <div dojoType="dojox.grid.data.DojoData" id="status_data_model" jsId="status_data_model" store="status_store" query="{ 'id' : '*' }"></div>
175                                 <div id="status_grid" dojoType="dojox.Grid" jsId="status_grid">
176                                         <script type="dojo/connect" event="startup">
177 <!--
178                                                 var g = this;
179                                                 var status_grid_layout = [
180                                                         {       cells : [
181                                                                         [
182                                                                                 { name : ccs_strings.ID,
183                                                                                   field : "id",
184                                                                                 },
185                                                                                 { name : ccs_strings.NAME,
186                                                                                   field : "name",
187                                                                                   width : "auto",
188                                                                                   editor : dojox.grid.editors.Dijit
189                                                                                 },
190                                                                                 { name : ccs_strings.TRANSLATION,
191                                                                                   width : "10em",
192                                                                                   height : "2em",
193                                                                                   get : function (row) {
194                                                                                         if (!window.status_rows) window.status_rows = [];
195                                                                                         var r = window.status_data_model.getRow(row);
196                                                                                         if (r) {
197                                                                                                 window.status_rows[row] = new ccs().fromHash(window.status_data_model.getRow(row));
198                                                                                                 setTimeout(
199                                                                                                         'dojo.query(".status_grid_trans_cell_' + row + '").'+
200                                                                                                                 'instantiate(openils.widget.TranslatorPopup,{field:"name",'+
201                                                                                                                 'targetObject:"window.status_rows['+row+']"});'+
202                                                                                                                 'status_grid.rowHeightChanged('+row+')',
203                                                                                                         0
204                                                                                                 );
205                                                                                                 return '<span class="status_grid_trans_cell_'+row+'"></span>';
206                                                                                         }
207                                                                                         return '';
208                                                                                   }
209                                                                                 },
210                                                                                 { name : ccs_strings.HOLDABLE,
211                                                                                   field : "holdable",
212                                                                                   editor : dojox.grid.editors.bool,
213                                                                                   get : function (row) {
214                                                                                         var r = window.status_data_model.getRow(row);
215                                                                                         if (r) {
216                                                                                                 var h = r.holdable;
217                                                                                                 if (h == 't' || h === true) return true;
218                                                                                                 return false;
219                                                                                         }
220                                                                                   }
221                                                                                 },
222                                                                                 { name : ccs_strings.OPAC_VISIBLE,
223                                                                                   field : "opac_visible",
224                                                                                   editor : dojox.grid.editors.bool,
225                                                                                   get : function (row) {
226                                                                                         var r = window.status_data_model.getRow(row);
227                                                                                         if (r) {
228                                                                                                 var h = r.opac_visible;
229                                                                                                 if (h == 't' || h === true) return true;
230                                                                                                 return false;
231                                                                                         }
232                                                                                   }
233                                                                                 }
234                                                                         ]
235                                                                 ]
236                                                         }
237                                                 ];
238
239                                                 this.setStructure(status_grid_layout);
240                                                 this.setModel(window.status_data_model);
241 -->
242                                         </script>
243                                 </div>
244                         </div>
245
246                         <div dojoType="dijit.layout.ContentPane" orientation="horizontal" style="margin-bottom: 5px;" layoutAlign="bottom">
247                 
248                                 <button jsId="save_ccs_button" dojoType="dijit.form.Button" label="&conify.copy_status.save_changes;" onClick="save_them_all()"></button>
249                 
250                                 <button jsId="delete_ccs_button" dojoType="dijit.form.Button" label="&conify.copy_status.delete_selected;">
251                                         <script type="dojo/connect" event="onClick">
252 <!--
253                                                 var selected_rows = status_grid.selection.getSelected();
254                 
255                                                 var selected_items = [];
256                                                 for (var i in selected_rows) {
257                                                         selected_items.push(
258                                                                 status_grid.model.getRow( selected_rows[i] ).__dojo_data_item
259                                                         );
260                                                 }
261
262                                                 status_grid.selection.clear();
263
264                                                 for (var i in selected_items) {
265                                                         current_status = selected_items[i];
266
267                                                         if ( confirm(dojo.string.substitue(ccs_strings.CONFIRM_DELETE, [status_store.getValue( current_status, 'name' )]))) {
268
269                                                                 status_store.setValue( current_status, 'isdeleted', 1 );
270                         
271                                                                 var modified_ccs = new ccs().fromStoreItem( current_status );
272                                                                 modified_ccs.isdeleted( 1 );
273                         
274                                                                 pCRUD.request({
275                                                                         method : 'open-ils.permacrud.delete.ccs',
276                                                                         timeout : 10,
277                                                                         params : [ ses, modified_ccs ],
278                                                                         onerror : function (r) {
279                                                                                 highlighter.red.play();
280                                                                                 status_update( dojo.string.substitute( ccs_strings.ERROR_DELETING, [status_store.getValue( current_status, 'name' )] ) );
281                                                                         },
282                                                                         oncomplete : function (r) {
283                                                                                 var res = r.recv();
284                                                                                 if ( res && res.content() ) {
285                         
286                                                                                         var old_name = status_store.getValue( current_status, 'name' );
287                 
288                                                                                         status_store.fetch({
289                                                                                                 query : { id : status_store.getValue( current_status, 'id' ) },
290                                                                                                 onItem : function (item, req) { try { if (this.isItem( item )) this.deleteItem( item ); } catch (e) { /* meh */ } },
291                                                                                                 scope : status_store
292                                                                                         });
293                         
294                                                                                         current_status = null;
295                         
296                                                                                         highlighter.green.play();
297                                                                                         status_update( dojo.string.substitute(ccs_strings.STATUS_DELETED, [old_name]) );
298                                                                                 } else {
299                                                                                         highlighter.red.play();
300                                                                                         status_update( dojo.string.substitute(ccs_strings.ERROR_DELETING, [old_name]) );
301                                                                                 }
302                                                                         }
303                                                                 }).send();
304                 
305                                                         }
306                                                 }
307 -->
308                                         </script>
309                                 </button>
310         
311                         </div>
312                 </div>
313         
314         </body>
315 </html>