2 # ---------------------------------------------------------------------------
3 # Copyright (C) 2008 Georgia Public Library Service / Equinox Software, Inc
4 # Mike Rylander <miker@esilibrary.com>
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 # ---------------------------------------------------------------------------
18 dojo.require('fieldmapper.dojoData');
19 dojo.require('dojo.parser');
20 dojo.require('dojo.data.ItemFileWriteStore');
21 dojo.require('dojo.date.stamp');
22 dojo.require('dijit.form.NumberSpinner');
23 dojo.require('dijit.form.TextBox');
24 dojo.require('dijit.form.TimeTextBox');
25 dojo.require('dijit.form.ValidationTextBox');
26 dojo.require('dijit.form.CheckBox');
27 dojo.require('dijit.form.FilteringSelect');
28 dojo.require('dijit.form.Textarea');
29 dojo.require('dijit.form.Button');
30 dojo.require('dijit.Dialog');
31 dojo.require('dijit.Tree');
32 dojo.require('dijit.layout.ContentPane');
33 dojo.require('dijit.layout.TabContainer');
34 dojo.require('dijit.layout.LayoutContainer');
35 dojo.require('dijit.layout.SplitContainer');
36 dojo.require('dojox.widget.Toaster');
37 dojo.require('dojox.fx');
38 dojo.require('dojox.grid.Grid');
39 dojo.require('dojox.grid._data.model');
40 dojo.require("dojox.grid.editors");
44 var cookieManager = new HTTP.Cookies();
45 var ses = cookieManager.read('ses') || cgi.param('ses');
47 server.pCRUD = new OpenSRF.ClientSession('open-ils.permacrud');
48 server.actor = new OpenSRF.ClientSession('open-ils.actor');
51 var virgin_out_id = -1;
55 function status_update (markup) {
56 if (parent !== window && parent.status_update) parent.status_update( markup );
59 function save_group () {
61 var modified_pgt = new pgt().fromStoreItem( current_group );
62 modified_pgt.ischanged( 1 );
64 new_kid_button.disabled = false;
65 save_out_button.disabled = false;
66 delete_out_button.disabled = false;
68 server.pCRUD.request({
69 method : 'open-ils.permacrud.update.pgt',
71 params : [ ses, modified_pgt ],
72 onerror : function (r) {
73 highlighter.editor_pane.red.play();
74 status_update( 'Problem saving data for ' + group_store.getValue( current_group, 'name' ) );
76 oncomplete : function (r) {
78 if ( res && res.content() ) {
79 group_store.setValue( current_group, 'ischanged', 0 );
80 highlighter.editor_pane.green.play();
81 status_update( 'Saved changes to ' + group_store.getValue( current_group, 'name' ) );
83 highlighter.editor_pane.red.play();
84 status_update( 'Problem saving data for ' + group_store.getValue( current_group, 'name' ) );
90 function save_perm_map (storeItem) {
92 var modified_pgpm = new pgpm().fromStoreItem( storeItem );
93 modified_pgpm.ischanged( 1 );
95 server.pCRUD.request({
96 method : 'open-ils.permacrud.update.pgpm',
98 params : [ ses, modified_pgpm ],
99 onerror : function (r) {
100 highlighter.editor_pane.red.play();
101 status_update( 'Problem saving permission data for ' + group_store.getValue( current_group, 'name' ) );
103 oncomplete : function (r) {
105 if ( res && res.content() ) {
106 perm_map_store.setValue( storeItem, 'ischanged', 0 );
107 highlighter.editor_pane.green.play();
108 status_update( 'Saved permission changes to ' + group_store.getValue( current_group, 'name' ) );
110 highlighter.editor_pane.red.play();
111 status_update( 'Problem saving permission data for ' + group_store.getValue( current_group, 'name' ) );
117 function save_them_all (event) {
121 perm_map_store.fetch({
122 query : { ischanged : 1 },
123 onItem : function (item, req) { try { if (this.isItem( item )) dirtyMaps.push( item ); } catch (e) { /* meh */ } },
124 scope : perm_map_store
127 var confirmation = true;
130 if (event && dirtyMaps.length > 0) {
131 confirmation = confirm(
132 'There are unsaved modified Permission Maps! '+
133 'OK to save these changes, Cancel to abandon them.'
138 for (var i in dirtyMaps) {
139 save_perm_map(dirtyMaps[i]);
144 dojo.addOnUnload( save_them_all );