]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/web/conify/global/config/copy_status.js
LP1615805 No inputs after submit in patron search (AngularJS)
[Evergreen.git] / Open-ILS / web / conify / global / config / copy_status.js
1 /*
2 # ---------------------------------------------------------------------------
3 # Copyright (C) 2008  Georgia Public Library Service / Equinox Software, Inc
4 # Mike Rylander <miker@esilibrary.com>
5
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.
10
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 # ---------------------------------------------------------------------------
16 */
17
18 dojo.require('fieldmapper.AutoIDL');
19 dojo.require('fieldmapper.dojoData');
20 dojo.require('openils.widget.TranslatorPopup');
21 dojo.require('openils.PermaCrud');
22 dojo.require('dojo.parser');
23 dojo.require('dojo.string');
24 dojo.require('dojo.data.ItemFileWriteStore');
25 dojo.require('dojo.cookie');
26 dojo.require('dijit.form.TextBox');
27 dojo.require('dijit.form.ValidationTextBox');
28 dojo.require('dijit.form.Textarea');
29 dojo.require('dijit.layout.ContentPane');
30 dojo.require('dijit.layout.LayoutContainer');
31 dojo.require('dijit.layout.BorderContainer');
32 dojo.require('dojox.widget.Toaster');
33 dojo.require('dojox.fx');
34 dojo.require('dojox.grid.Grid');
35 dojo.require('openils.XUL');
36 dojo.requireLocalization("openils.conify", "conify");
37
38 // some handy globals
39 var cgi = new CGI();
40 var ses = dojo.cookie('ses') || cgi.param('ses');
41 if(!ses && openils.XUL.isXUL()) {
42     var stash = openils.XUL.getStash();
43     ses = stash.session.key;
44 }
45 var pCRUD = new openils.PermaCrud({authtoken:ses});
46
47 var current_status;
48 var virgin_out_id = -1;
49
50 var ccs_strings = dojo.i18n.getLocalization('openils.conify', 'conify');
51
52 var highlighter = {};
53
54 function status_update (markup) {
55         if (parent !== window && parent.status_update) parent.status_update( markup );
56 }
57
58 function save_status () {
59
60         var modified_ccs = new ccs().fromStoreItem( current_status );
61         modified_ccs.ischanged( 1 );
62
63         pCRUD.update(modified_ccs, {
64                 onerror : function (r) {
65                         highlighter.red.play();
66                         status_update( dojo.string.substitute(ccs_strings.ERROR_SAVING_STATUS, [status_store.getValue( current_status, 'name' )]) );
67                 },
68                 oncomplete : function (r) {
69                         status_store.setValue( current_status, 'ischanged', 0 );
70                         highlighter.green.play();
71                         status_update( dojo.string.substitute(ccs_strings.SUCCESS_SAVE, [status_store.getValue( current_status, 'name' )]) );
72                 }
73         });
74 }
75
76 function save_them_all (event) {
77
78         status_store.fetch({
79                 query : { ischanged : 1 },
80                 onItem : function (item, req) { try { if (this.isItem( item )) window.dirtyStore.push( item ); } catch (e) { /* meh */ } },
81                 scope : status_store
82         });
83
84         var confirmation = true;
85
86
87         if (event && dirtyStore.length > 0) {
88                 confirmation = confirm(
89                         ccs_strings.CONFIRM_EXIT_CCS
90                 );
91         }
92
93         if (confirmation) {
94                 for (var i in window.dirtyStore) {
95                         window.current_status = window.dirtyStore[i];
96                         save_status(true);
97                 }
98
99                 window.dirtyStore = [];
100         }
101 }
102
103 dojo.addOnUnload( save_them_all );
104