[open-ils-commits] r12122 - trunk/Open-ILS/web/js/dojo/openils/widget (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon Feb 9 16:53:52 EST 2009
Author: erickson
Date: 2009-02-09 16:53:48 -0500 (Mon, 09 Feb 2009)
New Revision: 12122
Modified:
trunk/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js
trunk/Open-ILS/web/js/dojo/openils/widget/EditPane.js
Log:
created read-only version of a single widget and edit pane
Modified: trunk/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js 2009-02-09 18:51:24 UTC (rev 12121)
+++ trunk/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js 2009-02-09 21:53:48 UTC (rev 12122)
@@ -43,7 +43,7 @@
* Turn the value from the dojo widget into a value oils understands
*/
getFormattedValue : function() {
- var value = this.widget.attr('value');
+ var value = this.baseWidgetValue();
switch(this.idlField.datatype) {
case 'bool':
return (value) ? 't' : 'f'
@@ -53,6 +53,12 @@
return value;
}
},
+
+ baseWidgetValue : function(value) {
+ var attr = (this.readOnly) ? 'content' : 'value';
+ if(arguments.length) this.widget.attr(attr, value);
+ return this.widget.attr(attr, value);
+ },
getDisplayString : function() {
var value = this.widgetValue;
@@ -67,7 +73,7 @@
case 'org_unit':
return fieldmapper.aou.findOrgUnit(value).shortname();
default:
- return value;
+ return value+'';
}
},
@@ -76,43 +82,50 @@
if(this.widgetValue == null)
this.widgetValue = (this.fmObject) ? this.fmObject[this.idlField.name]() : null;
- switch(this.idlField.datatype) {
-
- case 'id':
- dojo.require('dijit.form.TextBox');
- this.widget = new dijit.form.TextBox(this.dijitArgs, this.parentNode);
- this.widget.attr('disabled', true); // never allow editing of IDs
- break;
+ if(this.readOnly) {
+ dojo.require('dijit.layout.ContentPane');
+ this.widget = new dijit.layout.ContentPane(this.dijitArgs, this.parentNode);
- case 'org_unit':
- this._buildOrgSelector();
- break;
+ } else {
- case 'money':
- dojo.require('dijit.form.CurrencyTextBox');
- this.widget = new dijit.form.CurrencyTextBox(this.dijitArgs, this.parentNode);
- break;
+ switch(this.idlField.datatype) {
+
+ case 'id':
+ dojo.require('dijit.form.TextBox');
+ this.widget = new dijit.form.TextBox(this.dijitArgs, this.parentNode);
+ this.widget.attr('disabled', true); // never allow editing of IDs
+ break;
- case 'timestamp':
- dojo.require('dijit.form.DateTextBox');
- dojo.require('dojo.date.stamp');
- this.widget = new dijit.form.DateTextBox(this.dijitArgs, this.parentNode);
- if(this.widgetValue != null)
- this.widgetValue = dojo.date.stamp.fromISOString(this.widgetValue);
- break;
+ case 'org_unit':
+ this._buildOrgSelector();
+ break;
- case 'bool':
- dojo.require('dijit.form.CheckBox');
- this.widget = new dijit.form.CheckBox(this.dijitArgs, this.parentNode);
- this.widgetValue = openils.Util.isTrue(this.widgetValue);
- break;
+ case 'money':
+ dojo.require('dijit.form.CurrencyTextBox');
+ this.widget = new dijit.form.CurrencyTextBox(this.dijitArgs, this.parentNode);
+ break;
- case 'link':
- if(this._buildLinkSelector()) break;
+ case 'timestamp':
+ dojo.require('dijit.form.DateTextBox');
+ dojo.require('dojo.date.stamp');
+ this.widget = new dijit.form.DateTextBox(this.dijitArgs, this.parentNode);
+ if(this.widgetValue != null)
+ this.widgetValue = dojo.date.stamp.fromISOString(this.widgetValue);
+ break;
- default:
- dojo.require('dijit.form.TextBox');
- this.widget = new dijit.form.TextBox(this.dijitArgs, this.parentNode);
+ case 'bool':
+ dojo.require('dijit.form.CheckBox');
+ this.widget = new dijit.form.CheckBox(this.dijitArgs, this.parentNode);
+ this.widgetValue = openils.Util.isTrue(this.widgetValue);
+ break;
+
+ case 'link':
+ if(this._buildLinkSelector()) break;
+
+ default:
+ dojo.require('dijit.form.TextBox');
+ this.widget = new dijit.form.TextBox(this.dijitArgs, this.parentNode);
+ }
}
if(!this.async) this._widgetLoaded();
@@ -167,10 +180,13 @@
* For widgets that run asynchronously, provide a callback for finishing up
*/
_widgetLoaded : function(value) {
- if(this.widgetValue != null)
- this.widget.attr('value', this.widgetValue);
- if(this.idlField.name == this.fmIDL.pkey && this.fmIDL.pkey_sequence)
- this.widget.attr('disabled', true);
+ if(this.readOnly) {
+ this.baseWidgetValue(this.getDisplayString());
+ } else {
+ this.baseWidgetValue(this.widgetValue);
+ if(this.idlField.name == this.fmIDL.pkey && this.fmIDL.pkey_sequence)
+ this.widget.attr('disabled', true);
+ }
if(this.onload)
this.onload(this.widget, self);
},
Modified: trunk/Open-ILS/web/js/dojo/openils/widget/EditPane.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/widget/EditPane.js 2009-02-09 18:51:24 UTC (rev 12121)
+++ trunk/Open-ILS/web/js/dojo/openils/widget/EditPane.js 2009-02-09 21:53:48 UTC (rev 12122)
@@ -29,6 +29,7 @@
startup : function() {
this.inherited(arguments);
this.initAutoEnv();
+ this.hideActionButtons = this.readOnly;
var table = document.createElement('table');
var tbody = document.createElement('tbody');
@@ -59,7 +60,8 @@
fmObject : this.fmObject,
fmClass : this.fmClass,
parentNode : valSpan,
- orgLimitPerms : this.limitPerms
+ orgLimitPerms : this.limitPerms,
+ readOnly : this.readOnly
});
widget.build();
More information about the open-ils-commits
mailing list