]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/web/conify/global/config/copy_status.html
locale parsing based on URL knowledge (because apache is not helping); aou.name trans...
[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                 <!-- Fieldmapper objects -->
54                 <script language='javascript' src='/opac/common/js/fmall.js' type='text/javascript'></script>
55
56                 <!-- Dojo goodness -->
57                 <script type="text/javascript" src="/js/dojo/dojo/dojo.js" djConfig="parseOnLoad: true"></script>
58                 <script type="text/javascript" src="/js/dojo/dijit/dijit.js"></script>
59
60                 <script type="text/javascript" src="copy_status.js"></script>
61
62         </head>
63
64         <body class="tundra" id='pagebody'>
65
66                 <div dojoType="dijit.layout.LayoutContainer" id="grid_container" jsId="grid_container" orientation="vertical">
67                         <script type="dojo/method">
68                                 window.highlighter= {};
69                                 window.highlighter.green = dojox.fx.highlight( { color : '#B4FFB4', node : 'grid_container', duration : 500 } );
70                                 window.highlighter.red = dojox.fx.highlight( { color : '#FF2018', node : 'grid_container', duration : 500 } );
71
72                                 window.dirtyStore = [];
73
74                 pCRUD.request({
75                     method : 'open-ils.permacrud.search.ccs.atomic',
76                     timeout : 10,
77                     params : [ ses, { id : { "!=" : null } }, { order_by : { ccs : 'name' } } ],
78                     onerror : function (r) { status_update('Problem fetching statuses') },
79                     oncomplete : function (r) {
80
81                         window._status_list = r.recv().content();
82                         window._status_data = ccs.toStoreData( window._status_list, 'name' );
83                         window.status_store = new dojo.data.ItemFileWriteStore({ data : window._status_data });
84
85                             window.status_store.onSet = function (item, attr, o, n) {
86                             if (attr == 'ischanged') return;
87                             if (n == o) return;
88                             this.setValue( item, 'ischanged', 1);
89
90                             if (attr == 'holdable' && typeof n != 'string')
91                                 this.setValue(item, 'holdable', n ? 't' : 'f');
92
93                         };
94
95                         dojo.addOnUnload( function (event) {
96
97                             status_store.fetch({
98                                 query : { ischanged : 1 },
99                                 onItem : function (item, req) { try { if (this.isItem( item )) window.dirtyStore.push( item ); } catch (e) { /* meh */ } },
100                                 scope : status_store
101                             });
102
103                             if (dirtyStore.length > 0) {
104                                 var confirmation = confirm(
105                                     'There are unsaved modified Statuses!  '+
106                                     'OK to save these changes, Cancel to abandon them.'
107                                 );
108
109                                 if (confirmation) {
110                                     for (var i in window.dirtyStore) {
111                                         window.current_status = window.dirtyStore[i];
112                                         save_status(true);
113                                     }
114                                 }
115                             }
116
117                         });
118                     }
119                 }).send();
120
121                         </script>
122
123                         <div dojoType="dijit.layout.LayoutContainer" orientation="horizontal" style="margin-top: 5px;" layoutAlign="top">
124                                 <span>New Status:</span>
125                                 <div dojoType="dijit.form.TextBox" id="new_status_code" jsId="new_status_name" label="New Status Name"></div>
126                                 <button dojoType="dijit.form.Button" id="save_new_status_code" jsId="save_new_status_name" label="Add"> 
127                                         <script type="dojo/connect" event="onClick">
128
129                                                 var new_name = new_status_name.getValue();
130                                                 if (!new_name) return;
131
132                         var new_fm_obj = new ccs().fromHash({
133                                 isnew           : 1,
134                             name            : new_name
135                             });
136     
137                         var err = false;
138                             pCRUD.request({
139                             method : 'open-ils.permacrud.create.ccs',
140                                 timeout : 10,
141                             params : [ ses, new_fm_obj ],
142                                 onerror : function (r) {
143                                 highlighter.red.play();
144                                     status_update( 'Problem calling method to create new Status' );
145                                 err = true;
146                                 },
147                                 oncomplete : function (r) {
148                                 var res = r.recv();
149                                     if ( res && res.content() ) {
150                                     var new_item_hash = res.content().toHash();
151                                     status_store.newItem( new_item_hash );
152                                                                         status_update( 'New ' + new_item_hash.name + ' status created' );
153                                                                         status_grid.model.sort(-2);
154                                                                         highlighter.green.play();
155                                 } else {
156                                         highlighter.red.play();
157                                     status_update( 'Problem creating new Status' );
158                                         err = true;
159                                 }
160                                 }
161                         }).send();
162     
163                         </script>
164                                 </button>
165                         </div>
166
167                         <div dojoType="dijit.layout.ContentPane" style="width:100%; height:100%;" layoutAlign="client">
168                                 <div dojoType="dojox.grid.data.DojoData" id="status_data_model"jsId="status_data_model" store="status_store" query="{ 'id' : '*' }"></div>
169                                 <div id="status_grid" dojoType="dojox.Grid" jsId="status_grid">
170                                         <script type="dojo/connect" event="startup">
171                                                 var g = this;
172                                                 var status_grid_layout = [
173                                                         {       cells : [
174                                                                         [
175                                                                                 { name : "ID",
176                                                                                   field : "id",
177                                                                                 },
178                                                                                 { name : "Name",
179                                                                                   field : "name",
180                                                                                   width : "auto",
181                                                                                   editor : dojox.grid.editors.Dijit
182                                                                                 },
183                                                                                 { name : "Holdable",
184                                                                                   field : "holdable",
185                                                                                   editor : dojox.grid.editors.bool,
186                                           get : function (row) {
187                                                 var r = window.status_data_model.getRow(row);
188                                                                                         if (r) {
189                                                         var h = r.holdable;
190                                                             if (h == 't' || h === true) return true;
191                                                                 return false;
192                                                                                         }
193                                           }
194                                                                                 }
195                                                                         ]
196                                                                 ]
197                                                         }
198                                                 ];
199
200                                                 this.setStructure(status_grid_layout);
201                                                 this.setModel(window.status_data_model);
202                                         </script>
203                                 </div>
204                         </div>
205
206                         <div dojoType="dijit.layout.ContentPane" orientation="horizontal" style="margin-bottom: 5px;" layoutAlign="bottom">
207                 
208                                 <button jsId="save_ccs_button" dojoType="dijit.form.Button" label="Save Changes" onClick="save_them_all()"></button>
209                 
210                                 <button jsId="delete_ccs_button" dojoType="dijit.form.Button" label="Delete Selected">
211                                         <script type="dojo/connect" event="onClick">
212
213                                                 var selected_rows = status_grid.selection.getSelected();
214                 
215                                                 var selected_items = [];
216                                                 for (var i in selected_rows) {
217                                                         selected_items.push(
218                                                                 status_grid.model.getRow( selected_rows[i] ).__dojo_data_item
219                                                         );
220                                                 }
221
222                                                 status_grid.selection.clear();
223
224                                                 for (var i in selected_items) {
225                                                         current_status = selected_items[i];
226
227                                                         if ( confirm('Are you sure you want to delete ' + status_store.getValue( current_status, 'name' ) + '?')) {
228
229                                                                 status_store.setValue( current_status, 'isdeleted', 1 );
230                         
231                                                                 var modified_ccs = new ccs().fromStoreItem( current_status );
232                                                                 modified_ccs.isdeleted( 1 );
233                         
234                                                                 pCRUD.request({
235                                                                         method : 'open-ils.permacrud.delete.ccs',
236                                                                         timeout : 10,
237                                                                         params : [ ses, modified_ccs ],
238                                                                         onerror : function (r) {
239                                                                                 highlighter.red.play();
240                                                                                 status_update( 'Problem deleting ' + status_store.getValue( current_status, 'name' ) );
241                                                                         },
242                                                                         oncomplete : function (r) {
243                                                                                 var res = r.recv();
244                                                                                 if ( res && res.content() ) {
245                         
246                                                                                         var old_name = status_store.getValue( current_status, 'name' );
247                 
248                                                                                         status_store.fetch({
249                                                                                                 query : { id : status_store.getValue( current_status, 'id' ) },
250                                                                                                 onItem : function (item, req) { try { if (this.isItem( item )) this.deleteItem( item ); } catch (e) { /* meh */ } },
251                                                                                                 scope : status_store
252                                                                                         });
253                         
254                                                                                         current_status = null;
255                         
256                                                                                         highlighter.green.play();
257                                                                                         status_update( old_name + ' deleted' );
258                                                                                 } else {
259                                                                                         highlighter.red.play();
260                                                                                         status_update( 'Problem deleting ' + old_name );
261                                                                                 }
262                                                                         }
263                                                                 }).send();
264                 
265                                                         }
266                                                 }
267         
268                                         </script>
269                                 </button>
270         
271                         </div>
272                 </div>
273         
274         </body>
275 </html>