]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/web/conify/global/permission/grp_tree.html
d6ebe497e695c58843841f81bf026be489623f6c
[Evergreen.git] / Open-ILS / web / conify / global / permission / grp_tree.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.w2.org/1999/xhtml">
21         <head>
22                 <title>&conify.grp_tree.group_tree.title;</title>
23
24                 <style type="text/css">
25                         @import url('/js/dojo/dojox/grid/_grid/tundraGrid.css');
26                         @import url('/js/dojo/dojo/resources/dojo.css');
27                         @import url('/js/dojo/dijit/themes/tundra/tundra.css');
28                         @import url('/js/dojo/dojox/widget/Toaster/Toaster.css');
29                 </style>
30
31                 <style type="text/css">
32                         html, body
33                         {
34                                 height: 100%;
35                                 width: 100%;
36                                 margin: 0px 0px 0px 0px;
37                                 padding: 0px 0px 0px 0px;
38                                 overflow: hidden;
39                         }
40
41                         th
42                         {
43                                 text-align: right;
44                                 font-weight: bold;
45                                 padding-left: 20px;
46                                 padding-right: 5px;
47                         }
48
49             #perm_grid {
50                 border: 0px;
51                 width: 100%;
52                 height: 100%;
53             }
54
55             #grid_container {
56                 width: 75%;
57                 height: 100%;
58             }
59
60             /* this is a hack to get the right pane to display
61                in recent browsers when using this interface
62                embedded in the web staff client
63             */
64             .dijitLayoutContainer {
65                 position: static;
66             }
67
68                 </style>
69
70                 <!-- The OpenSRF API writ JS -->
71                 <script language='javascript' src='/IDL2js' type='text/javascript'></script>
72                 <script language='javascript' src='/opac/common/js/utils.js' type='text/javascript'></script>
73                 <script language='javascript' src='/opac/common/js/CGI.js' type='text/javascript'></script>
74                 <script language='javascript' src='/opac/common/js/JSON_v1.js' type='text/javascript'></script>
75
76                 <!-- Dojo goodness -->
77                 <script type="text/javascript" src="../admin.js"></script>
78                 <script type="text/javascript" src="/js/dojo/dojo/dojo.js"></script>
79                 <script type="text/javascript" src="/js/dojo/dojo/openils_dojo.js"></script>
80                 <script type="text/javascript" src="/js/dojo/dijit/dijit.js"></script>
81
82                 <script type="text/javascript" src="grp_tree.js"></script>
83
84         <script type="text/javascript"><![CDATA[
85             var dirtyStore = [];
86             var current_group;
87
88             var _group_list = server.pcrud.retrieveAll('pgt', { order_by : { pgt : 'name' } });
89             var _group_data = pgt.toStoreData( _group_list );
90             var group_store = new dojo.data.ItemFileWriteStore({ data : _group_data });
91
92             group_store.onSet = function (item, attr, o, n) {
93                 if (attr == 'ischanged') return;
94                 if (n == o) return;
95                 this.setValue( item, 'ischanged', 1);
96             };
97
98             dojo.addOnUnload( function (event) {
99
100                 group_store.fetch({
101                     query : { ischanged : 1 },
102                     queryOptions : { deep : true },
103                     onItem : function (item, req) { try { if (this.isItem( item )) dirtyStore.push( item ); } catch (e) { /* meh */ } },
104                     scope : group_store
105                 });
106
107                 if (dirtyStore.length > 0) {
108                     var confirmation = confirm( pgt_strings.CONFIRM_EXIT_PGT );
109
110                     if (confirmation) {
111                         for (var i in dirtyStore) {
112                             current_group = dirtyStore[i];
113                             save_group(true);
114                         }
115                     }
116                 }
117
118             });
119
120             var _ou_type_list = server.pcrud.retrieveAll('aout', { order_by : { aout : 'depth' } });
121             var _ou_type_data = aout.toStoreData( _ou_type_list );
122             var ou_type_store = new dojo.data.ItemFileReadStore({ data : _ou_type_data });
123
124             var _perm_list = server.pcrud.retrieveAll('ppl', { order_by : { ppl : 'code' } });
125             var _perm_data = ppl.toStoreData( _perm_list, 'code' );
126             var _perm_name_data = ppl.toStoreData( _perm_list, 'code', { identifier : 'code' } );
127
128             var perm_store = new dojo.data.ItemFileWriteStore({ data : _perm_data });
129             var perm_name_store = new dojo.data.ItemFileWriteStore({ data : _perm_name_data });
130
131             var _perm_map_list = server.pcrud.retrieveAll('pgpm');
132             var _perm_map_data = pgpm.toStoreData( _perm_map_list, 'id' );
133             var perm_map_store = new dojo.data.ItemFileWriteStore({ data : _perm_map_data });
134
135             perm_map_store.onSet = function (item, attr, o, n) {
136                 if (attr == 'ischanged') return;
137                 if (n == o) return;
138
139                 this.setValue( item, 'ischanged', 1);
140
141                 if (attr == 'grantable' && (typeof (n) != 'string'))
142                     this.setValue(item, 'grantable', n ? 't' : 'f');
143             }
144
145             dojo.addOnUnload( function (event) { save_them_all(); });
146
147         ]]></script>
148
149         </head>
150
151         <body class="tundra" id='pagebody'>
152
153                 <div dojoType="dijit.layout.SplitContainer" orientation="horizontal" style="height: 100%">
154
155                         <div dojoType="dijit.layout.ContentPane" sizeShare="100">
156                                 <div
157                                   id="group_tree"
158                   label="&conify.grp_tree.permission_groups.label;"
159                                   dojoType="dijit.Tree"
160                                   store="group_store"
161                   query="{'_top':'true'}"
162                                   minSize="200"
163                                   jsId="group_tree"
164                                 >
165
166                                         <script type="dojo/method" event="onClick" args="item,node">
167 <![CDATA[
168                                                 right_pane_toggler.show();
169
170                                                 current_group = item;
171                                                 window.current_fm_group = new pgt().fromStoreItem(item);
172
173                                                 perm_map_model.query = { grp : current_group ? group_store.getValue(current_group,'id') : -1 };
174                                                 perm_map_model.refresh();
175                                                 perm_grid.refresh();
176
177                                                 highlighter.editor_pane.green.play();
178                                                 status_update( dojo.string.substitute( pgt_strings.STATUS_EDITING, [this.store.getValue( item, 'name' )]) );
179
180                                                 new_kid_button.disabled = false;
181                                                 save_group_button.disabled = false;
182                                                 delete_group_button.disabled = false;
183
184                                                 var main_settings_fields = [ 'name', 'perm_interval', 'description'];
185                                                 for ( var i in main_settings_fields ) {
186                                                         var field = main_settings_fields[i];
187                                                         var value = this.store.getValue( current_group, field );
188
189                                                         if (!value) {
190                                                                 window["editor_pane_" + field].setValue( '' ); // unset the value
191                                                                 if (field != 'description') window["editor_pane_" + field].setDisplayedValue( '' ); // unset the value
192                                                         } else window["editor_pane_" + field].setValue( value );
193                                                 }
194
195                                                 if ( this.store.getValue( current_group, '_trueRoot' ) == 'true' ) {
196                                                         editor_pane_parent.disabled = true;
197                                                         editor_pane_parent.setValue(null);
198                                                         editor_pane_parent.setDisplayedValue('');
199                                                         editor_pane_parent.validate(false);
200                                                 } else {
201                                                         editor_pane_parent.disabled = false;
202                                                         editor_pane_parent.validate(true);
203                                                         editor_pane_parent.setValue( this.store.getValue( current_group, 'parent' ) );
204                                                 }
205
206                                                 editor_pane_application_perm.setValue( this.store.getValue( current_group, 'application_perm' ) );
207                                                 editor_pane_hold_priority.setValue( this.store.getValue( current_group, 'hold_priority' ) );
208
209                                                 editor_pane_usergroup.setChecked( this.store.getValue( current_group, 'usergroup' ) == 't' ? true : false );
210 ]]>
211                                         </script>
212
213                                         <script type="dojo/method" event="getLabel" args="item,pI">
214                                                 var label = this.store.getValue(item,'name');
215                                                 if (this.store.getValue(item,'ischanged') == 1) label = '* ' + label;
216                                                 return label;
217                                         </script>
218
219                                 </div>
220                         </div>
221
222                         <div id="right_pane" dojoType="dijit.layout.ContentPane"  sizeShare="300">
223                                 <script type="dojo/method">
224                                         window.right_pane_toggler = new dojo.fx.Toggler({ node: 'right_pane'});
225                                         window.right_pane_toggler.hide();
226                                 </script>
227
228                                 <div dojoType="dijit.layout.TabContainer">
229                                         <div id="editor_pane" dojoType="dijit.layout.ContentPane" title="&conify.grp_tree.group_config.label;">
230                                                 <script type="dojo/method">
231                                                         highlighter.group_tree = {};
232                                                         highlighter.editor_pane = {};
233                                                         highlighter.group_tree.green = dojox.fx.highlight( { color : '#B4FFB4', node : 'group_tree', duration : 500 } );
234                                                         highlighter.group_tree.red = dojox.fx.highlight( { color : '#FF2018', node : 'group_tree', duration : 500 } );
235                                                         highlighter.editor_pane.green = dojox.fx.highlight( { color : '#B4FFB4', node : 'editor_pane', duration : 500 } );
236                                                         highlighter.editor_pane.red = dojox.fx.highlight( { color : '#FF2018', node : 'editor_pane', duration : 500 } );
237                                                 </script>
238         
239                                                 <table class="tundra" style="margin:10px;">
240                                                         <tr>
241                                                                 <th>&conify.grp_tree.group_name.label;</th>
242                                                                 <td>
243                                                                         <span id="editor_pane_name" dojoType="dijit.form.ValidationTextBox" jsId="editor_pane_name" regExp=".+" required="true">
244                                                                                 <script type="dojo/connect" event="onChange">
245                                                                                         if (current_group) {
246                                                                                                 group_store.setValue( current_group, "name", this.getValue() );
247                                                                                         }
248                                                                                 </script>
249                                                                         </span>
250                                                                         <span dojoType="openils.widget.TranslatorPopup" targetObject="current_fm_group" field="name"></span>
251                                                                 </td>
252                                                         </tr>
253                                                         <tr>
254                                                                 <th>&conify.grp_tree.description.label;</th>
255                                                                 <td>
256                                                                         <span>
257                                                                                 <textarea
258                                                                                   id="editor_pane_description"
259                                                                                   dojoType="dijit.form.Textarea"
260                                                                                   jsId="editor_pane_description"
261                                                                                   onChange="if (current_group) group_store.setValue( current_group, 'description', this.getValue() );"
262                                                                                 ></textarea>
263                                                                         </span>
264                                                                         <span dojoType="openils.widget.TranslatorPopup" targetObject="current_fm_group" field="description"></span>
265                                                                 </td>
266                                                         </tr>
267                                                         <tr>
268                                                                 <th>&conify.grp_tree.permission_interval.label;</th>
269                                                                 <td>
270                                                                         <span id="editor_pane_perm_interval" dojoType="dijit.form.ValidationTextBox" jsId="editor_pane_perm_interval" regExp="^\d+ (?:y.*|mo.*|d.*)$" required="true">
271                                                                                 <script type="dojo/connect" event="onChange">
272                                                                                         if (current_group) {
273                                                                                                 group_store.setValue( current_group, "perm_interval", this.getValue() );
274                                                                                         }
275                                                                                 </script>
276                                                                         </span>
277                                                                 </td>
278                                                         </tr>
279                                                         <tr>
280                                                                 <th>&conify.grp_tree.editing_permission.label;</th>
281                                                                 <td>
282                                                                         <div
283                                                                           id="editor_pane_application_perm"
284                                                                           dojoType="dijit.form.FilteringSelect"
285                                                                           store="perm_name_store"
286                                                                           searchAttr="code"
287                                                                           jsId="editor_pane_application_perm"
288                                                                         >
289                                                                                 <script type="dojo/connect" event="onChange">
290 <![CDATA[
291                                                                                         if (current_group && this.getValue()) {
292                                                                                                 group_store.setValue( current_group, "application_perm", this.getValue() );
293                                                                                         }
294 ]]>
295                                                                                 </script>
296                                                                         </div>
297                                                                 </td>
298                                                         </tr>
299                                                         <tr>
300                                                                 <th>&conify.grp_tree.hold_priority.label;</th>
301                                                                 <td>
302                                                                         <div
303                                                                           id="editor_pane_hold_priority"
304                                                                           dojoType="dijit.form.NumberSpinner"
305                                                                           jsId="editor_pane_hold_priority"
306                                                                         >
307                                                                                 <script type="dojo/connect" event="onChange">
308 <![CDATA[
309                                                                                         if (current_group && this.getValue()) {
310                                                                                                 group_store.setValue( current_group, "hold_priority", this.getValue() );
311                                                                                         }
312 ]]>
313                                                                                 </script>
314                                                                         </div>
315                                                                 </td>
316                                                         </tr>
317                                                         <tr>
318                                                                 <th>&conify.grp_tree.parent_group.label;</th>
319                                                                 <td>
320                                                                         <div
321                                                                           id="editor_pane_parent"
322                                                                           dojoType="dijit.form.FilteringSelect"
323                                                                           jsId="editor_pane_parent"
324                                                                           store="group_store"
325                                                                           searchAttr="name"
326                                                                           ignoreCase="true"
327                                                                           required="true"
328                                                                         >
329                                                                                 <script type="dojo/connect" event="onChange">
330 <![CDATA[
331                                                                                         if (current_group && this.getValue()) {
332                                                                                                 this.store.setValue( current_group, "parent", this.getValue() );
333                                                                                         }
334 ]]>
335                                                                                 </script>
336                                                                         </div>
337                                                                 </td>
338                                                         </tr>
339                                                         <tr>
340                                                                 <th>&conify.grp_tree.user_group.label;</th>
341                                                                 <td>
342                                                                         <input
343                                                                           id="editor_pane_usergroup"
344                                                                           jsId="editor_pane_usergroup"
345                                                                           type="checkbox"
346                                                                           dojoType="dijit.form.CheckBox"
347                                                                           onChange="if (current_group) group_store.setValue( current_group, 'usergroup', this.checked ? 't' : 'f' );"
348                                                                         />
349                                                                 </td>
350                                                         </tr>
351                                                 </table>
352         
353                                                 <div dojoType="dijit.layout.ContentPane" orientation="horizontal" style="margin-bottom: 20px;">
354         
355                                                         <button jsId="save_group_button" dojoType="dijit.form.Button" label="&conify.grp_tree.save_button.label;" onClick="save_group()">
356                                                                 <script type="dojo/connect" event="startup">
357                                                                         this.disabled = true;
358                                                                 </script>
359                                                         </button>
360         
361                                                         <button jsId="delete_group_button" dojoType="dijit.form.Button" label="&conify.grp_tree.delete_button.label;">
362                                                                 <script type="dojo/connect" event="startup">
363                                                                         this.disabled = true;
364                                                                 </script>
365                                                                 <script type="dojo/connect" event="onClick">
366 <![CDATA[
367         
368                                                                         if (group_store.getValue( current_group, '_trueRoot' ) == 'true') {
369                                                                                 highlighter.editor_pane.red.play();
370                                                                                 status_update( dojo.string.substitute( pgt_strings.STATUS_ERR_DELETING, [group_store.getValue( current_group, 'name' )])  );
371                                                                                 return false;
372                                                                         }
373
374                                                                         if ( current_group.children ) {
375                                                                                 var kids = current_group.children;
376                                                                                 if (!dojo.isArray(kids)) kids = [kids];
377         
378                                                                                 var existing_kids = dojo.filter(
379                                                                                         kids,
380                                                                                         function(kid){ return kid.isdeleted[0] != 1 }
381                                                                                 );
382                                                                                 if ( existing_kids.length > 0) {
383                                                                                         highlighter.editor_pane.red.play();
384                                                                                         status_update( dojo.string.substitute( pgt_strings.STATUS_ERR_DELETING_DEPENDENCY, [group_store.getValue( current_group, 'name' ), existing_kids.length]) );
385                                                                                         return;
386                                                                                 }
387                                                                         }
388         
389                                                                         if ( confirm( dojo.string.substitute( pgt_strings.CONFIRM_DELETE, [current_group.name]) ) ) {
390                                                                                 group_store.setValue( current_group, 'isdeleted', 1 );
391         
392                                                                                 var modified_pgt = new pgt().fromStoreItem( current_group );
393                                                                                 modified_pgt.isdeleted( 1 );
394         
395                                                                                 server.pcrud.eliminate( modified_pgt, {
396                                                                                         onerror : function (r) {
397                                                                                                 highlighter.editor_pane.red.play();
398                                                                                                 status_update( dojo.string.substitute( pgt_strings.CONFIRM_DELETE, [group_store.getValue( current_group, 'name' )]) );
399                                                                                         },
400                                                                                         oncomplete : function (r) {
401                                                                                                 var old_name = group_store.getValue( current_group, 'name' );
402
403                                                                                                 group_store.fetch({
404                                                                                                         query : { id : group_store.getValue( current_group, 'id' ) },
405                                                                                                         queryOptions : { deep : true },
406                                                                                                         onItem : function (item, req) { try { if (this.isItem( item )) this.deleteItem( item ); } catch (e) { /* meh */ } },
407                                                                                                         scope : group_store
408                                                                                                 });
409
410                                                                                                 current_group = null;
411
412                                                                                                 new_kid_button.disabled = true;
413                                                                                                 save_group_button.disabled = true;
414                                                                                                 delete_group_button.disabled = true;
415                 
416                                                                                                 var main_settings_fields = [ 'name', 'perm_interval', 'description' ];
417                                                                                                 for ( var i in main_settings_fields ) {
418                                                                                                         var field = main_settings_fields[i];
419                                                                                                         window["editor_pane_" + field].setValue( '' ); // unset the value
420                                                                                                         window["editor_pane_" + field].setDisplayedValue( '' ); // unset the value
421                                                                                                 }
422
423                                                                                                 window["editor_pane_usergroup"].setChecked( false ); // unset the value
424                 
425                                                                                                 highlighter.editor_pane.green.play();
426                                                                                                 status_update( dojo.string.substitute( pgt_strings.STATUS_DELETED, [old_name]) );
427                                                                                         }
428                                                                                 });
429         
430                                                                         }
431 ]]>     
432                                                                 </script>
433                                                         </button>
434         
435                                                 </div>
436         
437                                                 <button jsId="new_kid_button" dojoType="dijit.form.Button" label="&conify.grp_tree.new_child_button.label;">
438                                                         <script type="dojo/connect" event="startup">
439                                                                 this.disabled = true;
440                                                         </script>
441                                                         <script type="dojo/connect" event="onClick">
442 <![CDATA[
443         
444                                                                 var new_fm_obj = new pgt().fromHash({
445                                                                         isnew                   : 1,
446                                                                         name                    : pgt_strings.LABEL_NEW_GROUP,
447                                                                         usergroup               : 'f',
448                                                                         parent                  : group_store.getValue( current_group, 'id' )
449                                                                 });
450         
451                                                                 var err = false;
452
453                                                                 server.pcrud.create( new_fm_obj, {
454                                                                         onerror : function (r) {
455                                                                                 highlighter.editor_pane.red.play();
456                                                                                 status_update( pgt_strings.ERROR_CALLING_METHOD_PGT );
457                                                                                 err = true;
458                                                                         },
459                                     oncomplete : function (r,list) {
460                                                                         group_store.newItem( list[0].toStoreItem(), { parent : current_group, attribute : 'children' } );
461                                     }
462                                 });
463
464                                                                 if (!err) {
465                                                                         highlighter.editor_pane.green.play();
466                                                                         highlighter.group_tree.green.play();
467                                                                         status_update( dojo.string.substitute( pgt_strings.SUCCESS_NEW_CHILD_GROUP, [group_store.getValue( current_group, 'name' )]) );
468                                                                 }
469 ]]>     
470                                                         </script>
471                                                 </button>
472         
473                                         </div>
474
475                                         <div id="perm_pane" dojoType="dijit.layout.ContentPane" title="&conify.grp_tree.group_permissions.title;">
476                                                 <script type="dojo/connect" event="onShow">
477                                                         perm_map_model.query = { grp : current_group ? group_store.getValue(current_group,'id') : -1 };
478                                                         perm_map_model.refresh();
479                                                         perm_grid.refresh();
480                                                 </script>
481                                                 <div dojoType="dijit.layout.LayoutContainer" orientation="horizontal" style="width:100%; height:100%; min-height: 250px">
482                                                         <div id="grid_container" dojoType="dijit.layout.ContentPane" sizeShare="1" layoutAlign="left">
483                                                                 <div dojoType="dojox.grid.data.DojoData" id="perm_map_model" jsId="perm_map_model" store="perm_map_store"></div>
484         
485                                                                 <div id="perm_grid" dojoType="dojox.Grid" model="perm_map_model" jsId="perm_grid">
486                                                                         <script type="dojo/connect" event="startup">
487 <![CDATA[
488                                                                                 function get_item_part(model_field, item_search_field, item_part, model, store, datum, row) {
489                                                                                         var formatter = true;
490         
491                                                                                         if (!row && row != '0') {
492                                                                                                 row = datum;
493                                                                                                 formatter = false;
494                                                                                         }
495         
496                                                                                         if(!model.getRow(row)) return null;
497                                                                                         var value = null;
498         
499                                                                                         if(!formatter) { //this.editor && (this.editor.alwaysOn || (this.grid.edit.info.rowIndex==row && this.grid.edit.info.cell==this))) {
500                                                                                                 return model.getRow(row)[model_field];
501                                                                                         }
502         
503                                                                                         var q = {};
504                                                                                         q[item_search_field] = model.getRow(row)[model_field];
505         
506                                                                                         store.fetch({
507                                                                                                 query : q,
508                                                                                                 onItem : function (item) { value = store.getValue( item, item_part ) }
509                                                                                         });
510
511                                                                                         return value;
512                                                                                 }
513         
514                                                     window.current_perm_grid_layout = [
515                                                         {   cells : [
516                                                                     [
517                                                                             {   name : pgt_strings.LABEL_CODE,
518                                                                                                                         field: "perm",
519                                                                                                                         formatter : dojo.partial(get_item_part, "perm", "id", "code", perm_map_model, perm_store),
520                                                                                                                         width : "auto"
521                                                                                                                 },
522                                                                                                 {       name : pgt_strings.LABEL_DEPTH,
523                                                                                                                         field : "depth",
524                                                                                                                         formatter : dojo.partial(get_item_part, "depth", "depth", "name", perm_map_model, ou_type_store),
525                                                                                                                         editor : dojox.grid.editors.select,
526                                                                                                                         options : dojo.map( _ou_type_list, function (x) { return x.name() } ),
527                                                                                                                         values : dojo.map( _ou_type_list, function (x) { return x.depth() } )
528                                                                                                                 }, 
529                                                                     {   name : pgt_strings.LABEL_GRANTABLE,
530                                                                                                                         field : "grantable",
531                                                                                                                         editor : dojox.grid.editors.bool,
532                                                                                                                         get : function (row) {
533                                                                                                                                 var gr = get_item_part("id", "id", "grantable", perm_map_model, perm_map_model.store, row, row);
534                                                                                                                                 if (gr == 't' || gr === true) return true;
535                                                                                                                                 return false;
536                                                                                                                         },
537                                                                                                                 }
538                                                                                                 ]
539                                                                                                 ]
540                                                         }
541                                                     ];
542
543                                                                                 perm_grid.setStructure(window.current_perm_grid_layout);
544 ]]>
545                                                                         </script>
546                                                                 </div>
547                                                         </div>
548
549                                                         <div id="new_perm_container" dojoType="dijit.layout.ContentPane" sizeShare="1" layoutAlign="client">
550
551                                                                 <div dojoType="dijit.form.DropDownButton" id="new_popup" jsId="new_popup">
552                                                                         <span>&conify.grp_tree.new_mapping.label;</span>
553                                                                         <div  dojoType="dijit.TooltipDialog"> 
554                                                                                 <table class="tundra">
555                                                                                         <tr>
556                                                                                                 <td>&conify.grp_tree.permission.label;</td>
557                                                                                                 <td>
558                                                                                                         <div
559                                                                                                           dojoType="dijit.form.FilteringSelect"
560                                                                                                           Id="new_perm_select"
561                                                                                                           jsId="new_perm_select"
562                                                                                                           store="perm_store"
563                                                                                                           searchAttr="code"
564                                                                                                           ignoreCase="true"
565                                                                                                           required="true"></div>
566                                                                                                 </td>
567                                                                                         </tr>
568                                                                                         <tr>
569                                                                                                 <td>&conify.grp_tree.depth.label;</td>
570                                                                                                 <td>
571                                                                                                         <div
572                                                                                                           dojoType="dijit.form.FilteringSelect"
573                                                                                                           Id="new_depth_select"
574                                                                                                           jsId="new_depth_select"
575                                                                                                           store="ou_type_store"
576                                                                                                           searchAttr="name"
577                                                                                                           ignoreCase="true"
578                                                                                                           required="true"></div>
579                                                                                                 </td>
580                                                                                         </tr>
581                                                                                         <tr>
582                                                                                                 <td>&conify.grp_tree.grantable.label;</td>
583                                                                                                 <td>
584                                                                                                         <input
585                                                                                                           type="checkbox"
586                                                                                                           dojoType="dijit.form.CheckBox"
587                                                                                                           Id="new_grant_checkbox"
588                                                                                                           jsId="new_grant_checkbox"
589                                                                                                           value="t"></input>
590                                                                                                 </td>
591                                                                                         </tr>
592                                                                                 </table>
593
594                                                                                 <button dojoType="dijit.form.Button" jsId="new_mapping_add" label="&conify.grp_tree.add_mapping_button.label;">
595                                                                     <script type="dojo/connect" event="onClick">
596 <![CDATA[
597                                                                         var new_perm = new_perm_select.getValue();
598                                                                         if (!new_perm) return;
599                 
600                                                                         var new_type_id = new_depth_select.getValue();
601                                                                         if (!new_type_id) return;
602                 
603                                                                                                 var new_type;
604                                                                 window.ou_type_store.fetch({
605                                                                 query : { id : new_type_id },
606                                                                 onItem : function (item, req) { try { new_type = item } catch (e) { /* meh */ } },
607                                                                 });
608                 
609                                                                         var new_depth = ou_type_store.getValue( new_type, 'depth')
610                                                                         var new_grant = new_grant_checkbox.getValue();
611                                                 
612                                                                         var new_fm_obj = new pgpm().fromHash({
613                                                                             isnew       : 1,
614                                                                             perm        : new_perm,
615                                                                             depth       : new_depth,
616                                                                                                         grp                     : group_store.getValue( current_group, 'id' ),
617                                                                                                         grantable       : new_grant ? 't' : 'f'
618                                                                         });
619                                                     
620                                                                         var err = false;
621                                                                         server.pcrud.create(new_fm_obj, {
622                                                                             onerror : function (r) {
623                                                                                 highlighter.group_tree.red.play();
624                                                                                 status_update( pgt_strings.ERROR_CALLING_METHOD_PERM_MAP );
625                                                                                 err = true;
626                                                                             },
627                                                                             oncomplete : function (r, list) {
628                 
629                                                                                 var new_item_hash = list[0].toStoreItem();
630                                                                                 perm_map_store.newItem( new_item_hash );
631                                                                                 status_update( pgt_strings.SUCCESS_NEW_PERM_MAP );
632                                                                                 highlighter.group_tree.green.play();
633                 
634                                                                                         perm_map_model.query = { grp : current_group ? group_store.getValue(current_group,'id') : -1 };
635                                                                                 perm_grid.model.sort(-1);
636                                                                                         perm_map_model.refresh();
637                                                                                         perm_grid.refresh();
638                 
639                                                                             }
640                                                                         });
641
642                                                                                                 new_popup._closeDropDown();
643 ]]>    
644                                                                     </script>
645                 
646                                                                                 </button>
647                                                                         </div>
648                                                                 </div>
649
650                                                                 <button jsId="save_pgpm_button" dojoType="dijit.form.Button" label="&conify.grp_tree.save_changes.label;" onClick="save_them_all()"></button><br/>
651
652                                                 <button jsId="delete_pgpm_button" dojoType="dijit.form.Button" label="&conify.grp_tree.remove_selected.label;">
653                                                         <script type="dojo/connect" event="onClick">
654 <![CDATA[
655                                                         var selected_rows = perm_grid.selection.getSelected();
656                                         
657                                                         var selected_items = [];
658                                                         for (var i in selected_rows) {
659                                                             selected_items.push(
660                                                                 perm_grid.model.getRow( selected_rows[i] ).__dojo_data_item
661                                                             );
662                                                         }
663                         
664                                                         perm_grid.selection.clear();
665                                 
666                                                             for (var i in selected_items) {
667                                                                     window.current_perm_map = selected_items[i];
668                         
669                                                                         perm_map_store.setValue( window.current_perm_map, 'isdeleted', 1 );
670                                                         
671                                                                             var modified_pgpm = new pgpm().fromStoreItem( window.current_perm_map );
672                                                                                 modified_pgpm.isdeleted( 1 );
673                                     
674                                                         server.pcrud.eliminate( modified_pgpm, {
675                                                                     onerror : function (r) {
676                                                                                                         highlighter.editor_pane.red.play();
677                                                                                 status_update( dojo.string.substitute( pgt_strings.ERROR_DELETING_PERM_MAPPING, [perm_map_store.getValue( window.current_perm_map, 'id' )] ) );
678                                                                                 },
679                                                                                     oncomplete : function (r, list) {
680                                                 
681                                                                             perm_map_store.fetch({
682                                                                                     query : { id : perm_map_store.getValue( window.current_perm_map, 'id' ) },
683                                                                                         onItem : function (item, req) { try { if (this.isItem( item )) this.deleteItem( item ); } catch (e) { /* meh */ } },
684                                                                                             scope : perm_map_store
685                                                                                             });
686                             
687                                                                                                 window.current_perm_map = null;
688                                                 
689                                                                                                         highlighter.editor_pane.green.play();
690                                                                                 status_update( pgt_strings.SUCCESS_DELETED_PERM_MAP );
691                                                             }
692                                                         });
693                                         
694                                                         }
695 ]]>
696                                                         </script>
697                                                         </button>
698         
699                                                         </div>
700                                                 </div>
701                                         </div>
702                                 </div>
703                         </div>
704                 </div>
705         </body>
706 </html>