Correctly return {app, id} or just id, even if value is empty

This commit is contained in:
Nathan Gray 2012-06-18 22:41:54 +00:00
parent b80570cd66
commit e807bb824d

View File

@ -458,7 +458,8 @@ var et2_link_entry = et2_inputWidget.extend({
{ {
// Clear // Clear
self.search.autocomplete("close"); self.search.autocomplete("close");
self.search.val(""); self.set_value("");
self.search.trigger("change");
} }
self.search.focus(); self.search.focus();
}) })
@ -505,17 +506,10 @@ var et2_link_entry = et2_inputWidget.extend({
}, },
getValue: function() { getValue: function() {
return this.options.value; return this.options.application ? this.value.id : this.value;
}, },
set_value: function(_value) { set_value: function(_value) {
if(!_value || _value.length == 0)
{
this.search.text("");
this.clear.hide();
this.value = {};
return;
}
if(typeof _value == 'string') if(typeof _value == 'string')
{ {
if(_value.indexOf(",") > 0) _value = _value.replace(",",":"); if(_value.indexOf(",") > 0) _value = _value.replace(",",":");
@ -536,6 +530,13 @@ var et2_link_entry = et2_inputWidget.extend({
}; };
} }
} }
if(!_value || _value.length == 0)
{
this.search.val("");
this.clear.hide();
this.value = _value;
return;
}
this.clear.show(); this.clear.show();
if(!_value.app) _value.app = this.options.application; if(!_value.app) _value.app = this.options.application;
if(typeof _value != 'object' || !(_value.app && _value.id)) if(typeof _value != 'object' || !(_value.app && _value.id))
@ -643,6 +644,8 @@ var et2_link_entry = et2_inputWidget.extend({
this.clear.show(); this.clear.show();
event.data.search.val(selected.item.label); event.data.search.val(selected.item.label);
// Fire change event
this.search.change();
}, },
/** /**