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