plugged in option to build cancel and 'apply' buttons. next steps are 1. i18n for...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 23 Jan 2009 16:40:58 +0000 (16:40 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 23 Jan 2009 16:40:58 +0000 (16:40 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@11936 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/js/dojo/openils/widget/AutoWidget.js
Open-ILS/web/js/dojo/openils/widget/EditDialog.js
Open-ILS/web/js/dojo/openils/widget/EditPane.js

index 9b05657..ad9df60 100644 (file)
@@ -112,7 +112,7 @@ if(!dojo._hasResource['openils.widget.AutoWidget']) {
             this.widget.searchAttr = 'shortname';
             this.widget.labelAttr = 'shortname';
             this.widget.parentField = 'parent_ou';
-            //
+            
             // if we have a limit perm, find the relevent orgs (async)
             if(this.orgLimitPerms && this.orgLimitPerms.length > 0) {
                 this.async = true;
index 68b5fb9..9fc5bfc 100644 (file)
@@ -16,6 +16,9 @@ if(!dojo._hasResource['openils.widget.EditDialog']) {
 
             constructor : function() {
                 this.editPane = new openils.widget.EditPane();
+                var self = this;
+                this.editPane.onCancel = function() { self.hide(); }
+                this.editPane.onPostApply = function() { self.hide(); }
             },
 
             /**
index 875a308..1e9f565 100644 (file)
@@ -18,6 +18,9 @@ if(!dojo._hasResource['openils.widget.EditPane']) {
             fieldOrder : null, // ordered list of field names, optional.
             fieldList : [], // holds the field name + associated widget
             sortedFieldList : [], // holds the sorted IDL defs for our fields
+            onPostApply : null, // apply callback
+            onCancel : null, // cancel callback
+            hideActionButtons : false,
 
             /**
              * Builds a basic table of key / value pairs.  Keys are IDL display labels.
@@ -61,10 +64,39 @@ if(!dojo._hasResource['openils.widget.EditPane']) {
                     widget.build();
                     this.fieldList.push({name:field.name, widget:widget});
                 }
-
+                if(!this.hideActionButtons)
+                    this.buildActionButtons(tbody);
+    
                 openils.Util.addCSSClass(table, 'oils-fm-edit-dialog');
             },
 
+            buildActionButtons : function(tbody) {
+                var row = document.createElement('tr');
+                var cancelTd = document.createElement('td');
+                var applyTd = document.createElement('td');
+                row.appendChild(cancelTd);
+                row.appendChild(applyTd);
+                tbody.appendChild(row);
+
+                var self = this;
+                new dijit.form.Button({
+                    label:'Cancel', // XXX
+                    onClick : this.onCancel
+                }, cancelTd);
+
+                new dijit.form.Button({
+                    label:'Save',  // XXX
+                    onClick: function() {
+                        self.performEditAction({
+                            oncomplete:function() {
+                                if(self.onPostApply)
+                                    self.onPostApply();
+                            }
+                        });
+                    }
+                }, applyTd);
+            },
+
             getFields : function() {
                 return this.fieldList.map(function(a) { return a.name });
             },
@@ -128,21 +160,13 @@ if(!dojo._hasResource['openils.widget.EditPane']) {
             },
 
             performEditAction : function(opts) {
-
                 var pcrud = new openils.PermaCrud();
                 var fields = this.getFields();
+                if(this.mode == 'create')
+                    this.fmObject = new fieldmapper[this.fmClass]();
                 for(var idx in fields) 
                     this.fmObject[fields[idx]](this.getFieldValue(fields[idx]));
-
-                if(opts.async) {
-                    opts.oncomplete = function(r) {
-                        pcrud.disconnect()
-                        opts.oncomplete(r);
-                    };
-                }
-
                 pcrud[this.mode](this.fmObject, opts);
-                if(!opts.async) pcrud.disconnect();
             }
         }
     );