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.
15 <html xmlns="http://www.w3.org/1999/xhtml">
17 <title>Confiy :: Global :: Permission :: Permission List</title>
19 <style type="text/css">
20 @import url("/js/dojo/dojox/grid/_grid/tundraGrid.css");
21 @import url("/js/dojo/dojo/resources/dojo.css");
22 @import url("/js/dojo/dijit/themes/tundra/tundra.css");
23 @import url("/js/dojo/dojox/widget/Toaster/Toaster.css");
30 margin: 0px 0px 0px 0px;
31 padding: 0px 0px 0px 0px;
47 <!-- The OpenSRF API writ JS -->
48 <script language='javascript' src='/opac/common/js/utils.js' type='text/javascript'></script>
49 <script language='javascript' src='/opac/common/js/Cookies.js' type='text/javascript'></script>
50 <script language='javascript' src='/opac/common/js/CGI.js' type='text/javascript'></script>
51 <script language='javascript' src='/opac/common/js/JSON_v1.js' type='text/javascript'></script>
53 <!-- Fieldmapper objects -->
54 <script language='javascript' src='/opac/common/js/fmall.js' type='text/javascript'></script>
56 <!-- Dojo goodness -->
57 <script type="text/javascript" src="/js/dojo/dojo/dojo.js" djConfig="parseOnLoad: true"></script>
58 <script type="text/javascript" src="/js/dojo/dijit/dijit.js"></script>
60 <script type="text/javascript" src="perm_list.js"></script>
64 <body class="tundra" id='pagebody'>
66 <div dojoType="dijit.layout.LayoutContainer" id="grid_container" jsId="grid_container" orientation="vertical">
67 <script type="dojo/method">
68 window.highlighter= {};
69 window.highlighter.green = dojox.fx.highlight( { color : '#B4FFB4', node : 'grid_container', duration : 500 } );
70 window.highlighter.red = dojox.fx.highlight( { color : '#FF2018', node : 'grid_container', duration : 500 } );
72 window.dirtyStore = [];
75 method : 'open-ils.permacrud.search.ppl.atomic',
77 params : [ ses, { id : { "!=" : null } }, { order_by : { ppl : 'code' } } ],
78 onerror : function (r) { status_update('Problem fetching perms') },
79 oncomplete : function (r) {
81 window._perm_list = r.recv().content();
82 window._perm_data = ppl.toStoreData( window._perm_list, 'code' );
83 window.perm_store = new dojo.data.ItemFileWriteStore({ data : window._perm_data });
85 perm_store.onSet = function (item, attr, o, n) {
86 if (attr == 'ischanged') return;
88 this.setValue( item, 'ischanged', 1);
91 window.perm_grid_layout = [
94 { name : "Code", field : "code", width : "300px", editor : dojox.grid.editors.Dijit },
95 { name : "Description", field : "description", width : "auto", editor : dojox.grid.editors.Editor }
101 dojo.addOnUnload( function (event) {
104 query : { ischanged : 1 },
105 onItem : function (item, req) { try { if (this.isItem( item )) window.dirtyStore.push( item ); } catch (e) { /* meh */ } },
109 if (dirtyStore.length > 0) {
110 var confirmation = confirm(
111 'There are unsaved modified Permissions! '+
112 'OK to save these changes, Cancel to abandon them.'
116 for (var i in window.dirtyStore) {
117 window.current_perm = window.dirtyStore[i];
129 <div dojoType="dijit.layout.LayoutContainer" orientation="horizontal" style="margin-top: 5px;" layoutAlign="top">
130 <span>New Permission:</span>
131 <div dojoType="dijit.form.TextBox" id="new_perm_code" jsId="new_perm_code" label="New Code"></div>
132 <button dojoType="dijit.form.Button" id="save_new_perm_code" jsId="save_new_perm_code" label="Add">
133 <script type="dojo/connect" event="onClick">
135 var new_code = new_perm_code.getValue();
136 if (!new_code) return;
138 var new_fm_obj = new ppl().fromHash({
145 method : 'open-ils.permacrud.create.ppl',
147 params : [ ses, new_fm_obj ],
148 onerror : function (r) {
149 highlighter.red.play();
150 status_update( 'Problem calling method to create new Permission' );
153 oncomplete : function (r) {
155 if ( res && res.content() ) {
156 var new_item_hash = res.content().toHash();
157 perm_store.newItem( new_item_hash );
158 status_update( 'New ' + new_item_hash.code + ' permission created' );
159 perm_grid.model.sort(-1);
160 highlighter.green.play();
162 highlighter.red.play();
163 status_update( 'Problem creating new Permission' );
173 <div dojoType="dijit.layout.ContentPane" style="width:100%; height:100%;" layoutAlign="client">
174 <div dojoType="dojox.grid.data.DojoData" id="perm_data_model"jsId="perm_data_model" store="perm_store" query="{ code : '*' }"></div>
175 <div id="perm_grid" dojoType="dojox.Grid" model="perm_data_model" structure="perm_grid_layout" jsId="perm_grid">
177 <script type="dojo/connect" event="onSet" args="item,attr,oldVal,newVal">
183 <div dojoType="dijit.layout.ContentPane" orientation="horizontal" style="margin-bottom: 5px;" layoutAlign="bottom">
185 <button jsId="save_ppl_button" dojoType="dijit.form.Button" label="Save Changes" onClick="save_them_all()"></button>
187 <button jsId="delete_ppl_button" dojoType="dijit.form.Button" label="Delete Selected">
188 <script type="dojo/connect" event="onClick">
190 var selected_rows = perm_grid.selection.getSelected();
192 var selected_items = [];
193 for (var i in selected_rows) {
195 perm_grid.model.getRow( selected_rows[i] ).__dojo_data_item
199 perm_grid.selection.clear();
201 for (var i in selected_items) {
202 current_perm = selected_items[i];
204 if ( confirm('Are you sure you want to delete ' + perm_store.getValue( current_perm, 'code' ) + '?')) {
206 perm_store.setValue( current_perm, 'isdeleted', 1 );
208 var modified_ppl = new ppl().fromStoreItem( current_perm );
209 modified_ppl.isdeleted( 1 );
212 method : 'open-ils.permacrud.delete.ppl',
214 params : [ ses, modified_ppl ],
215 onerror : function (r) {
216 highlighter.red.play();
217 status_update( 'Problem deleting ' + perm_store.getValue( current_perm, 'code' ) );
219 oncomplete : function (r) {
221 if ( res && res.content() ) {
223 var old_name = perm_store.getValue( current_perm, 'code' );
226 query : { id : perm_store.getValue( current_perm, 'id' ) },
227 onItem : function (item, req) { try { if (this.isItem( item )) this.deleteItem( item ); } catch (e) { /* meh */ } },
233 highlighter.green.play();
234 status_update( old_name + ' deleted' );
236 highlighter.red.play();
237 status_update( 'Problem deleting ' + old_name );