]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/web/conify/global/actor/org_unit_type.js
26cb07d10eb0f58e2af3d8c862d4b23bd7115de1
[working/Evergreen.git] / Open-ILS / web / conify / global / actor / org_unit_type.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.cookie');
24 dojo.require('dojo.data.ItemFileWriteStore');
25 dojo.require('dojo.date.stamp');
26 dojo.require('dijit.form.NumberSpinner');
27 dojo.require('dijit.form.TextBox');
28 dojo.require('dijit.form.TimeTextBox');
29 dojo.require('dijit.form.ValidationTextBox');
30 dojo.require('dijit.form.CheckBox');
31 dojo.require('dijit.form.FilteringSelect');
32 dojo.require('dijit.Tree');
33 dojo.require('dijit.layout.ContentPane');
34 dojo.require('dijit.layout.TabContainer');
35 dojo.require('dijit.layout.LayoutContainer');
36 dojo.require('dijit.layout.SplitContainer');
37 dojo.require('dojox.widget.Toaster');
38 dojo.require('dojox.fx');
39 dojo.requireLocalization("openils.conify", "conify");
40
41 // some handy globals
42 var cgi = new CGI();
43 var ses = dojo.cookie('ses') || cgi.param('ses');
44 var pCRUD = new openils.PermaCrud({authtoken:ses});
45
46 var current_type;
47 var current_fm_type;
48 var virgin_out_id = -1;
49
50 var highlighter = {};
51
52 var aout_strings = dojo.i18n.getLocalization('openils.conify', 'conify');
53
54 function status_update (markup) {
55         if (parent !== window && parent.status_update) parent.status_update( markup );
56 }
57
58 function save_type () {
59
60         var modified_aout = new aout().fromStoreItem( current_type );
61         modified_aout.ischanged( 1 );
62
63         new_kid_button.disabled = false;
64         save_out_button.disabled = false;
65         delete_out_button.disabled = false;
66
67         pCRUD.update(modified_aout, {
68                 onerror : function (r) {
69                         highlighter.editor_pane.red.play();
70                         status_update( dojo.string.substitute(aout_strings.ERROR_SAVING_DATA, [ou_type_store.getValue( current_type, 'name' )] ) );
71                 },
72                 oncomplete : function (r) {
73                         ou_type_store.setValue( current_type, 'ischanged', 0 );
74                         highlighter.editor_pane.green.play();
75                         status_update( dojo.string.substitute(aout_strings.SUCCESS_SAVING_DATA, [ou_type_store.getValue( current_type, 'name' )] ) );
76                 }
77         });
78 }
79