some fixes to get "add favorite" in regular calendar views do something

This commit is contained in:
Ralf Becker 2013-12-08 22:56:23 +00:00
parent 921eaf73f1
commit 8da1afca1e
2 changed files with 24 additions and 20 deletions

View File

@ -22,10 +22,10 @@
* et2_inputWidget derrives from et2_simpleWidget and implements the IInput * et2_inputWidget derrives from et2_simpleWidget and implements the IInput
* interface. When derriving from this class, call setDOMNode with an input * interface. When derriving from this class, call setDOMNode with an input
* DOMNode. * DOMNode.
* *
* @augments et2_valueWidget * @augments et2_valueWidget
*/ */
var et2_inputWidget = et2_valueWidget.extend([et2_IInput,et2_ISubmitListener], var et2_inputWidget = et2_valueWidget.extend([et2_IInput,et2_ISubmitListener],
{ {
attributes: { attributes: {
"needed": { "needed": {
@ -62,7 +62,7 @@ var et2_inputWidget = et2_valueWidget.extend([et2_IInput,et2_ISubmitListener],
/** /**
* Constructor * Constructor
* *
* @memberOf et2_inputWidget * @memberOf et2_inputWidget
*/ */
init: function() { init: function() {
@ -117,7 +117,7 @@ var et2_inputWidget = et2_valueWidget.extend([et2_IInput,et2_ISubmitListener],
} }
this._super.apply(this,arguments); this._super.apply(this,arguments);
// $j(this.getInputNode()).attr("novalidate","novalidate"); // Stop browser from getting involved // $j(this.getInputNode()).attr("novalidate","novalidate"); // Stop browser from getting involved
// $j(this.getInputNode()).validator(); // $j(this.getInputNode()).validator();
}, },
@ -132,7 +132,7 @@ var et2_inputWidget = et2_valueWidget.extend([et2_IInput,et2_ISubmitListener],
change: function(_node) { change: function(_node) {
var messages = []; var messages = [];
var valid = this.isValid(messages); var valid = this.isValid(messages);
// Passing false will clear any set messages // Passing false will clear any set messages
this.set_validation_error(valid ? false : messages); this.set_validation_error(valid ? false : messages);
@ -143,7 +143,7 @@ var et2_inputWidget = et2_valueWidget.extend([et2_IInput,et2_ISubmitListener],
// Make sure function gets a reference to the widget // Make sure function gets a reference to the widget
var args = Array.prototype.slice.call(arguments); var args = Array.prototype.slice.call(arguments);
if(args.indexOf(this) == -1) args.push(this); if(args.indexOf(this) == -1) args.push(this);
return this.onchange.apply(this, args); return this.onchange.apply(this, args);
} else { } else {
return (et2_compileLegacyJS(this.options.onchange, this, _node))(); return (et2_compileLegacyJS(this.options.onchange, this, _node))();
@ -151,15 +151,15 @@ var et2_inputWidget = et2_valueWidget.extend([et2_IInput,et2_ISubmitListener],
} }
return valid; return valid;
}, },
focus: function(_node) focus: function(_node)
{ {
if(typeof this.options.onfocus == 'function') if(typeof this.options.onfocus == 'function')
{ {
// Make sure function gets a reference to the widget // Make sure function gets a reference to the widget
var args = Array.prototype.slice.call(arguments); var args = Array.prototype.slice.call(arguments);
if(args.indexOf(this) == -1) args.push(this); if(args.indexOf(this) == -1) args.push(this);
return this.options.onfocus.apply(this, args); return this.options.onfocus.apply(this, args);
} }
}, },
@ -180,7 +180,7 @@ var et2_inputWidget = et2_valueWidget.extend([et2_IInput,et2_ISubmitListener],
set_id: function(_value) { set_id: function(_value) {
this.id = _value; this.id = _value;
this.dom_id = _value ? this.getInstanceManager().uniqueId+'_'+this.id : _value; this.dom_id = _value && this.getInstanceManager() ? this.getInstanceManager().uniqueId+'_'+this.id : _value;
// Set the id of the _input_ node (in contrast to the default // Set the id of the _input_ node (in contrast to the default
// implementation, which sets the base node) // implementation, which sets the base node)
@ -227,7 +227,7 @@ var et2_inputWidget = et2_valueWidget.extend([et2_IInput,et2_ISubmitListener],
{ {
this.showMessage(_value, "validation_error"); this.showMessage(_value, "validation_error");
$j(node).addClass("invalid"); $j(node).addClass("invalid");
// If on a tab, switch to that tab so user can see it // If on a tab, switch to that tab so user can see it
var widget = this; var widget = this;
var tab = this; var tab = this;
@ -278,10 +278,10 @@ var et2_inputWidget = et2_valueWidget.extend([et2_IInput,et2_ISubmitListener],
resetDirty: function() { resetDirty: function() {
this._oldValue = this.getValue(); this._oldValue = this.getValue();
}, },
isValid: function(messages) { isValid: function(messages) {
var ok = true; var ok = true;
// Check for required // Check for required
if(this.options && this.options.needed && !this.options.readonly && (this.getValue() == null || this.getValue().valueOf() == '')) if(this.options && this.options.needed && !this.options.readonly && (this.getValue() == null || this.getValue().valueOf() == ''))
{ {
@ -294,14 +294,14 @@ var et2_inputWidget = et2_valueWidget.extend([et2_IInput,et2_ISubmitListener],
/** /**
* Called whenever the template gets submitted. We return false if the widget * Called whenever the template gets submitted. We return false if the widget
* is not valid, which cancels the submission. * is not valid, which cancels the submission.
* *
* @param _values contains the values which will be sent to the server. * @param _values contains the values which will be sent to the server.
* Listeners may change these values before they get submitted. * Listeners may change these values before they get submitted.
*/ */
submit: function(_values) { submit: function(_values) {
var messages = []; var messages = [];
var valid = this.isValid(messages); var valid = this.isValid(messages);
// Passing false will clear any set messages // Passing false will clear any set messages
this.set_validation_error(valid ? false : messages); this.set_validation_error(valid ? false : messages);
return valid; return valid;

View File

@ -225,11 +225,15 @@ var et2_selectbox = et2_inputWidget.extend(
// content array. // content array.
if (jQuery.isEmptyObject(_attrs["select_options"])) if (jQuery.isEmptyObject(_attrs["select_options"]))
{ {
// If that didn't work, check according to ID if (content_options) _attrs['select_options'] = content_options;
_attrs["select_options"] = content_options ? content_options : this.getArrayMgr('content') var content_mgr = this.getArrayMgr('content');
.getEntry("options-" + this.id); if (content_mgr)
// Again, try last name part at top level - this is usually just the value {
var content_options = this.getArrayMgr('content').getRoot().getEntry(name_parts[name_parts.length-1]); // If that didn't work, check according to ID
if (!content_options) _attrs["select_options"] = content_mgr.getEntry("options-" + this.id);
// Again, try last name part at top level - this is usually just the value
var content_options = content_mgr.getRoot().getEntry(name_parts[name_parts.length-1]);
}
} }
// Default to an empty object // Default to an empty object