From bf4376855feb9e6c4eee18969ac637d2406acaf2 Mon Sep 17 00:00:00 2001 From: erickson Date: Mon, 12 Jan 2009 17:33:08 +0000 Subject: [PATCH] added support for retrieving the formatted value from the widgets in a pane. all editdialog communication goes directly to the editpane git-svn-id: svn://svn.open-ils.org/ILS/trunk@11798 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/js/dojo/openils/widget/AutoWidget.js | 15 +++++++++++++++ Open-ILS/web/js/dojo/openils/widget/EditDialog.js | 15 ++++++++------- Open-ILS/web/js/dojo/openils/widget/EditPane.js | 19 +++++++++++++++++-- 3 files changed, 40 insertions(+), 9 deletions(-) diff --git a/Open-ILS/web/js/dojo/openils/widget/AutoWidget.js b/Open-ILS/web/js/dojo/openils/widget/AutoWidget.js index c7834dd96e..343e957473 100644 --- a/Open-ILS/web/js/dojo/openils/widget/AutoWidget.js +++ b/Open-ILS/web/js/dojo/openils/widget/AutoWidget.js @@ -36,6 +36,21 @@ if(!dojo._hasResource['openils.widget.AutoWidget']) { } }, + /** + * Turn the value from the dojo widget into a value oils understands + */ + getFormattedValue : function() { + var value = this.widget.attr('value'); + switch(this.idlField.datatype) { + case 'bool': + return (value) ? 't' : 'f' + case 'timestamp': + return dojo.date.stamp.toISOString(value); + default: + return value; + } + }, + build : function(onload) { this.onload = onload; this.widgetValue = (this.fmObject) ? this.fmObject[this.idlField.name]() : null; diff --git a/Open-ILS/web/js/dojo/openils/widget/EditDialog.js b/Open-ILS/web/js/dojo/openils/widget/EditDialog.js index 9aa5b4df4c..9f3c71c186 100644 --- a/Open-ILS/web/js/dojo/openils/widget/EditDialog.js +++ b/Open-ILS/web/js/dojo/openils/widget/EditDialog.js @@ -16,6 +16,12 @@ if(!dojo._hasResource['openils.widget.EditDialog']) { fmObject : null, mode : 'update', fieldOrder : null, // ordered list of field names, optional. + editPane : null, + + constructor : function() { + //this.inherited(arguments); + this.editPane = new openils.widget.EditPane(); + }, /** * Builds a basic table of key / value pairs. Keys are IDL display labels. @@ -23,13 +29,8 @@ if(!dojo._hasResource['openils.widget.EditDialog']) { */ startup : function() { this.inherited(arguments); - var pane = new openils.widget.EditPane(); - pane.mode = this.mode; - pane.fmClass = this.fmClass; - pane.fmObject = this.fmObject; - pane.fieldOrder = this.fieldOrder; - pane.startup(); - this.domNode.appendChild(pane.domNode); + this.editPane.startup(); + this.domNode.appendChild(this.editPane.domNode); } } ); diff --git a/Open-ILS/web/js/dojo/openils/widget/EditPane.js b/Open-ILS/web/js/dojo/openils/widget/EditPane.js index 595fb9f29d..f76f6abc95 100644 --- a/Open-ILS/web/js/dojo/openils/widget/EditPane.js +++ b/Open-ILS/web/js/dojo/openils/widget/EditPane.js @@ -15,6 +15,8 @@ if(!dojo._hasResource['openils.widget.EditPane']) { fmObject : null, mode : 'update', fieldOrder : null, // ordered list of field names, optional. + fieldList : [], // holds the field name + associated widget + sortedFieldList : [], // holds the sorted IDL defs for our fields /** * Builds a basic table of key / value pairs. Keys are IDL display labels. @@ -49,17 +51,30 @@ if(!dojo._hasResource['openils.widget.EditPane']) { row.appendChild(valTd); tbody.appendChild(row); - new openils.widget.AutoWidget({ + var widget = new openils.widget.AutoWidget({ idlField : field, fmObject : this.fmObject, parentNode : valTd, orgLimitPerms : this.limitPerms - }).build(); + }); + widget.build(); + this.fieldList.push({name:field.name, widget:widget}); } openils.Util.addCSSClass(table, 'oils-fm-edit-dialog'); }, + getFields : function() { + return this.fieldList.map(function(a) { return a.name }); + }, + + getFieldValue : function(field) { + for(var i in this.fieldList) { + if(field == this.fieldList[i].name) + return this.fieldList[i].widget.getFormattedValue(); + } + }, + _buildSortedFieldList : function() { this.sortedFieldList = []; -- 2.11.0