]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/web/conify/global/config/copy_status.html
LP2042879 Shelving Location Groups Admin accessibility
[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 type="text/css">
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='/IDL2js' type='text/javascript'></script>
54                 <script language='javascript' src='/opac/common/js/utils.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         <script type="text/javascript">
66 <![CDATA[
67             var dirtyStore = [];
68
69             var _status_list = pCRUD.retrieveAll('ccs', { order_by : { ccs : 'name' } });
70             var _status_data = ccs.toStoreData( _status_list, 'name' );
71             var status_store = new dojo.data.ItemFileWriteStore({ data : _status_data });
72
73             status_store.onSet = function (item, attr, o, n) {
74                 if (attr == 'ischanged') return;
75                 if (n == o) return;
76                 this.setValue( item, 'ischanged', 1);
77
78                 if (attr == 'holdable' && typeof n != 'string')
79                     this.setValue(item, 'holdable', n ? 't' : 'f');
80
81                 if (attr == 'opac_visible' && typeof n != 'string')
82                     this.setValue(item, 'opac_visible', n ? 't' : 'f');
83
84                 if (attr == 'copy_active' && typeof n != 'string')
85                     this.setValue(item, 'copy_active', n ? 't' : 'f');
86             };
87
88             dojo.addOnUnload( function (event) {
89
90                 status_store.fetch({
91                     query : { ischanged : 1 },
92                     onItem : function (item, req) { try { if (this.isItem( item )) dirtyStore.push( item ); } catch (e) { /* meh */ } },
93                     scope : status_store
94                 });
95
96                 if (dirtyStore.length > 0) {
97                     var confirmation = confirm(
98                         ccs_strings.CONFIRM_EXIT_CCS
99                     );
100
101                     if (confirmation) {
102                         for (var i in window.dirtyStore) {
103                             current_status = dirtyStore[i];
104                             save_status(true);
105                         }
106                     }
107                 }
108
109             });
110 ]]>
111         </script>
112
113         </head>
114
115         <body class="tundra" id='pagebody'>
116
117                 <div dojoType="dijit.layout.LayoutContainer" id="grid_container" jsId="grid_container" orientation="vertical">
118
119                         <div dojoType="dijit.layout.LayoutContainer" orientation="horizontal" style="margin-top: 5px;" layoutAlign="top">
120                                 <span>&conify.copy_status.new_status.label;</span>
121                                 <div dojoType="dijit.form.TextBox" id="new_status_code" jsId="new_status_name" label="&conify.copy_status.new_status.name;"></div>
122                                 <button dojoType="dijit.form.Button" id="save_new_status_code" jsId="save_new_status_name" label="&conify.copy_status.new_status.save;"> 
123                                         <script type="dojo/connect" event="onClick">
124 <![CDATA[
125                                                 var new_name = new_status_name.getValue();
126                                                 if (!new_name) return;
127
128                         var new_fm_obj = new ccs().fromHash({
129                                 isnew           : 1,
130                             name            : new_name
131                             });
132     
133                         var err = false;
134                             pCRUD.create(new_fm_obj, {
135                                 onerror : function (r) {
136                                 highlighter.red.play();
137                                     status_update( ccs_strings.ERROR_CALLING_METHOD_CCS );
138                                 err = true;
139                                 },
140                                 oncomplete : function (r, list) {
141                                     var new_item_hash = list[0].toHash();
142                                     status_store.newItem( new_item_hash );
143                                                                 status_update( dojo.string.substitute(ccs_strings.SUCCESS_CREATING_STATUS, [new_item_hash.name]) );
144                                                                 status_grid.model.sort(-2);
145                                                                 highlighter.green.play();
146                                 }
147                         });
148 ]]> 
149                         </script>
150                                 </button>
151                         </div>
152
153                         <div dojoType="dijit.layout.ContentPane" style="width:100%; height:100%;" layoutAlign="client">
154                                 <div dojoType="dojox.grid.data.DojoData" id="status_data_model" jsId="status_data_model" store="status_store" query="{ 'id' : '*' }"></div>
155                                 <div id="status_grid" dojoType="dojox.Grid" jsId="status_grid">
156                                         <script type="dojo/connect" event="startup">
157 <![CDATA[
158                                                 var g = this;
159                                                 var status_grid_layout = [
160                                                         {       cells : [
161                                                                         [
162                                                                                 { name : ccs_strings.ID,
163                                                                                   field : "id",
164                                                                                 },
165                                                                                 { name : ccs_strings.NAME,
166                                                                                   field : "name",
167                                                                                   width : "auto",
168                                                                                   editor : dojox.grid.editors.Dijit
169                                                                                 },
170                                                                                 { name : ccs_strings.TRANSLATION,
171                                                                                   width : "10em",
172                                                                                   height : "2em",
173                                           formatter: function (row) {
174                                                                                                 return '<span class="status_grid_trans_cell_'+row+'"></span>';
175                                           },
176                                                                                   get : function (row) {
177                                                                                         if (!window.status_rows) window.status_rows = [];
178                                                                                         var r = window.status_data_model.getRow(row);
179                                                                                         if (r) {
180                                                                                                 window.status_rows[row] = new ccs().fromHash(window.status_data_model.getRow(row));
181                                                                                                 setTimeout(
182                                                                                                         'dojo.query(".status_grid_trans_cell_' + row + '").'+
183                                                                                                                 'instantiate(openils.widget.TranslatorPopup,{field:"name",'+
184                                                                                                                 'targetObject:"window.status_rows['+row+']"});'+
185                                                                                                                 'status_grid.rowHeightChanged('+row+')',
186                                                                                                         0
187                                                                                                 );
188                                                                                                 return row;
189                                                                                         }
190                                                                                         return '';
191                                                                                   }
192                                                                                 },
193                                                                                 { name : ccs_strings.HOLDABLE,
194                                                                                   field : "holdable",
195                                                                                   editor : dojox.grid.editors.bool,
196                                                                                   get : function (row) {
197                                                                                         var r = window.status_data_model.getRow(row);
198                                                                                         if (r) {
199                                                                                                 var h = r.holdable;
200                                                                                                 if (h == 't' || h === true) return true;
201                                                                                                 return false;
202                                                                                         }
203                                                                                   }
204                                                                                 },
205                                                                                 { name : ccs_strings.OPAC_VISIBLE,
206                                                                                   field : "opac_visible",
207                                                                                   editor : dojox.grid.editors.bool,
208                                                                                   get : function (row) {
209                                                                                         var r = window.status_data_model.getRow(row);
210                                                                                         if (r) {
211                                                                                                 var h = r.opac_visible;
212                                                                                                 if (h == 't' || h === true) return true;
213                                                                                                 return false;
214                                                                                         }
215                                                                                   }
216                                                                                 },
217                                                                                 { name : ccs_strings.COPY_ACTIVE,
218                                                                                   field : "copy_active",
219                                                                                   editor : dojox.grid.editors.bool,
220                                                                                   get : function (row) {
221                                                                                         var r = window.status_data_model.getRow(row);
222                                                                                         if (r) {
223                                                                                                 var h = r.copy_active;
224                                                                                                 if (h == 't' || h === true) return true;
225                                                                                                 return false;
226                                                                                         }
227                                                                                   }
228                                                                                 },
229                                                                                 { name : ccs_strings.IS_AVAILABLE,
230                                                                                   field : "is_available",
231                                                                                   editor : dojox.grid.editors.bool,
232                                                                                   get : function (row) {
233                                                                                         var r = window.status_data_model.getRow(row);
234                                                                                         if (r) {
235                                                                                                 var h = r.is_available;
236                                                                                                 if (h == 't' || h === true) return true;
237                                                                                                 return false;
238                                                                                         }
239                                                                                   }
240                                                                                 }
241                                                                         ]
242                                                                 ]
243                                                         }
244                                                 ];
245
246                                                 this.setStructure(status_grid_layout);
247                                                 this.setModel(window.status_data_model);
248 ]]>
249                                         </script>
250                                 </div>
251                         </div>
252
253                         <div dojoType="dijit.layout.ContentPane" orientation="horizontal" style="margin-bottom: 5px;" layoutAlign="bottom">
254                 
255                                 <button jsId="save_ccs_button" dojoType="dijit.form.Button" label="&conify.copy_status.save_changes;" onClick="save_them_all()"></button>
256                 
257                                 <button jsId="delete_ccs_button" dojoType="dijit.form.Button" label="&conify.copy_status.delete_selected;">
258                                         <script type="dojo/connect" event="onClick">
259 <![CDATA[
260                                                 var selected_rows = status_grid.selection.getSelected();
261                 
262                                                 var selected_items = [];
263                                                 for (var i in selected_rows) {
264                                                         selected_items.push(
265                                                                 status_grid.model.getRow( selected_rows[i] ).__dojo_data_item
266                                                         );
267                                                 }
268
269                                                 status_grid.selection.clear();
270
271                                                 for (var i in selected_items) {
272                                                         current_status = selected_items[i];
273
274                                                         if ( confirm(dojo.string.substitute(ccs_strings.CONFIRM_DELETE, [status_store.getValue( current_status, 'name' )]))) {
275
276                                                                 status_store.setValue( current_status, 'isdeleted', 1 );
277                         
278                                                                 var modified_ccs = new ccs().fromStoreItem( current_status );
279                                                                 modified_ccs.isdeleted( 1 );
280                         
281                                                                 pCRUD.eliminate(modified_ccs, {
282                                                                         onerror : function (r) {
283                                                                                 highlighter.red.play();
284                                                                                 status_update( dojo.string.substitute( ccs_strings.ERROR_DELETING, [status_store.getValue( current_status, 'name' )] ) );
285                                                                         },
286                                                                         oncomplete : function (r) {
287                                                                                 var old_name = status_store.getValue( current_status, 'name' );
288                 
289                                                                                 status_store.fetch({
290                                                                                         query : { id : status_store.getValue( current_status, 'id' ) },
291                                                                                         onItem : function (item, req) { try { if (this.isItem( item )) this.deleteItem( item ); } catch (e) { /* meh */ } },
292                                                                                         scope : status_store
293                                                                                 });
294                         
295                                                                                 current_status = null;
296                         
297                                                                                 highlighter.green.play();
298                                                                                 status_update( dojo.string.substitute(ccs_strings.STATUS_DELETED, [old_name]) );
299                                                                         }
300                                                                 });
301                 
302                                                         }
303                                                 }
304 ]]>
305                                         </script>
306                                 </button>
307         
308                         </div>
309                 </div>
310         
311         <script type="text/javascript">
312             var highlighter= {};
313             highlighter.green = dojox.fx.highlight( { color : '#B4FFB4', node : 'grid_container', duration : 500 } );
314             highlighter.red = dojox.fx.highlight( { color : '#FF2018', node : 'grid_container', duration : 500 } );
315         </script>
316  
317         </body>
318 </html>