]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/web/js/dojo/openils/widget/EditDialog.js
LP2045292 Color contrast for AngularJS patron bills
[working/Evergreen.git] / Open-ILS / web / js / dojo / openils / widget / EditDialog.js
1 /**
2 var dialog = new openils.widget.EditDialog({
3     fmObject: survey,
4     fieldOrder: ['id', 'name', 'description', 'start_date', 'end_date']
5 });
6 dialog.startup();
7 dialog.show();
8 */
9
10
11
12 if(!dojo._hasResource['openils.widget.EditDialog']) {
13     dojo.provide('openils.widget.EditDialog');
14     dojo.require('openils.widget.EditPane');
15     dojo.require('dijit.Dialog');
16     dojo.require('openils.Util');
17
18     /**
19      * Given a fieldmapper object, this builds a pop-up dialog used for editing the object
20      */
21
22     dojo.declare(
23         'openils.widget.EditDialog',
24         [dijit.Dialog],
25         {
26             editPane : null, // reference to our EditPane object
27
28             constructor : function(args) {
29                 args = args || {};
30                 this.editPane = args.editPane || new openils.widget.EditPane(args);
31                 var self = this;
32
33                 var onCancel = args.onCancel || this.editPane.onCancel;
34                 var onSubmit = args.onPostSubmit || this.editPane.onPostSubmit;
35
36                 this.editPane.onCancel = function() { 
37                     if(onCancel) onCancel();
38                     self.hide(); 
39                 }
40
41                 this.editPane.onPostSubmit = function(r, cudResults) { 
42                     self.hide(); 
43                     if(onSubmit) onSubmit(r, cudResults);
44                 }
45             },
46
47             /**
48              * Builds a basic table of key / value pairs.  Keys are IDL display labels.
49              * Values are dijit's, when values set
50              */
51             startup : function() {
52                 this.inherited(arguments);
53                 this.attr('content', this.editPane);
54                 openils.Util.addCSSClass(this.editPane.table, 'oils-fm-edit-dialog');
55             }
56         }
57     );
58 }
59