]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/web/conify/global/permission/perm_list.html
LP 2061136 release notes
[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/dijit/dijit.js"></script>
61                 <script language='javascript'>dojo.require('fieldmapper.AutoIDL')</script>
62
63                 <script type="text/javascript" src="perm_list.js"></script>
64
65                 <script type="text/javascript"><![CDATA[
66                         var dirtyStore = [];
67                         var perm_rows = [];
68
69             var _perm_list = pCRUD.retrieveAll('ppl', { order_by : { ppl : 'code' } });
70             var _perm_data = ppl.toStoreData( _perm_list, 'code' );
71             var perm_store = new dojo.data.ItemFileWriteStore({ data : _perm_data });
72
73
74             perm_store.onSet = function (item, attr, o, n) {
75                 if (attr == 'ischanged') return;
76                 if (n == o) return;
77                 this.setValue( item, 'ischanged', 1);
78             };
79
80
81                         var perm_grid_layout = [
82                                 {       cells : [
83                                                 [
84                                                         { name : ppl_strings.LABEL_CODE,        field : "code",        width : "300px", editor : dojox.grid.editors.Dijit, rowSpan : "2" },
85                                                         { name : ppl_strings.LABEL_DESCRIPTION, field : "description", width : "auto",  editor : dojox.grid.editors.Editor, style : "minHeight:1em;" }
86                                                 ],
87                                                 [
88                                                         { name : ppl_strings.LABEL_TRANSLATION,
89                                                           width : "10em",
90                                                           height : "2em",
91                                                           formatter : function (value) {
92                                 return '<span class="perm_grid_trans_desc_'+value+'"></span>';
93                               },
94                                                           get : function (row) {
95                                                                 var r = perm_data_model.getRow(row);
96                                                                 if (r) {
97                                                                         perm_rows[row] = new ccs().fromHash(perm_data_model.getRow(row));
98                                                                         setTimeout(
99                                                                                 'dojo.query(".perm_grid_trans_desc_' + row + '").'+
100                                                                                         'instantiate(openils.widget.TranslatorPopup,{field:"description",'+
101                                                                                         'targetObject:"window.perm_rows['+row+']"});'+
102                                                                                         'perm_grid.rowHeightChanged('+row+')',
103                                                                                 0
104                                                                         );
105                                                                         var oldnode = dojo.byId('description_translation_' + row);
106                                                                         if (oldnode) dijit.byNode(oldnode).destroyRecursive();
107                                                                         return row;
108                                                                 }
109                                                                 return '';
110                                                           }
111                                                         }
112                                                 ]
113                                         ]
114                                 }
115                         ];
116
117             dojo.addOnUnload( function (event) {
118
119                 perm_store.fetch({
120                     query : { ischanged : 1 },
121                     onItem : function (item, req) { try { if (this.isItem( item )) dirtyStore.push( item ); } catch (e) { /* meh */ } },
122                     scope : perm_store
123                 });
124
125                 if (dirtyStore.length > 0) {
126                     var confirmation = confirm(ppl_strings.CONFIRM_EXIT_PPL);
127
128                     if (confirmation) {
129                         for (var i in dirtyStore) {
130                             current_perm = dirtyStore[i];
131                             save_perm(true);
132                         }
133                     }
134                 }
135
136             });
137 ]]>
138                 </script>
139
140
141         </head>
142
143         <body class="tundra" id='pagebody'>
144
145                 <div dojoType="dijit.layout.LayoutContainer" id="grid_container" jsId="grid_container" orientation="vertical">
146                         <div dojoType="dijit.layout.LayoutContainer" orientation="horizontal" style="margin-top: 5px;" layoutAlign="top">
147                                 <span>&conify.perm_list.new_permission.label;</span>
148                                 <div dojoType="dijit.form.TextBox" id="new_perm_code" jsId="new_perm_code" label="&conify.perm_list.new_code.label;"></div>
149                                 <button dojoType="dijit.form.Button" id="save_new_perm_code" jsId="save_new_perm_code" label="&conify.perm_list.add_button.label;"> 
150                                         <script type="dojo/connect" event="onClick">
151 <![CDATA[
152                                                 var new_code = new_perm_code.getValue();
153                                                 if (!new_code) return;
154
155                         var new_fm_obj = new ppl().fromHash({
156                                 isnew           : 1,
157                             code            : new_code
158                             });
159     
160                         var err = false;
161                             pCRUD.create(new_fm_obj, {
162                                 onerror : function (r) {
163                                 highlighter.red.play();
164                                     status_update( ppl_strings.ERROR_CALLING_METHOD_PPL );
165                                 err = true;
166                                 },
167                                 oncomplete : function (r, list) {
168                                     var new_item_hash = list[0].toHash();
169                                     perm_store.newItem( new_item_hash );
170                                                                 status_update( dojo.string.substitute(ppl_strings.SUCCESS_CREATING_PERMISSION, [new_item_hash.code]) );
171                                                                 perm_grid.model.sort(-1);
172                                                                 highlighter.green.play();
173                                 }
174                         });
175 ]]> 
176                         </script>
177                                 </button>
178                         </div>
179
180                         <div dojoType="dijit.layout.ContentPane" style="width:100%; height:100%;" layoutAlign="client">
181                 <div dojoType="dojox.grid.data.DojoData" id="perm_data_model" jsId="perm_data_model" store="perm_store" query="{ code : '*' }">
182                 </div>
183                                 <div id="perm_grid" dojoType="dojox.Grid" model="perm_data_model" structure="perm_grid_layout" jsId="perm_grid">
184                                 </div>
185                         </div>
186
187                         <div dojoType="dijit.layout.ContentPane" orientation="horizontal" style="margin-bottom: 5px;" layoutAlign="bottom">
188                 
189                                 <button jsId="save_ppl_button" dojoType="dijit.form.Button" label="&conify.perm_list.save_changes.label;" onClick="save_them_all()"></button>
190                 
191                                 <button jsId="delete_ppl_button" dojoType="dijit.form.Button" label="&conify.perm_list.delete_selected.label;">
192                                         <script type="dojo/connect" event="onClick">
193 <![CDATA[
194                                                 var selected_rows = perm_grid.selection.getSelected();
195                 
196                                                 var selected_items = [];
197                                                 for (var i in selected_rows) {
198                                                         selected_items.push(
199                                                                 perm_grid.model.getRow( selected_rows[i] ).__dojo_data_item
200                                                         );
201                                                 }
202
203                                                 perm_grid.selection.clear();
204
205                                                 for (var i in selected_items) {
206                                                         current_perm = selected_items[i];
207
208                                                         if ( confirm( dojo.string.substitute(ppl_strings.CONFIRM_DELETE, [perm_store.getValue(current_perm, 'code')]) ) ) {
209
210                                                                 perm_store.setValue( current_perm, 'isdeleted', 1 );
211                         
212                                                                 var modified_ppl = new ppl().fromStoreItem( current_perm );
213                                                                 modified_ppl.isdeleted( 1 );
214                         
215                                                                 pCRUD.eliminate(modified_ppl, {
216                                                                         onerror : function (r) {
217                                                                                 highlighter.red.play();
218                                                                                 status_update( dojo.string.substitute(ppl_strings.ERROR_DELETING, [perm_store.getValue( current_perm, 'code' )]) );
219                                                                         },
220                                                                         oncomplete : function (r) {
221                                                                                 var old_name = perm_store.getValue( current_perm, 'code' );
222
223                                                                                 perm_store.fetch({
224                                                                                         query : { id : perm_store.getValue( current_perm, 'id' ) },
225                                                                                         onItem : function (item, req) { try { if (this.isItem( item )) this.deleteItem( item ); } catch (e) { /* meh */ } },
226                                                                                         scope : perm_store
227                                                                                 });
228
229                                                                                 current_perm = null;
230
231                                                                                 highlighter.green.play();
232                                                                                 status_update( dojo.string.substitute(ppl_strings.STATUS_DELETED, [old_name]) );
233                                                                         }
234                                                                 });
235                 
236                                                         }
237                                                 }
238 ]]>
239                                         </script>
240                                 </button>
241         
242                         </div>
243                 </div>
244         
245         <script type="text/javascript">
246             var highlighter= {};
247                 highlighter.green = dojox.fx.highlight( { color : '#B4FFB4', node : 'grid_container', duration : 500 } );
248                 highlighter.red = dojox.fx.highlight( { color : '#FF2018', node : 'grid_container', duration : 500 } );
249         </script>
250
251         </body>
252 </html>