[open-ils-commits] r11797 - trunk/Open-ILS/web/js/dojo/openils/widget
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon Jan 12 11:51:33 EST 2009
Author: erickson
Date: 2009-01-12 11:51:30 -0500 (Mon, 12 Jan 2009)
New Revision: 11797
Added:
trunk/Open-ILS/web/js/dojo/openils/widget/EditPane.js
Modified:
trunk/Open-ILS/web/js/dojo/openils/widget/EditDialog.js
Log:
added a new editpane class, which models the basic edit table of key/value pairs, for use outside of a dialog. editdialog now uses the editpane as its content.
Modified: trunk/Open-ILS/web/js/dojo/openils/widget/EditDialog.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/widget/EditDialog.js 2009-01-12 16:03:34 UTC (rev 11796)
+++ trunk/Open-ILS/web/js/dojo/openils/widget/EditDialog.js 2009-01-12 16:51:30 UTC (rev 11797)
@@ -1,11 +1,7 @@
if(!dojo._hasResource['openils.widget.EditDialog']) {
dojo.provide('openils.widget.EditDialog');
- dojo.require('openils.widget.AutoWidget');
- dojo.require('fieldmapper.Fieldmapper');
+ dojo.require('openils.widget.EditPane');
dojo.require('dijit.Dialog');
- dojo.require('openils.Util');
- dojo.require('openils.User');
- dojo.require('fieldmapper.IDL');
/**
@@ -27,93 +23,13 @@
*/
startup : function() {
this.inherited(arguments);
- this.fmClass = (this.fmObject) ? this.fmObject.classname : this.fmClass;
- this.fmIDL = fieldmapper.IDL.fmclasses[this.fmClass];
-
- var table = document.createElement('table');
- var tbody = document.createElement('tbody');
- this.domNode.appendChild(table);
- table.appendChild(tbody);
-
- this.limitPerms = [];
- if(this.fmIDL.permacrud && this.fmIDL.permacrud[this.mode])
- this.limitPerms = this.fmIDL.permacrud[this.mode].perms;
-
- this._buildSortedFieldList()
-
- for(var f in this.sortedFieldList) {
- var field = this.sortedFieldList[f];
- if(!field || field.virtual) continue;
-
- var row = document.createElement('tr');
- var nameTd = document.createElement('td');
- var valTd = document.createElement('td');
-
- nameTd.appendChild(document.createTextNode(field.label));
- row.appendChild(nameTd);
- row.appendChild(valTd);
- tbody.appendChild(row);
-
- new openils.widget.AutoWidget({
- idlField : field,
- fmObject : this.fmObject,
- parentNode : valTd,
- orgLimitPerms : this.limitPerms
- }).build();
- }
-
- openils.Util.addCSSClass(table, 'oils-fm-edit-dialog');
- },
-
- _buildSortedFieldList : function() {
- this.sortedFieldList = [];
-
- if(this.fieldOrder) {
-
- for(var idx in this.fieldOrder) {
- var name = this.fieldOrder[idx];
- for(var idx2 in this.fmIDL.fields) {
- if(this.fmIDL.fields[idx2].name == name) {
- this.sortedFieldList.push(this.fmIDL.fields[idx2]);
- break;
- }
- }
- }
-
- // if the user-defined order does not list all fields,
- // shove the extras on the end.
- var anonFields = [];
- for(var idx in this.fmIDL.fields) {
- var name = this.fmIDL.fields[idx].name;
- if(this.fieldOrder.indexOf(name) < 0) {
- anonFields.push(this.fmIDL.fields[idx]);
- }
- }
-
- anonFields = anonFields.sort(
- function(a, b) {
- if(a.label > b.label) return 1;
- if(a.label < b.label) return -1;
- return 0;
- }
- );
-
- this.sortedFieldList = this.sortedFieldList.concat(anonFields);
-
- } else {
- // no sort order defined, sort all fields on display label
-
- for(var f in this.fmIDL.fields)
- this.sortedFieldList.push(this.fmIDL.fields[f]);
- this.sortedFieldList = this.sortedFieldList.sort(
- // by default, sort on label
- function(a, b) {
- if(a.label > b.label) return 1;
- if(a.label < b.label) return -1;
- return 0;
- }
- );
- }
+ 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);
}
}
);
Added: trunk/Open-ILS/web/js/dojo/openils/widget/EditPane.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/widget/EditPane.js (rev 0)
+++ trunk/Open-ILS/web/js/dojo/openils/widget/EditPane.js 2009-01-12 16:51:30 UTC (rev 11797)
@@ -0,0 +1,116 @@
+if(!dojo._hasResource['openils.widget.EditPane']) {
+ dojo.provide('openils.widget.EditPane');
+ dojo.require('openils.widget.AutoWidget');
+ dojo.require('fieldmapper.Fieldmapper');
+ dojo.require('dijit.layout.ContentPane');
+ dojo.require('openils.Util');
+ dojo.require('openils.User');
+ dojo.require('fieldmapper.IDL');
+
+ dojo.declare(
+ 'openils.widget.EditPane',
+ [dijit.layout.ContentPane],
+ {
+ fmClass : '',
+ fmObject : null,
+ mode : 'update',
+ fieldOrder : null, // ordered list of field names, optional.
+
+ /**
+ * Builds a basic table of key / value pairs. Keys are IDL display labels.
+ * Values are dijit's, when values set
+ */
+ startup : function() {
+ this.inherited(arguments);
+ this.fmClass = (this.fmObject) ? this.fmObject.classname : this.fmClass;
+ this.fmIDL = fieldmapper.IDL.fmclasses[this.fmClass];
+
+ var table = document.createElement('table');
+ var tbody = document.createElement('tbody');
+ this.domNode.appendChild(table);
+ table.appendChild(tbody);
+
+ this.limitPerms = [];
+ if(this.fmIDL.permacrud && this.fmIDL.permacrud[this.mode])
+ this.limitPerms = this.fmIDL.permacrud[this.mode].perms;
+
+ this._buildSortedFieldList()
+
+ for(var f in this.sortedFieldList) {
+ var field = this.sortedFieldList[f];
+ if(!field || field.virtual) continue;
+
+ var row = document.createElement('tr');
+ var nameTd = document.createElement('td');
+ var valTd = document.createElement('td');
+
+ nameTd.appendChild(document.createTextNode(field.label));
+ row.appendChild(nameTd);
+ row.appendChild(valTd);
+ tbody.appendChild(row);
+
+ new openils.widget.AutoWidget({
+ idlField : field,
+ fmObject : this.fmObject,
+ parentNode : valTd,
+ orgLimitPerms : this.limitPerms
+ }).build();
+ }
+
+ openils.Util.addCSSClass(table, 'oils-fm-edit-dialog');
+ },
+
+ _buildSortedFieldList : function() {
+ this.sortedFieldList = [];
+
+ if(this.fieldOrder) {
+
+ for(var idx in this.fieldOrder) {
+ var name = this.fieldOrder[idx];
+ for(var idx2 in this.fmIDL.fields) {
+ if(this.fmIDL.fields[idx2].name == name) {
+ this.sortedFieldList.push(this.fmIDL.fields[idx2]);
+ break;
+ }
+ }
+ }
+
+ // if the user-defined order does not list all fields,
+ // shove the extras on the end.
+ var anonFields = [];
+ for(var idx in this.fmIDL.fields) {
+ var name = this.fmIDL.fields[idx].name;
+ if(this.fieldOrder.indexOf(name) < 0) {
+ anonFields.push(this.fmIDL.fields[idx]);
+ }
+ }
+
+ anonFields = anonFields.sort(
+ function(a, b) {
+ if(a.label > b.label) return 1;
+ if(a.label < b.label) return -1;
+ return 0;
+ }
+ );
+
+ this.sortedFieldList = this.sortedFieldList.concat(anonFields);
+
+ } else {
+ // no sort order defined, sort all fields on display label
+
+ for(var f in this.fmIDL.fields)
+ this.sortedFieldList.push(this.fmIDL.fields[f]);
+ this.sortedFieldList = this.sortedFieldList.sort(
+ // by default, sort on label
+ function(a, b) {
+ if(a.label > b.label) return 1;
+ if(a.label < b.label) return -1;
+ return 0;
+ }
+ );
+ }
+ }
+ }
+ );
+}
+
More information about the open-ils-commits
mailing list