]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/web/conify/global/actor/org_unit_type.html
LP#1617556 - Remove openils_dojo.js references
[Evergreen.git] / Open-ILS / web / conify / global / actor / org_unit_type.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
16 <!DOCTYPE html PUBLIC 
17         "-//W3C//DTD XHTML 1.0 Transitional//EN" 
18         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" [
19         <!--#include virtual="/opac/locale/${locale}/conify.dtd"-->
20 ]>
21
22 <html xmlns="http://www.w3.org/1999/xhtml">
23         <head>
24                 <title>&conify.org_unit_type.title;</title>
25
26                 <style type="text/css">
27                         @import url('/js/dojo/dojo/resources/dojo.css');
28                         @import url('/js/dojo/dijit/themes/tundra/tundra.css');
29                         @import url('/js/dojo/dojox/widget/Toaster/Toaster.css');
30                 </style>
31
32                 <style type="text/css">
33                         html, body
34                         {
35                                 height: 100%;
36                                 width: 100%;
37                                 margin: 0px 0px 0px 0px;
38                                 padding: 0px 0px 0px 0px;
39                                 overflow: hidden;
40                         }
41
42                         th
43                         {
44                                 text-align: right;
45                                 font-weight: bold;
46                                 padding-left: 20px;
47                                 padding-right: 5px;
48                         }
49                 </style>
50
51                 <!-- The OpenSRF API writ JS -->
52                 <script language='javascript' src='/IDL2js' type='text/javascript'></script>
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/dijit/dijit.js"></script>
61
62                 <script type="text/javascript" src="org_unit_type.js"></script>
63
64         <script type="text/javascript">
65 <![CDATA[
66             var dirtyStore = [];
67
68             var _out_type_list = pCRUD.retrieveAll('aout', { order_by : { aout : 'name' } });
69
70             var ou_type_store = new dojo.data.ItemFileWriteStore({ data : aout.toStoreData( _out_type_list ) });
71
72             ou_type_store.onSet = function (item, attr, o, n) {
73                 if (attr == 'ischanged') return;
74                 if (n == o) return;
75                 this.setValue( item, 'ischanged', 1);
76             };
77
78             dojo.addOnUnload( function (event) {
79
80                 ou_type_store.fetch({
81                     query : { ischanged : 1 },
82                     queryOptions : { deep : true },
83                     onItem : function (item, req) { try { if (this.isItem( item )) dirtyStore.push( item ); } catch (e) { /* meh */ } },
84                     scope : ou_type_store
85                 });
86
87                 if (dirtyStore.length > 0) {
88                     var confirmation = confirm(
89                         aout_strings.CONFIRM_UNSAVED_CHANGES
90                     );
91
92                     if (confirmation) {
93                         for (var i in dirtyStore) {
94                             current_type = dirtyStore[i];
95                             save_type(true);
96                         }
97                     }
98                 }
99
100             });
101 ]]>
102         </script>
103
104         </head>
105
106         <body class="tundra" id='pagebody'>
107
108                 <div dojoType="dijit.layout.SplitContainer" orientation="horizontal" style="height: 100%">
109
110                         <div dojoType="dijit.layout.ContentPane" sizeShare="100">
111                                 <div
112                                   id="type_tree"
113                                   label="&conify.org_unit_type.type_tree.label;"
114                                   query="{'_top':'true'}"
115                                   dojoType="dijit.Tree"
116                                   store="ou_type_store"
117                                   minSize="200"
118                                   jsId="type_tree"
119                                 >
120
121                                         <script type="dojo/method" event="onClick" args="item,node">
122 <![CDATA[
123                                                 right_pane_toggler.show();
124                                                 current_type = item;
125                                                 current_fm_type = new aout().fromStoreItem(item);
126
127                                                 highlighter.editor_pane.green.play();
128                                                 status_update( dojo.string.substitute( aout_strings.STATUS_EDITING, [this.store.getValue( item, 'name' )] ) );
129
130                                                 new_kid_button.disabled = false;
131                                                 save_out_button.disabled = false;
132                                                 delete_out_button.disabled = false;
133
134                                                 var main_settings_fields = [ 'name', 'opac_label'];
135                                                 for ( var i in main_settings_fields ) {
136                                                         var field = main_settings_fields[i];
137                                                         var value = this.store.getValue( current_type, field );
138
139                                                         if (!value) {
140                                                                 window["editor_pane_" + field].setValue( '' ); // unset the value
141                                                                 window["editor_pane_" + field].setDisplayedValue( '' ); // unset the value
142                                                         } else window["editor_pane_" + field].setValue( value );
143                                                 }
144
145                                                 if ( this.store.getValue( current_type, '_trueRoot' ) == 'true' ) {
146                                                         editor_pane_parent.disabled = true;
147                                                         editor_pane_parent.setValue(null);
148                                                         editor_pane_parent.setDisplayedValue('');
149                                                         editor_pane_parent.validate(false);
150                                                 } else {
151                                                         editor_pane_parent.disabled = false;
152                                                         editor_pane_parent.validate(true);
153                                                         editor_pane_parent.setValue( this.store.getValue( current_type, 'parent' ) );
154                                                 }
155
156                                                 editor_pane_can_have_vols.setChecked( this.store.getValue( current_type, 'can_have_vols' ) == 't' ? true : false );
157                                                 editor_pane_can_have_users.setChecked( this.store.getValue( current_type, 'can_have_users' ) == 't' ? true : false );
158 ]]>
159                                         </script>
160
161                                         <script type="dojo/method" event="getLabel" args="item,pI">
162                                                 var label = this.store.getValue(item,'name');
163                                                 if (this.store.getValue(item,'ischanged') == 1) label = '* ' + label;
164                                                 return label;
165                                         </script>
166
167                                 </div>
168                         </div>
169
170                         <div id="right_pane" dojoType="dijit.layout.ContentPane"  sizeShare="200">
171                                 <script type="dojo/method">
172                                         window.right_pane_toggler = new dojo.fx.Toggler({ node: 'right_pane'});
173                                         window.right_pane_toggler.hide();
174                                 </script>
175
176                                         <div id="editor_pane" dojoType="dijit.layout.ContentPane">
177                                                 <script type="dojo/method">
178                                                         highlighter.type_tree = {};
179                                                         highlighter.editor_pane = {};
180                                                         highlighter.type_tree.green = dojox.fx.highlight( { color : '#B4FFB4', node : 'type_tree', duration : 500 } );
181                                                         highlighter.type_tree.red = dojox.fx.highlight( { color : '#FF2018', node : 'type_tree', duration : 500 } );
182                                                         highlighter.editor_pane.green = dojox.fx.highlight( { color : '#B4FFB4', node : 'editor_pane', duration : 500 } );
183                                                         highlighter.editor_pane.red = dojox.fx.highlight( { color : '#FF2018', node : 'editor_pane', duration : 500 } );
184                                                 </script>
185         
186                                                 <table class="tundra" style="margin:10px;">
187                                                         <tr>
188                                                                 <th>&conify.org_unit_type.type_name;</th>
189                                                                 <td>
190                                                                         <span id="editor_pane_name" dojoType="dijit.form.ValidationTextBox" jsId="editor_pane_name" regExp=".+" required="true">
191                                                                                 <script type="dojo/connect" event="onChange">
192                                                                                         if (current_type) {
193                                                                                                 ou_type_store.setValue( current_type, "name", this.getValue() );
194                                                                                         }
195                                                                                 </script>
196                                                                         </span>
197                                                                         <span dojoType="openils.widget.TranslatorPopup" targetObject="current_fm_type" field="name"></span>
198                                                                 </td>
199                                                         </tr>
200                                                         <tr>
201                                                                 <th>&conify.org_unit_type.opac_label;</th>
202                                                                 <td>
203                                                                         <span id="editor_pane_opac_label" dojoType="dijit.form.ValidationTextBox" jsId="editor_pane_opac_label" regExp=".+" required="true">
204                                                                                 <script type="dojo/connect" event="onChange">
205                                                                                         if (current_type) {
206                                                                                                 ou_type_store.setValue( current_type, "opac_label", this.getValue() );
207                                                                                         }
208                                                                                 </script>
209                                                                         </span>
210                                                                         <span dojoType="openils.widget.TranslatorPopup" targetObject="current_fm_type" field="opac_label"></span>
211                                                                 </td>
212                                                         </tr>
213                                                         <tr>
214                                                                 <th>&conify.org_unit_type.parent_type;</th>
215                                                                 <td>
216                                                                         <div
217                                                                           id="editor_pane_parent"
218                                                                           dojoType="dijit.form.FilteringSelect"
219                                                                           jsId="editor_pane_parent"
220                                                                           store="ou_type_store"
221                                                                           searchAttr="name"
222                                                                           ignoreCase="true"
223                                                                           required="true"
224                                                                         >
225                                                                                 <script type="dojo/method" event="onChange">
226 <![CDATA[
227                                                                                         if (current_type && this.getValue()) {
228                                                                                                 if ( this.store.getValue( current_type, 'parent' ) == this.getValue() ) return;
229
230                                                                                                 this.store.setValue( current_type, "parent", this.getValue() );
231                                                                                                 this.store.fetch({
232                                                                                                         query : { "parent" : this.getValue() },
233                                                                                                         onItem: function (parent_item) {
234                                                                                                                 this.setValue( current_type, 'depth', 1 + parseInt(this.getValue( parent_item, 'depth' ) ));
235                                                                                                         },
236                                                                                                         scope : ou_type_store
237                                                                                                 });
238                                                                                         }
239 ]]>
240                                                                                 </script>
241                                                                         </div>
242                                                                 </td>
243                                                         </tr>
244                                                         <tr>
245                                                                 <th>&conify.org_unit_type.can_have_volumes;</th>
246                                                                 <td>
247                                                                         <input
248                                                                           id="editor_pane_can_have_vols"
249                                                                           jsId="editor_pane_can_have_vols"
250                                                                           type="checkbox"
251                                                                           dojoType="dijit.form.CheckBox"
252                                                                           onChange="if (current_type) ou_type_store.setValue( current_type, 'can_have_vols', this.checked ? 't' : 'f' );"
253                                                                         />
254                                                                 </td>
255                                                         </tr>
256                                                         <tr>
257                                                                 <th>&conify.org_unit_type.can_have_users;</th>
258                                                                 <td>
259                                                                         <input
260                                                                           id="editor_pane_can_have_users"
261                                                                           jsId="editor_pane_can_have_users"
262                                                                           type="checkbox"
263                                                                           dojoType="dijit.form.CheckBox"
264                                                                           onChange="if (current_type) ou_type_store.setValue( current_type, 'can_have_users', this.checked ? 't' : 'f' );"
265                                                                         />
266                                                                 </td>
267                                                         </tr>
268                                                 </table>
269         
270                                                 <div dojoType="dijit.layout.ContentPane" orientation="horizontal" style="margin-bottom: 20px;">
271         
272                                                         <button jsId="save_out_button" dojoType="dijit.form.Button" label="&conify.save_button.label;" onClick="save_type()">
273                                                                 <script type="dojo/connect" event="startup">
274                                                                         this.disabled = true;
275                                                                 </script>
276                                                         </button>
277         
278                                                         <button jsId="delete_out_button" dojoType="dijit.form.Button" label="&conify.delete_button.label;">
279                                                                 <script type="dojo/connect" event="startup">
280                                                                         this.disabled = true;
281                                                                 </script>
282                                                                 <script type="dojo/connect" event="onClick">
283 <![CDATA[
284         
285                                                                         if (ou_type_store.getValue( current_type, '_trueRoot' ) == 'true') {
286                                                                                 highlighter.editor_pane.red.play();
287                                                                                 status_update( dojo.string.substitute( aout_strings.ERROR_DELETING_LAST_AOUT, [ou_type_store.getValue( current_type, 'name' )] ) );
288                                                                                 return false;
289                                                                         }
290
291                                                                         if ( current_type.children ) {
292                                                                                 var kids = current_type.children;
293                                                                                 if (!dojo.isArray(kids)) kids = [kids];
294         
295                                                                                 var existing_kids = dojo.filter(
296                                                                                         kids,
297                                                                                         function(kid){ return kid.isdeleted[0] != 1 }
298                                                                                 );
299                                                                                 if ( existing_kids.length > 0) {
300                                                                                         highlighter.editor_pane.red.play();
301                                                                                         status_update( dojo.string.substitute( aout_strings.ERROR_ORPHANS, [ou_type_store.getValue( current_type, 'name' ), existing_kids.length] ) );
302                                                                                         return;
303                                                                                 }
304                                                                         }
305         
306                                                                         if ( confirm( dojo.string.substitute ( aout_strings.CONFIRM_DELETE, [current_type.name] ))) {
307                                                                                 ou_type_store.setValue( current_type, 'isdeleted', 1 );
308         
309                                                                                 var modified_aout = new aout().fromStoreItem( current_type );
310                                                                                 modified_aout.isdeleted( 1 );
311         
312                                                                                 pCRUD.eliminate(modified_aout, {
313                                                                                         onerror : function (r) {
314                                                                                                 highlighter.editor_pane.red.play();
315                                                                                                 status_update( dojo.string.substitute ( aout_strings.ERROR_DELETING, [ou_type_store.getValue( current_type, 'name' )] ) );
316                                                                                         },
317                                                                                         oncomplete : function (r) {
318         
319                                                                                                 var old_name = ou_type_store.getValue( current_type, 'name' );
320
321                                                                                                 ou_type_store.fetch({
322                                                                                                         query : { id : ou_type_store.getValue( current_type, 'id' ) },
323                                                                                                         queryOptions : { deep : true },
324                                                                                                         onItem : function (item, req) { try { if (this.isItem( item )) this.deleteItem( item ); } catch (e) { /* meh */ } },
325                                                                                                         scope : ou_type_store
326                                                                                                 });
327         
328                                                                                                 current_type = null;
329         
330                                                                                                 new_kid_button.disabled = true;
331                                                                                                 save_out_button.disabled = true;
332                                                                                                 delete_out_button.disabled = true;
333                         
334                                                                                                 var main_settings_fields = [ 'name', 'opac_label' ];
335                                                                                                 for ( var i in main_settings_fields ) {
336                                                                                                         var field = main_settings_fields[i];
337                                                                                                         window["editor_pane_" + field].setValue( '' ); // unset the value
338                                                                                                         window["editor_pane_" + field].setDisplayedValue( '' ); // unset the value
339                                                                                                 }
340
341                                                                                                 window["editor_pane_can_have_vols"].setChecked( false ); // unset the value
342                                                                                                 window["editor_pane_can_have_users"].setChecked( false ); // unset the value
343                 
344                                                                                                 highlighter.editor_pane.green.play();
345                                                                                                 status_update( dojo.string.substitute( aout_strings.STATUS_DELETED, [old_name] ) );
346                                                                                         }
347                                                                                 });
348         
349                                                                         }
350 ]]>
351                                                                 </script>
352                                                         </button>
353         
354                                                 </div>
355         
356                                                 <button jsId="new_kid_button" dojoType="dijit.form.Button" label="&conify.new_kid_button.label;">
357                                                         <script type="dojo/connect" event="startup">
358                                                                 this.disabled = true;
359                                                         </script>
360                                                         <script type="dojo/connect" event="onClick">
361 <![CDATA[
362                                                                 var new_fm_obj = new aout().fromHash({
363                                                                         isnew                   : 1,
364                                                                         name                    : aout_strings.LABEL_NEW_TYPE,
365                                                                         can_have_vols   : 'f',
366                                                                         can_have_users  : 'f',
367                                                                         depth                   : 1 + parseInt(ou_type_store.getValue( current_type, 'depth' )),
368                                                                         opac_label              : ou_type_store.getValue( current_type, 'opac_label' ) + ' child' + virgin_out_id--,
369                                                                         parent                  : ou_type_store.getValue( current_type, 'id' )
370                                                                 });
371                                                                 var err = false;
372                                                                 pCRUD.create(new_fm_obj, {
373                                                                         onerror : function (r) {
374                                                                                 highlighter.editor_pane.red.play();
375                                                                                 status_update( aout_strings.ERROR_CALLING_METHOD_AOUT );
376                                                                                 err = true;
377                                                                         },
378                                                                         oncomplete : function (r, list) {
379                                                                                 ou_type_store.newItem(
380                                                                                         list[0].toHash(),
381                                                                                         { parent : current_type, attribute : 'children' }
382                                                                                 );
383                                                                         },
384                                                                 });
385         
386                                                                 if (!err) {
387                                                                         highlighter.editor_pane.green.play();
388                                                                         highlighter.type_tree.green.play();
389                                                                         status_update( dojo.string.substitute( aout_strings.SUCCESS_CREATING_CHILD_AOUT, [ou_type_store.getValue( current_type, 'name' )] ) );
390                                                                 }
391 ]]>
392                                                         </script>
393                                                 </button>
394         
395                                         </div>
396                                 </div>
397                         </div>
398         </body>
399 </html>