Merge branch 'fix'
This commit is contained in:
@@ -174,7 +174,7 @@ class Collection {
|
||||
parentModel
|
||||
|
||||
/**
|
||||
* @param {Model[]|null} [models] Models.
|
||||
* @param {Model[]|Record<string, *>[]|null} [models] Models.
|
||||
* @param {{
|
||||
* entityType?: string,
|
||||
* model?: Model.prototype,
|
||||
|
||||
@@ -420,7 +420,38 @@ class EmailAddressVarcharFieldView extends BaseFieldView {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} address
|
||||
* @param {string} name
|
||||
* @param {string} [type]
|
||||
* @param {string} [id]
|
||||
*/
|
||||
addAddress(address, name, type, id) {
|
||||
if (name === '') {
|
||||
const nameHash = this.model.attributes.nameHash ?? {};
|
||||
|
||||
if (address in nameHash) {
|
||||
name = nameHash[address];
|
||||
}
|
||||
}
|
||||
|
||||
if (type === undefined) {
|
||||
const typeHash = this.model.attributes.typeHash ?? {};
|
||||
|
||||
if (address in typeHash) {
|
||||
type = typeHash[address];
|
||||
}
|
||||
}
|
||||
|
||||
if (id === undefined) {
|
||||
const idHash = this.model.attributes.idHash ?? {};
|
||||
|
||||
if (address in idHash) {
|
||||
id = idHash[address];
|
||||
}
|
||||
}
|
||||
|
||||
if (this.justAddedAddress) {
|
||||
this.deleteAddress(this.justAddedAddress);
|
||||
}
|
||||
@@ -482,9 +513,9 @@ class EmailAddressVarcharFieldView extends BaseFieldView {
|
||||
|
||||
$text.append(
|
||||
$('<span>').text(name),
|
||||
' ',
|
||||
'<span class="no-select"> </span>',
|
||||
$('<span>').addClass('text-muted middle-dot'),
|
||||
' '
|
||||
'<span class="no-select"> </span>'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -256,6 +256,10 @@ class ArrayFieldView extends BaseFieldView {
|
||||
this.allowCustomOptions = true;
|
||||
}
|
||||
|
||||
if (this.params.allowCustomOptions === false) {
|
||||
this.allowCustomOptions = false;
|
||||
}
|
||||
|
||||
if (this.type === 'array') {
|
||||
this.validations.push('noInputValue')
|
||||
}
|
||||
|
||||
@@ -217,6 +217,13 @@ class LinkFieldView extends BaseFieldView {
|
||||
*/
|
||||
linkClass
|
||||
|
||||
/**
|
||||
* @protected
|
||||
* @type {string}
|
||||
* @since 9.2.5
|
||||
*/
|
||||
foreignNameAttribute
|
||||
|
||||
/** @inheritDoc */
|
||||
events = {
|
||||
/** @this LinkFieldView */
|
||||
@@ -364,6 +371,10 @@ class LinkFieldView extends BaseFieldView {
|
||||
this.model.getFieldParam(this.name, 'entity') ||
|
||||
this.model.getLinkParam(this.name, 'entity');
|
||||
|
||||
this.foreignNameAttribute = this.model.getLinkParam(this.name, 'foreignName') ??
|
||||
this.getMetadata().get(`clientDefs.${this.foreignScope}.nameAttribute`) ??
|
||||
'name';
|
||||
|
||||
if ('createDisabled' in this.options) {
|
||||
this.createDisabled = this.options.createDisabled;
|
||||
}
|
||||
@@ -407,12 +418,12 @@ class LinkFieldView extends BaseFieldView {
|
||||
* @return {Promise|void}
|
||||
*/
|
||||
select(model) {
|
||||
this.$elementName.val(model.get('name') || model.id);
|
||||
this.$elementId.val(model.get('id'));
|
||||
this.$elementName.val(model.get(this.foreignNameAttribute) || model.id);
|
||||
this.$elementId.val(model.id);
|
||||
|
||||
if (this.mode === this.MODE_SEARCH) {
|
||||
this.searchData.idValue = model.get('id');
|
||||
this.searchData.nameValue = model.get('name') || model.id;
|
||||
this.searchData.idValue = model.id;
|
||||
this.searchData.nameValue = model.get(this.foreignNameAttribute) || model.id;
|
||||
}
|
||||
|
||||
this.trigger('change');
|
||||
@@ -611,7 +622,7 @@ class LinkFieldView extends BaseFieldView {
|
||||
if (!this.forceSelectAllAttributes) {
|
||||
const mandatorySelectAttributeList = this.getMandatorySelectAttributeList();
|
||||
|
||||
let select = ['id', 'name'];
|
||||
let select = ['id', this.foreignNameAttribute];
|
||||
|
||||
if (mandatorySelectAttributeList) {
|
||||
select = select.concat(mandatorySelectAttributeList);
|
||||
@@ -824,12 +835,20 @@ class LinkFieldView extends BaseFieldView {
|
||||
const list = [];
|
||||
|
||||
response.list.forEach(item => {
|
||||
const name = item[this.foreignNameAttribute] || item.name || item.id;
|
||||
|
||||
const attributes = item;
|
||||
|
||||
if (this.foreignNameAttribute !== 'name') {
|
||||
attributes[this.foreignNameAttribute] = name;
|
||||
}
|
||||
|
||||
list.push({
|
||||
id: item.id,
|
||||
name: item.name || item.id,
|
||||
name: name,
|
||||
data: item.id,
|
||||
value: item.name || item.id,
|
||||
attributes: item,
|
||||
value: name,
|
||||
attributes: attributes,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1365,7 +1384,7 @@ class LinkFieldView extends BaseFieldView {
|
||||
*/
|
||||
selectOneOf(models) {
|
||||
models.forEach(model => {
|
||||
this.addLinkOneOf(model.id, model.get('name'));
|
||||
this.addLinkOneOf(model.id, model.get(this.foreignNameAttribute));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,7 +148,11 @@ class EditRecordView extends DetailRecordView {
|
||||
this.wait(promise);
|
||||
|
||||
// @todo Revise. Possible race condition issues.
|
||||
promise.then(() => super.setupBeforeFinal());
|
||||
promise.then(() => {
|
||||
super.setupBeforeFinal();
|
||||
|
||||
this.processDynamicLogic();
|
||||
});
|
||||
}
|
||||
|
||||
if (this.model.isNew()) {
|
||||
|
||||
@@ -938,7 +938,7 @@ class SearchView extends View {
|
||||
|
||||
this.$el
|
||||
.find('ul.filter-menu a.preset[data-name="'+presetName+'"]')
|
||||
.prepend('<span class="fas fa-check pull-right"></span>');
|
||||
.prepend('<span class="fas fa-check check-icon pull-right"></span>');
|
||||
}
|
||||
|
||||
manageBoolFilters() {
|
||||
|
||||
Reference in New Issue
Block a user