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