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