[open-ils-commits] r11936 - trunk/Open-ILS/web/js/dojo/openils/widget
svn at svn.open-ils.org
svn at svn.open-ils.org
Fri Jan 23 11:41:00 EST 2009
Author: erickson
Date: 2009-01-23 11:40:58 -0500 (Fri, 23 Jan 2009)
New Revision: 11936
Modified:
trunk/Open-ILS/web/js/dojo/openils/widget/AutoWidget.js
trunk/Open-ILS/web/js/dojo/openils/widget/EditDialog.js
trunk/Open-ILS/web/js/dojo/openils/widget/EditPane.js
Log:
plugged in option to build cancel and 'apply' buttons. next steps are 1. i18n for buttons, 2. use widget template instead of manual element creation
Modified: trunk/Open-ILS/web/js/dojo/openils/widget/AutoWidget.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/widget/AutoWidget.js 2009-01-23 15:57:47 UTC (rev 11935)
+++ trunk/Open-ILS/web/js/dojo/openils/widget/AutoWidget.js 2009-01-23 16:40:58 UTC (rev 11936)
@@ -112,7 +112,7 @@
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;
Modified: trunk/Open-ILS/web/js/dojo/openils/widget/EditDialog.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/widget/EditDialog.js 2009-01-23 15:57:47 UTC (rev 11935)
+++ trunk/Open-ILS/web/js/dojo/openils/widget/EditDialog.js 2009-01-23 16:40:58 UTC (rev 11936)
@@ -16,6 +16,9 @@
constructor : function() {
this.editPane = new openils.widget.EditPane();
+ var self = this;
+ this.editPane.onCancel = function() { self.hide(); }
+ this.editPane.onPostApply = function() { self.hide(); }
},
/**
Modified: trunk/Open-ILS/web/js/dojo/openils/widget/EditPane.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/widget/EditPane.js 2009-01-23 15:57:47 UTC (rev 11935)
+++ trunk/Open-ILS/web/js/dojo/openils/widget/EditPane.js 2009-01-23 16:40:58 UTC (rev 11936)
@@ -18,6 +18,9 @@
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 @@
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 @@
},
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();
}
}
);
More information about the open-ils-commits
mailing list