From e7921304796d75a9bd5985460c2822c9d32e5dd6 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Tue, 16 Aug 2011 21:18:26 +0000 Subject: [PATCH] Stop errors from missing _data and missing array managers --- etemplate/js/et2_inputWidget.js | 9 +++++++++ etemplate/js/et2_valueWidget.js | 10 ++++++---- etemplate/js/et2_widget.js | 16 ++++++++++------ etemplate/js/etemplate2.js | 4 +++- 4 files changed, 28 insertions(+), 11 deletions(-) diff --git a/etemplate/js/et2_inputWidget.js b/etemplate/js/et2_inputWidget.js index 4c4a045d44..1b7a31a747 100644 --- a/etemplate/js/et2_inputWidget.js +++ b/etemplate/js/et2_inputWidget.js @@ -45,6 +45,14 @@ var et2_IInput = new Interface({ */ var et2_inputWidget = et2_valueWidget.extend(et2_IInput, { + attributes: { + "required": { + "name": "Required", + "default": false, + "type": "boolean", + "description": "If required, the user must enter a value before the form can be submitted" + } + }, init: function() { this._super.apply(this, arguments); @@ -89,6 +97,7 @@ var et2_inputWidget = et2_valueWidget.extend(et2_IInput, { node.removeAttribute("required"); } } + }, get_value: function() { diff --git a/etemplate/js/et2_valueWidget.js b/etemplate/js/et2_valueWidget.js index 92abbd5506..778a970017 100644 --- a/etemplate/js/et2_valueWidget.js +++ b/etemplate/js/et2_valueWidget.js @@ -40,10 +40,12 @@ var et2_valueWidget = et2_baseWidget.extend({ { // Set the value for this element var contentMgr = this.getArrayMgr("content"); - var val = contentMgr.getValueForID(this.id); - if (val !== null) - { - this.setAttribute("value", val) + if(contentMgr != null) { + var val = contentMgr.getValueForID(this.id); + if (val !== null) + { + this.setAttribute("value", val) + } } } } diff --git a/etemplate/js/et2_widget.js b/etemplate/js/et2_widget.js index 9905c65a89..3bd3507954 100644 --- a/etemplate/js/et2_widget.js +++ b/etemplate/js/et2_widget.js @@ -395,8 +395,12 @@ var et2_widget = Class.extend({ // Check whether the widget is marked as readonly and whether a special // readonly type (suffixed with "_ro") is registered - var readonly = this.getArrayMgr("readonlys").isReadOnly( - _node.getAttribute("id"), _node.getAttribute("readonly"), this.readonly); + var mgr = this.getArrayMgr("readonlys"); + var readonly = false; + if(mgr != null) { + readonly = mgr.isReadOnly( + _node.getAttribute("id"), _node.getAttribute("readonly"), this.readonly); + } if (readonly && typeof et2_registry[_nodeName + "_ro"] != "undefined") { constructor = et2_registry[_nodeName + "_ro"]; @@ -471,7 +475,8 @@ var et2_widget = Class.extend({ var attrName = _attrs[i].name; var attrValue = _attrs[i].value; - if (typeof this.attributes[attrName] != "undefined") + var mgr = this.getArrayMgr("content"); + if (mgr != null && typeof this.attributes[attrName] != "undefined") { var attr = this.attributes[attrName]; @@ -479,12 +484,11 @@ var et2_widget = Class.extend({ // expression as bool expression. if (attr.type == "boolean") { - attrValue = this.getArrayMgr("content") - .parseBoolExpression(attrValue); + attrValue = mgr.parseBoolExpression(attrValue); } else { - attrValue = this.getArrayMgr("content").expandName(attrValue); + attrValue = mgr.expandName(attrValue); } } diff --git a/etemplate/js/etemplate2.js b/etemplate/js/etemplate2.js index 242b276b90..4259fd6f06 100644 --- a/etemplate/js/etemplate2.js +++ b/etemplate/js/etemplate2.js @@ -131,7 +131,9 @@ etemplate2.prototype.load = function(_url, _data) this.widgetContainer.setParentDOMNode(this.DOMContainer); // store the id to submit it back to server - this.etemplate_exec_id = _data.etemplate_exec_id; + if(_data) { + this.etemplate_exec_id = _data.etemplate_exec_id; + } // set app_header if (window.opener) { // popup