fix validate tab list unique

This commit is contained in:
Yuri Kuznetsov
2022-08-05 09:17:36 +03:00
parent 522e9be624
commit 01cc896972
@@ -40,6 +40,8 @@ define('views/preferences/fields/dashboard-tab-list', ['views/fields/array'], fu
list.forEach(value => {
this.translatedOptions[value] = value;
});
this.validations.push('uniqueLabel');
},
getItemHtml: function (value) {
@@ -85,6 +87,28 @@ define('views/preferences/fields/dashboard-tab-list', ['views/fields/array'], fu
.get(0).outerHTML;
},
validateUniqueLabel: function () {
let keyList = this.model.get(this.name) || [];
let labels = this.model.get('translatedOptions') || {};
let metLabelList = [];
for (let key of keyList) {
let label = labels[key];
if (!label) {
return true;
}
if (metLabelList.indexOf(label) !== -1) {
return true;
}
metLabelList.push(label);
}
return false;
},
fetch: function () {
let data = Dep.prototype.fetch.call(this);