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.string');
21 dojo.require('dojo.data.ItemFileWriteStore');
22 dojo.require('dijit.form.TextBox');
23 dojo.require('dijit.form.ValidationTextBox');
24 dojo.require('dijit.form.Textarea');
25 dojo.require('dijit.layout.ContentPane');
26 dojo.require('dijit.layout.LayoutContainer');
27 dojo.require('dijit.layout.BorderContainer');
28 dojo.require('dojox.widget.Toaster');
29 dojo.require('dojox.fx');
30 dojo.require('dojox.grid.Grid');
31 dojo.require('dojox.grid._data.model');
32 dojo.require("dojox.grid.editors");
36 var cookieManager = new HTTP.Cookies();
37 var ses = cookieManager.read('ses') || cgi.param('ses');
38 var pCRUD = new OpenSRF.ClientSession('open-ils.permacrud');
41 var virgin_out_id = -1;
45 function status_update (markup) {
46 if (parent !== window && parent.status_update) parent.status_update( markup );
49 function save_status () {
51 var modified_ccs = new ccs().fromStoreItem( current_status );
52 modified_ccs.ischanged( 1 );
55 method : 'open-ils.permacrud.update.ccs',
57 params : [ ses, modified_ccs ],
58 onerror : function (r) {
59 highlighter.red.play();
60 status_update( 'Problem saving ' + status_store.getValue( current_status, 'name' ) );
62 oncomplete : function (r) {
64 if ( res && res.content() ) {
65 status_store.setValue( current_status, 'ischanged', 0 );
66 highlighter.green.play();
67 status_update( 'Saved changes to ' + status_store.getValue( current_status, 'name' ) );
69 highlighter.red.play();
70 status_update( 'Problem saving ' + status_store.getValue( current_status, 'name' ) );
76 function save_them_all (event) {
79 query : { ischanged : 1 },
80 onItem : function (item, req) { try { if (this.isItem( item )) window.dirtyStore.push( item ); } catch (e) { /* meh */ } },
84 var confirmation = true;
87 if (event && dirtyStore.length > 0) {
88 confirmation = confirm(
89 'There are unsaved modified Statuses! '+
90 'OK to save these changes, Cancel to abandon them.'
95 for (var i in window.dirtyStore) {
96 window.current_status = window.dirtyStore[i];
100 window.dirtyStore = [];
104 dojo.addOnUnload( save_them_all );