]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/web/conify/global/config/copy_status.html
fixing translation framework for perms and statuses; adding marc codes to admin page
[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 <html xmlns="http://www.w3.org/1999/xhtml">
16         <head>
17                 <title>Confiy :: Global :: Config :: Copy Status</title>
18
19                 <style type="text/css">
20                         @import url("/js/dojo/dojox/grid/_grid/tundraGrid.css");
21                         @import url("/js/dojo/dojo/resources/dojo.css");
22                         @import url("/js/dojo/dijit/themes/tundra/tundra.css");
23                         @import url("/js/dojo/dojox/widget/Toaster/Toaster.css");
24                 </style>
25
26                 <style>
27                         html, body {
28                                 height: 100%;
29                                 width: 100%;
30                                 margin: 0px 0px 0px 0px;
31                                 padding: 0px 0px 0px 0px;
32                                 overflow: hidden;
33                         }
34
35                         #status_grid {
36                                 border: 0px;
37                                 width: 100%;
38                                 height: 100%;
39                         }
40
41                         #grid_container {
42                                 width: 100%;
43                                 height: 100%;
44                         }
45                 </style>
46
47                 <!-- The OpenSRF API writ JS -->
48                 <script language='javascript' src='/opac/common/js/utils.js' type='text/javascript'></script>
49                 <script language='javascript' src='/opac/common/js/Cookies.js' type='text/javascript'></script>
50                 <script language='javascript' src='/opac/common/js/CGI.js' type='text/javascript'></script>
51                 <script language='javascript' src='/opac/common/js/JSON_v1.js' type='text/javascript'></script>
52
53                 <!-- Dojo goodness -->
54                 <script type="text/javascript" src="../admin.js"></script>
55                 <script type="text/javascript" src="/js/dojo/dojo/dojo.js"></script>
56                 <script type="text/javascript" src="/js/dojo/dijit/dijit.js"></script>
57
58                 <script type="text/javascript" src="copy_status.js"></script>
59
60         </head>
61
62         <body class="tundra" id='pagebody'>
63
64                 <div dojoType="dijit.layout.LayoutContainer" id="grid_container" jsId="grid_container" orientation="vertical">
65                         <script type="dojo/method">
66                                 window.highlighter= {};
67                                 window.highlighter.green = dojox.fx.highlight( { color : '#B4FFB4', node : 'grid_container', duration : 500 } );
68                                 window.highlighter.red = dojox.fx.highlight( { color : '#FF2018', node : 'grid_container', duration : 500 } );
69
70                                 window.dirtyStore = [];
71
72                 pCRUD.request({
73                     method : 'open-ils.permacrud.search.ccs.atomic',
74                     timeout : 10,
75                     params : [ ses, { id : { "!=" : null } }, { order_by : { ccs : 'name' } } ],
76                     onerror : function (r) { status_update('Problem fetching statuses') },
77                     oncomplete : function (r) {
78
79                         window._status_list = r.recv().content();
80                         window._status_data = ccs.toStoreData( window._status_list, 'name' );
81                         window.status_store = new dojo.data.ItemFileWriteStore({ data : window._status_data });
82
83                             window.status_store.onSet = function (item, attr, o, n) {
84                             if (attr == 'ischanged') return;
85                             if (n == o) return;
86                             this.setValue( item, 'ischanged', 1);
87
88                             if (attr == 'holdable' && typeof n != 'string')
89                                 this.setValue(item, 'holdable', n ? 't' : 'f');
90
91                             if (attr == 'opac_visible' && typeof n != 'string')
92                                 this.setValue(item, 'opac_visible', n ? 't' : 'f');
93
94                         };
95
96                         dojo.addOnUnload( function (event) {
97
98                             status_store.fetch({
99                                 query : { ischanged : 1 },
100                                 onItem : function (item, req) { try { if (this.isItem( item )) window.dirtyStore.push( item ); } catch (e) { /* meh */ } },
101                                 scope : status_store
102                             });
103
104                             if (dirtyStore.length > 0) {
105                                 var confirmation = confirm(
106                                     'There are unsaved modified Statuses!  '+
107                                     'OK to save these changes, Cancel to abandon them.'
108                                 );
109
110                                 if (confirmation) {
111                                     for (var i in window.dirtyStore) {
112                                         window.current_status = window.dirtyStore[i];
113                                         save_status(true);
114                                     }
115                                 }
116                             }
117
118                         });
119                     }
120                 }).send();
121
122                         </script>
123
124                         <div dojoType="dijit.layout.LayoutContainer" orientation="horizontal" style="margin-top: 5px;" layoutAlign="top">
125                                 <span>New Status:</span>
126                                 <div dojoType="dijit.form.TextBox" id="new_status_code" jsId="new_status_name" label="New Status Name"></div>
127                                 <button dojoType="dijit.form.Button" id="save_new_status_code" jsId="save_new_status_name" label="Add"> 
128                                         <script type="dojo/connect" event="onClick">
129
130                                                 var new_name = new_status_name.getValue();
131                                                 if (!new_name) return;
132
133                         var new_fm_obj = new ccs().fromHash({
134                                 isnew           : 1,
135                             name            : new_name
136                             });
137     
138                         var err = false;
139                             pCRUD.request({
140                             method : 'open-ils.permacrud.create.ccs',
141                                 timeout : 10,
142                             params : [ ses, new_fm_obj ],
143                                 onerror : function (r) {
144                                 highlighter.red.play();
145                                     status_update( 'Problem calling method to create new Status' );
146                                 err = true;
147                                 },
148                                 oncomplete : function (r) {
149                                 var res = r.recv();
150                                     if ( res && res.content() ) {
151                                     var new_item_hash = res.content().toHash();
152                                     status_store.newItem( new_item_hash );
153                                                                         status_update( 'New ' + new_item_hash.name + ' status created' );
154                                                                         status_grid.model.sort(-2);
155                                                                         highlighter.green.play();
156                                 } else {
157                                         highlighter.red.play();
158                                     status_update( 'Problem creating new Status' );
159                                         err = true;
160                                 }
161                                 }
162                         }).send();
163     
164                         </script>
165                                 </button>
166                         </div>
167
168                         <div dojoType="dijit.layout.ContentPane" style="width:100%; height:100%;" layoutAlign="client">
169                                 <div dojoType="dojox.grid.data.DojoData" id="status_data_model"jsId="status_data_model" store="status_store" query="{ 'id' : '*' }"></div>
170                                 <div id="status_grid" dojoType="dojox.Grid" jsId="status_grid">
171                                         <script type="dojo/connect" event="startup">
172                                                 var g = this;
173                                                 var status_grid_layout = [
174                                                         {       cells : [
175                                                                         [
176                                                                                 { name : "ID",
177                                                                                   field : "id",
178                                                                                 },
179                                                                                 { name : "Name",
180                                                                                   field : "name",
181                                                                                   width : "auto",
182                                                                                   editor : dojox.grid.editors.Dijit
183                                                                                 },
184                                                                                 { name : "Translation",
185                                                                                   width : "10em",
186                                                                                   height : "2em",
187                                                                                   get : function (row) {
188                                                                                         if (!window.status_rows) window.status_rows = [];
189                                                                                         var r = window.status_data_model.getRow(row);
190                                                                                         if (r) {
191                                                                                                 window.status_rows[row] = new ccs().fromHash(window.status_data_model.getRow(row));
192                                                                                                 setTimeout(
193                                                                                                         'dojo.query(".status_grid_trans_cell_' + row + '").'+
194                                                                                                                 'instantiate(openils.widget.TranslatorPopup,{field:"name",'+
195                                                                                                                 'unique:window.status_rows['+row+'].id(),'+
196                                                                                                                 'targetObject:"window.status_rows['+row+']"});'+
197                                                                                                                 'status_grid.rowHeightChanged('+row+')',
198                                                                                                         0
199                                                                                                 );
200                                                                                                 var oldnode = dojo.byId('name_translation_' + row);
201                                                                                                 if (oldnode) dijit.byNode(oldnode).destroyRecursive();
202                                                                                                 return '<span class="status_grid_trans_cell_'+row+'"></span>';
203                                                                                         }
204                                                                                         return '';
205                                                                                   }
206                                                                                 },
207                                                                                 { name : "Holdable",
208                                                                                   field : "holdable",
209                                                                                   editor : dojox.grid.editors.bool,
210                                                                                   get : function (row) {
211                                                                                         var r = window.status_data_model.getRow(row);
212                                                                                         if (r) {
213                                                                                                 var h = r.holdable;
214                                                                                                 if (h == 't' || h === true) return true;
215                                                                                                 return false;
216                                                                                         }
217                                                                                   }
218                                                                                 },
219                                                                                 { name : "OPAC Visible",
220                                                                                   field : "opac_visible",
221                                                                                   editor : dojox.grid.editors.bool,
222                                                                                   get : function (row) {
223                                                                                         var r = window.status_data_model.getRow(row);
224                                                                                         if (r) {
225                                                                                                 var h = r.opac_visible;
226                                                                                                 if (h == 't' || h === true) return true;
227                                                                                                 return false;
228                                                                                         }
229                                                                                   }
230                                                                                 }
231                                                                         ]
232                                                                 ]
233                                                         }
234                                                 ];
235
236                                                 this.setStructure(status_grid_layout);
237                                                 this.setModel(window.status_data_model);
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="Save Changes" onClick="save_them_all()"></button>
245                 
246                                 <button jsId="delete_ccs_button" dojoType="dijit.form.Button" label="Delete Selected">
247                                         <script type="dojo/connect" event="onClick">
248
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('Are you sure you want to 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.request({
271                                                                         method : 'open-ils.permacrud.delete.ccs',
272                                                                         timeout : 10,
273                                                                         params : [ ses, modified_ccs ],
274                                                                         onerror : function (r) {
275                                                                                 highlighter.red.play();
276                                                                                 status_update( 'Problem deleting ' + status_store.getValue( current_status, 'name' ) );
277                                                                         },
278                                                                         oncomplete : function (r) {
279                                                                                 var res = r.recv();
280                                                                                 if ( res && res.content() ) {
281                         
282                                                                                         var old_name = status_store.getValue( current_status, 'name' );
283                 
284                                                                                         status_store.fetch({
285                                                                                                 query : { id : status_store.getValue( current_status, 'id' ) },
286                                                                                                 onItem : function (item, req) { try { if (this.isItem( item )) this.deleteItem( item ); } catch (e) { /* meh */ } },
287                                                                                                 scope : status_store
288                                                                                         });
289                         
290                                                                                         current_status = null;
291                         
292                                                                                         highlighter.green.play();
293                                                                                         status_update( old_name + ' deleted' );
294                                                                                 } else {
295                                                                                         highlighter.red.play();
296                                                                                         status_update( 'Problem deleting ' + old_name );
297                                                                                 }
298                                                                         }
299                                                                 }).send();
300                 
301                                                         }
302                                                 }
303         
304                                         </script>
305                                 </button>
306         
307                         </div>
308                 </div>
309         
310         </body>
311 </html>