give explicit select-options priority over querying accounts via link-widget, fixes not displayed addressbook for sharing

This commit is contained in:
Ralf Becker 2020-11-02 09:09:46 +01:00
parent 93e5afac69
commit bd85f19c5e
3 changed files with 32 additions and 8 deletions

View File

@ -154,7 +154,7 @@
<customfields-list id="$row" class="customfields"/> <customfields-list id="$row" class="customfields"/>
<textbox multiline="true" id="${row}[note]" no_lang="1" readonly="true"/> <textbox multiline="true" id="${row}[note]" no_lang="1" readonly="true"/>
<description id="${row}[distrib_lists]"/> <description id="${row}[distrib_lists]"/>
<select id="${row}[owner]" readonly="true"/> <select-account id="${row}[owner]" readonly="true"/>
<description id="${row}[id]" class="contactid"/> <description id="${row}[id]" class="contactid"/>
<vbox> <vbox>
<link id="${row}[last_link]"/> <link id="${row}[last_link]"/>

View File

@ -661,8 +661,8 @@ var et2_selectAccount_ro = /** @class */ (function (_super) {
if (typeof _value == 'string' && _value.indexOf(',') > 0) { if (typeof _value == 'string' && _value.indexOf(',') > 0) {
_value = _value.split(','); _value = _value.split(',');
} }
// Don't bother to lookup if it's not an array, or a number // pass objects to link widget right away, as following code can't deal with objects
if (typeof _value == 'object' || !isNaN(_value) && _value != "") { if (typeof _value == 'object') {
_super.prototype.set_value.call(this, _value); _super.prototype.set_value.call(this, _value);
// Don't make it look like a link though // Don't make it look like a link though
jQuery('li', this.list).removeClass("et2_link et2_link_string") jQuery('li', this.list).removeClass("et2_link et2_link_string")
@ -674,10 +674,12 @@ var et2_selectAccount_ro = /** @class */ (function (_super) {
jQuery('li', this.list).removeClass("et2_link et2_link_string") jQuery('li', this.list).removeClass("et2_link et2_link_string")
// No clicks either // No clicks either
.off(); .off();
var found = false;
if (this.options.select_options && !jQuery.isEmptyObject(this.options.select_options) || this.options.empty_label) { if (this.options.select_options && !jQuery.isEmptyObject(this.options.select_options) || this.options.empty_label) {
if (!_value) { if (!_value) {
// Empty label from selectbox // Empty label from selectbox
this.list.append("<li>" + this.options.empty_label + "</li>"); this.list.append("<li>" + this.options.empty_label + "</li>");
found = true;
} }
else if (typeof _value == 'object') { else if (typeof _value == 'object') {
// An array with 0 / empty in it? // An array with 0 / empty in it?
@ -688,6 +690,7 @@ var et2_selectAccount_ro = /** @class */ (function (_super) {
} }
else if (this.options.select_options[_value]) { else if (this.options.select_options[_value]) {
this.list.append("<li>" + this.options.select_options[_value] + "</li>"); this.list.append("<li>" + this.options.select_options[_value] + "</li>");
found = true;
} }
} }
} }
@ -698,19 +701,28 @@ var et2_selectAccount_ro = /** @class */ (function (_super) {
search = [_value]; search = [_value];
} }
for (var j = 0; j < search.length; j++) { for (var j = 0; j < search.length; j++) {
var found = false;
// Not having a value to look up causes an infinite loop // Not having a value to look up causes an infinite loop
if (!search[j]) if (!search[j])
continue; continue;
for (var i in this.options.select_options) { for (var i in this.options.select_options) {
if (this.options.select_options[i].value == search[j]) { if (this.options.select_options[i].value == search[j]) {
this.list.append("<li>" + this.options.select_options[i].label + "</li>"); this.list.append("<li>" + this.options.select_options[i].label + "</li>");
found = true;
break; break;
} }
} }
} }
} }
} }
// if nothing found in select-options let link widget try
if (!found && !isNaN(_value)) {
_super.prototype.set_value.call(this, _value);
// Don't make it look like a link though
jQuery('li', this.list).removeClass("et2_link et2_link_string")
// No clicks either
.off();
return;
}
}; };
et2_selectAccount_ro._attributes = { et2_selectAccount_ro._attributes = {
"empty_label": { "empty_label": {

View File

@ -826,8 +826,8 @@ export class et2_selectAccount_ro extends et2_link_string
_value = _value.split(','); _value = _value.split(',');
} }
// Don't bother to lookup if it's not an array, or a number // pass objects to link widget right away, as following code can't deal with objects
if(typeof _value == 'object' || !isNaN(_value) && _value != "") if (typeof _value == 'object')
{ {
super.set_value(_value); super.set_value(_value);
// Don't make it look like a link though // Don't make it look like a link though
@ -842,12 +842,14 @@ export class et2_selectAccount_ro extends et2_link_string
// No clicks either // No clicks either
.off(); .off();
let found = false;
if(this.options.select_options && !jQuery.isEmptyObject(this.options.select_options) || this.options.empty_label) if(this.options.select_options && !jQuery.isEmptyObject(this.options.select_options) || this.options.empty_label)
{ {
if(!_value) if(!_value)
{ {
// Empty label from selectbox // Empty label from selectbox
this.list.append("<li>"+this.options.empty_label+"</li>"); this.list.append("<li>"+this.options.empty_label+"</li>");
found = true;
} }
else if (typeof _value == 'object') else if (typeof _value == 'object')
{ {
@ -862,6 +864,7 @@ export class et2_selectAccount_ro extends et2_link_string
else if (this.options.select_options[_value]) else if (this.options.select_options[_value])
{ {
this.list.append("<li>"+this.options.select_options[_value]+"</li>"); this.list.append("<li>"+this.options.select_options[_value]+"</li>");
found = true;
} }
} }
} }
@ -875,8 +878,6 @@ export class et2_selectAccount_ro extends et2_link_string
} }
for(let j = 0; j < search.length; j++) for(let j = 0; j < search.length; j++)
{ {
var found = false;
// Not having a value to look up causes an infinite loop // Not having a value to look up causes an infinite loop
if(!search[j]) continue; if(!search[j]) continue;
@ -885,6 +886,7 @@ export class et2_selectAccount_ro extends et2_link_string
if(this.options.select_options[i].value == search[j]) if(this.options.select_options[i].value == search[j])
{ {
this.list.append("<li>"+this.options.select_options[i].label+"</li>"); this.list.append("<li>"+this.options.select_options[i].label+"</li>");
found = true;
break; break;
} }
} }
@ -892,6 +894,16 @@ export class et2_selectAccount_ro extends et2_link_string
} }
} }
} }
// if nothing found in select-options let link widget try
if(!found && !isNaN(_value))
{
super.set_value(_value);
// Don't make it look like a link though
jQuery('li',this.list).removeClass("et2_link et2_link_string")
// No clicks either
.off();
return;
}
} }
} }
et2_register_widget(et2_selectAccount_ro, ["select-account_ro"]); et2_register_widget(et2_selectAccount_ro, ["select-account_ro"]);