fix validate tab list unique
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user