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