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