Skip to content

Commit

Permalink
Fixed extensible enum options order in fields
Browse files Browse the repository at this point in the history
  • Loading branch information
rzablodskyi committed Jan 10, 2025
1 parent db4c4fe commit b209d7f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 32 deletions.
28 changes: 11 additions & 17 deletions client/src/views/fields/extensible-enum-dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,18 @@ Espo.define('views/fields/extensible-enum-dropdown', 'views/fields/link-dropdown
return data;
},

getWhereFilter() {
let boolWhere = {
type: 'bool',
value:['onlyForExtensibleEnum'],
data:{
'onlyForExtensibleEnum': this.getExtensibleEnumId()
prepareOptionsList: function () {
this.params.options = [];
this.translatedOptions = {};
this.params.optionColors = [];

this.getListOptionsData(this.getExtensibleEnumId()).forEach(option => {
if (option.id) {
this.params.options.push(option.id);
this.translatedOptions[option.id] = option.name || option.id;
this.params.optionColors.push(option.color || null);
}
};

if( Array.isArray(this.selectBoolFilterList) && this.selectBoolFilterList.length > 0) {
boolWhere.value.push(...this.selectBoolFilterList);
}

let boolData = this.getBoolFilterData();
if (boolData && Object.keys(boolData).length > 0) {
boolWhere.data = {...boolWhere.data, ...boolData}
}
return [boolWhere];
})
}
});
});
36 changes: 21 additions & 15 deletions client/src/views/fields/extensible-multi-enum-dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,30 @@ Espo.define('views/fields/extensible-multi-enum-dropdown', 'views/fields/link-mu
return data;
},

getWhereFilter() {
let boolWhere = {
type: 'bool',
value:['onlyForExtensibleEnum'],
data:{
'onlyForExtensibleEnum': this.getExtensibleEnumId()
}
};
prepareOptionsList: function () {
this.params.options = [];
this.translatedOptions = {};
this.params.optionColors = [];

if( Array.isArray(this.selectBoolFilterList) && this.selectBoolFilterList.length > 0) {
boolWhere.value.push(...this.selectBoolFilterList);
}
this.getListOptionsData(this.getExtensibleEnumId()).forEach(option => {
if (option.id) {
this.params.options.push(option.id);
this.translatedOptions[option.id] = option.name || option.id;
this.params.optionColors.push(option.color || null);
}
})

let boolData = this.getBoolFilterData();
if (boolData && Object.keys(boolData).length > 0) {
boolWhere.data = {...boolWhere.data, ...boolData}
if(this.mode === 'edit') {
let newValues = [];
(this.model.get(this.idsName) ?? []).forEach((id) => {
if((this.params.options ?? []).includes(id)){
newValues.push(id);
}
})
if ((this.model.get(this.idsName) ?? []).length !== newValues.length) {
this.model.set(this.idsName, newValues);
}
}
return [boolWhere];
}
});
});

0 comments on commit b209d7f

Please sign in to comment.