2 # Copyright (C) 2008 Georgia Public Library Service / Equinox Software, Inc
3 # Mike Rylander <miker@esilibrary.com>
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.
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.
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"-->
20 <html xmlns="http://www.w3.org/1999/xhtml">
22 <title>&conify.perm_list.permission_list.title;</title>
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');
35 margin: 0px 0px 0px 0px;
36 padding: 0px 0px 0px 0px;
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>
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>
62 <script type="text/javascript" src="perm_list.js"></script>
66 <body class="tundra" id='pagebody'>
68 <div dojoType="dijit.layout.LayoutContainer" id="grid_container" jsId="grid_container" orientation="vertical">
69 <script type="dojo/method">
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 } );
75 window.dirtyStore = [];
78 method : 'open-ils.permacrud.search.ppl.atomic',
80 params : [ ses, { id : { "!=" : null } }, { order_by : { ppl : 'code' } } ],
81 onerror : function (r) { status_update(pgt_strings.ERROR_FETCHING_PERMS) },
82 oncomplete : function (r) {
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 });
88 perm_store.onSet = function (item, attr, o, n) {
89 if (attr == 'ischanged') return;
91 this.setValue( item, 'ischanged', 1);
94 window.perm_grid_layout = [
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;" }
101 { name : "Translation",
104 get : function (row) {
105 if (!window.perm_rows) window.perm_rows = [];
106 var r = window.perm_data_model.getRow(row);
108 window.perm_rows[row] = new ccs().fromHash(window.perm_data_model.getRow(row));
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+')',
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>';
128 dojo.addOnUnload( function (event) {
131 query : { ischanged : 1 },
132 onItem : function (item, req) { try { if (this.isItem( item )) window.dirtyStore.push( item ); } catch (e) { /* meh */ } },
136 if (dirtyStore.length > 0) {
137 var confirmation = confirm(pgt_strings.CONFIRM_EXIT);
140 for (var i in window.dirtyStore) {
141 window.current_perm = window.dirtyStore[i];
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">
159 var new_code = new_perm_code.getValue();
160 if (!new_code) return;
162 var new_fm_obj = new ppl().fromHash({
169 method : 'open-ils.permacrud.create.ppl',
171 params : [ ses, new_fm_obj ],
172 onerror : function (r) {
173 highlighter.red.play();
174 status_update( pgt_strings.ERROR_CALLING_METHOD );
177 oncomplete : function (r) {
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();
186 highlighter.red.play();
187 status_update( pgt_strings.ERROR_CREATING_PERMISSION );
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">
201 <script type="dojo/connect" event="onSet" args="item,attr,oldVal,newVal">
207 <div dojoType="dijit.layout.ContentPane" orientation="horizontal" style="margin-bottom: 5px;" layoutAlign="bottom">
209 <button jsId="save_ppl_button" dojoType="dijit.form.Button" label="&conify.perm_list.save_changes.label;" onClick="save_them_all()"></button>
211 <button jsId="delete_ppl_button" dojoType="dijit.form.Button" label="&conify.perm_list.delete_selected.label;">
212 <script type="dojo/connect" event="onClick">
214 var selected_rows = perm_grid.selection.getSelected();
216 var selected_items = [];
217 for (var i in selected_rows) {
219 perm_grid.model.getRow( selected_rows[i] ).__dojo_data_item
223 perm_grid.selection.clear();
225 for (var i in selected_items) {
226 current_perm = selected_items[i];
228 if ( confirm( dojo.string.substitute(pgt_strings.CONFIRM_DELETE, [perm_store.getValue(current_perm, 'code')]) ) ) {
230 perm_store.setValue( current_perm, 'isdeleted', 1 );
232 var modified_ppl = new ppl().fromStoreItem( current_perm );
233 modified_ppl.isdeleted( 1 );
236 method : 'open-ils.permacrud.delete.ppl',
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' )]) );
243 oncomplete : function (r) {
245 if ( res && res.content() ) {
247 var old_name = perm_store.getValue( current_perm, 'code' );
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 */ } },
257 highlighter.green.play();
258 status_update( dojo.string.substitute(pgt_strings.STATUS_DELETED, [old_name]) );
260 highlighter.red.play();
261 status_update( dojo.string.substitute(pgt_strings.ERROR_DELETING, [old_name]) );