]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/web/conify/global/permission/perm_list.html
680cf6104fefec906618899b887222e04938d6a3
[Evergreen.git] / Open-ILS / web / conify / global / permission / perm_list.html
1 <!--
2 # Copyright (C) 2008  Georgia Public Library Service / Equinox Software, Inc
3 # Mike Rylander <miker@esilibrary.com>
4
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
9
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 -->
15 <!DOCTYPE html PUBLIC 
16         "-//W3C//DTD XHTML 1.0 Transitional//EN" 
17         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" [
18         <!--#include virtual="/opac/locale/${locale}/conify.dtd"-->
19 ]>
20 <html xmlns="http://www.w3.org/1999/xhtml">
21         <head>
22                 <title>&conify.perm_list.permission_list.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                                 height: 100%;
34                                 width: 100%;
35                                 margin: 0px 0px 0px 0px;
36                                 padding: 0px 0px 0px 0px;
37                                 overflow: hidden;
38                         }
39
40                         #perm_grid {
41                                 border: 0px;
42                                 width: 100%;
43                                 height: 100%;
44                         }
45
46                         #grid_container {
47                                 width: 100%;
48                                 height: 100%;
49                         }
50                 </style>
51
52                 <!-- The OpenSRF API writ JS -->
53                 <script language='javascript' src='/IDL2js?au,aou,aout,pgt,ppl,ccs' type='text/javascript'></script>
54                 <script language='javascript' src='/opac/common/js/utils.js' type='text/javascript'></script>
55                 <script language='javascript' src='/opac/common/js/CGI.js' type='text/javascript'></script>
56                 <script language='javascript' src='/opac/common/js/JSON_v1.js' type='text/javascript'></script>
57
58                 <!-- Dojo goodness -->
59                 <script type="text/javascript" src="/js/dojo/dojo/dojo.js" djConfig="parseOnLoad: true"></script>
60                 <script type="text/javascript" src="/js/dojo/dojo/openils_dojo.js" djConfig="parseOnLoad: true"></script>
61                 <script type="text/javascript" src="/js/dojo/dijit/dijit.js"></script>
62                 <script language='javascript'>dojo.require('fieldmapper.AutoIDL')</script>
63
64                 <script type="text/javascript" src="perm_list.js"></script>
65
66                 <script type="text/javascript"><![CDATA[
67                         var dirtyStore = [];
68                         var perm_rows = [];
69
70             var _perm_list = pCRUD.retrieveAll('ppl', { order_by : { ppl : 'code' } });
71             var _perm_data = ppl.toStoreData( _perm_list, 'code' );
72             var perm_store = new dojo.data.ItemFileWriteStore({ data : _perm_data });
73
74
75             perm_store.onSet = function (item, attr, o, n) {
76                 if (attr == 'ischanged') return;
77                 if (n == o) return;
78                 this.setValue( item, 'ischanged', 1);
79             };
80
81
82                         var perm_grid_layout = [
83                                 {       cells : [
84                                                 [
85                                                         { name : ppl_strings.LABEL_CODE,        field : "code",        width : "300px", editor : dojox.grid.editors.Dijit, rowSpan : "2" },
86                                                         { name : ppl_strings.LABEL_DESCRIPTION, field : "description", width : "auto",  editor : dojox.grid.editors.Editor, style : "minHeight:1em;" }
87                                                 ],
88                                                 [
89                                                         { name : ppl_strings.LABEL_TRANSLATION,
90                                                           width : "10em",
91                                                           height : "2em",
92                                                           formatter : function (value) {
93                                 return '<span class="perm_grid_trans_desc_'+value+'"></span>';
94                               },
95                                                           get : function (row) {
96                                                                 var r = perm_data_model.getRow(row);
97                                                                 if (r) {
98                                                                         perm_rows[row] = new ccs().fromHash(perm_data_model.getRow(row));
99                                                                         setTimeout(
100                                                                                 'dojo.query(".perm_grid_trans_desc_' + row + '").'+
101                                                                                         'instantiate(openils.widget.TranslatorPopup,{field:"description",'+
102                                                                                         'targetObject:"window.perm_rows['+row+']"});'+
103                                                                                         'perm_grid.rowHeightChanged('+row+')',
104                                                                                 0
105                                                                         );
106                                                                         var oldnode = dojo.byId('description_translation_' + row);
107                                                                         if (oldnode) dijit.byNode(oldnode).destroyRecursive();
108                                                                         return row;
109                                                                 }
110                                                                 return '';
111                                                           }
112                                                         }
113                                                 ]
114                                         ]
115                                 }
116                         ];
117
118             dojo.addOnUnload( function (event) {
119
120                 perm_store.fetch({
121                     query : { ischanged : 1 },
122                     onItem : function (item, req) { try { if (this.isItem( item )) dirtyStore.push( item ); } catch (e) { /* meh */ } },
123                     scope : perm_store
124                 });
125
126                 if (dirtyStore.length > 0) {
127                     var confirmation = confirm(ppl_strings.CONFIRM_EXIT_PPL);
128
129                     if (confirmation) {
130                         for (var i in dirtyStore) {
131                             current_perm = dirtyStore[i];
132                             save_perm(true);
133                         }
134                     }
135                 }
136
137             });
138 ]]>
139                 </script>
140
141
142         </head>
143
144         <body class="tundra" id='pagebody'>
145
146                 <div dojoType="dijit.layout.LayoutContainer" id="grid_container" jsId="grid_container" orientation="vertical">
147                         <div dojoType="dijit.layout.LayoutContainer" orientation="horizontal" style="margin-top: 5px;" layoutAlign="top">
148                                 <span>&conify.perm_list.new_permission.label;</span>
149                                 <div dojoType="dijit.form.TextBox" id="new_perm_code" jsId="new_perm_code" label="&conify.perm_list.new_code.label;"></div>
150                                 <button dojoType="dijit.form.Button" id="save_new_perm_code" jsId="save_new_perm_code" label="&conify.perm_list.add_button.label;"> 
151                                         <script type="dojo/connect" event="onClick">
152 <![CDATA[
153                                                 var new_code = new_perm_code.getValue();
154                                                 if (!new_code) return;
155
156                         var new_fm_obj = new ppl().fromHash({
157                                 isnew           : 1,
158                             code            : new_code
159                             });
160     
161                         var err = false;
162                             pCRUD.create(new_fm_obj, {
163                                 onerror : function (r) {
164                                 highlighter.red.play();
165                                     status_update( ppl_strings.ERROR_CALLING_METHOD_PPL );
166                                 err = true;
167                                 },
168                                 oncomplete : function (r, list) {
169                                     var new_item_hash = list[0].toHash();
170                                     perm_store.newItem( new_item_hash );
171                                                                 status_update( dojo.string.substitute(ppl_strings.SUCCESS_CREATING_PERMISSION, [new_item_hash.code]) );
172                                                                 perm_grid.model.sort(-1);
173                                                                 highlighter.green.play();
174                                 }
175                         });
176 ]]> 
177                         </script>
178                                 </button>
179                         </div>
180
181                         <div dojoType="dijit.layout.ContentPane" style="width:100%; height:100%;" layoutAlign="client">
182                 <div dojoType="dojox.grid.data.DojoData" id="perm_data_model" jsId="perm_data_model" store="perm_store" query="{ code : '*' }">
183                 </div>
184                                 <div id="perm_grid" dojoType="dojox.Grid" model="perm_data_model" structure="perm_grid_layout" jsId="perm_grid">
185                                 </div>
186                         </div>
187
188                         <div dojoType="dijit.layout.ContentPane" orientation="horizontal" style="margin-bottom: 5px;" layoutAlign="bottom">
189                 
190                                 <button jsId="save_ppl_button" dojoType="dijit.form.Button" label="&conify.perm_list.save_changes.label;" onClick="save_them_all()"></button>
191                 
192                                 <button jsId="delete_ppl_button" dojoType="dijit.form.Button" label="&conify.perm_list.delete_selected.label;">
193                                         <script type="dojo/connect" event="onClick">
194 <![CDATA[
195                                                 var selected_rows = perm_grid.selection.getSelected();
196                 
197                                                 var selected_items = [];
198                                                 for (var i in selected_rows) {
199                                                         selected_items.push(
200                                                                 perm_grid.model.getRow( selected_rows[i] ).__dojo_data_item
201                                                         );
202                                                 }
203
204                                                 perm_grid.selection.clear();
205
206                                                 for (var i in selected_items) {
207                                                         current_perm = selected_items[i];
208
209                                                         if ( confirm( dojo.string.substitute(ppl_strings.CONFIRM_DELETE, [perm_store.getValue(current_perm, 'code')]) ) ) {
210
211                                                                 perm_store.setValue( current_perm, 'isdeleted', 1 );
212                         
213                                                                 var modified_ppl = new ppl().fromStoreItem( current_perm );
214                                                                 modified_ppl.isdeleted( 1 );
215                         
216                                                                 pCRUD.eliminate(modified_ppl, {
217                                                                         onerror : function (r) {
218                                                                                 highlighter.red.play();
219                                                                                 status_update( dojo.string.substitute(ppl_strings.ERROR_DELETING, [perm_store.getValue( current_perm, 'code' )]) );
220                                                                         },
221                                                                         oncomplete : function (r) {
222                                                                                 var old_name = perm_store.getValue( current_perm, 'code' );
223
224                                                                                 perm_store.fetch({
225                                                                                         query : { id : perm_store.getValue( current_perm, 'id' ) },
226                                                                                         onItem : function (item, req) { try { if (this.isItem( item )) this.deleteItem( item ); } catch (e) { /* meh */ } },
227                                                                                         scope : perm_store
228                                                                                 });
229
230                                                                                 current_perm = null;
231
232                                                                                 highlighter.green.play();
233                                                                                 status_update( dojo.string.substitute(ppl_strings.STATUS_DELETED, [old_name]) );
234                                                                         }
235                                                                 });
236                 
237                                                         }
238                                                 }
239 ]]>
240                                         </script>
241                                 </button>
242         
243                         </div>
244                 </div>
245         
246         <script type="text/javascript">
247             var highlighter= {};
248                 highlighter.green = dojox.fx.highlight( { color : '#B4FFB4', node : 'grid_container', duration : 500 } );
249                 highlighter.red = dojox.fx.highlight( { color : '#FF2018', node : 'grid_container', duration : 500 } );
250         </script>
251
252         </body>
253 </html>