]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/web/conify/global/actor/org_unit_type.js
Improve Firefox/XULRunner Support
[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.require('openils.XUL');
40 dojo.requireLocalization("openils.conify", "conify");
41
42 // some handy globals
43 var cgi = new CGI();
44 var ses = dojo.cookie('ses') || cgi.param('ses');
45 if(!ses && openils.XUL.isXUL()) {
46     var stash = openils.XUL.getStash();
47     ses = stash.session.key;
48 }
49 var pCRUD = new openils.PermaCrud({authtoken:ses});
50
51 var current_type;
52 var current_fm_type;
53 var virgin_out_id = -1;
54
55 var highlighter = {};
56
57 var aout_strings = dojo.i18n.getLocalization('openils.conify', 'conify');
58
59 function status_update (markup) {
60         if (parent !== window && parent.status_update) parent.status_update( markup );
61 }
62
63 function save_type () {
64
65         var modified_aout = new aout().fromStoreItem( current_type );
66         modified_aout.ischanged( 1 );
67
68         new_kid_button.disabled = false;
69         save_out_button.disabled = false;
70         delete_out_button.disabled = false;
71
72         pCRUD.update(modified_aout, {
73                 onerror : function (r) {
74                         highlighter.editor_pane.red.play();
75                         status_update( dojo.string.substitute(aout_strings.ERROR_SAVING_DATA, [ou_type_store.getValue( current_type, 'name' )] ) );
76                 },
77                 oncomplete : function (r) {
78                         ou_type_store.setValue( current_type, 'ischanged', 0 );
79                         highlighter.editor_pane.green.play();
80                         status_update( dojo.string.substitute(aout_strings.SUCCESS_SAVING_DATA, [ou_type_store.getValue( current_type, 'name' )] ) );
81                 }
82         });
83 }
84