Enum is Sorted
This commit is contained in:
@@ -23,8 +23,8 @@
|
||||
"type": "enum",
|
||||
"options": [
|
||||
"",
|
||||
"Agriculture",
|
||||
"Advertising",
|
||||
"Agriculture",
|
||||
"Apparel & Accessories",
|
||||
"Automotive",
|
||||
"Banking",
|
||||
@@ -52,7 +52,8 @@
|
||||
"Television",
|
||||
"Transportation",
|
||||
"Venture Capital"
|
||||
]
|
||||
],
|
||||
"isSorted": true
|
||||
},
|
||||
"sicCode": {
|
||||
"type": "varchar",
|
||||
|
||||
@@ -106,7 +106,8 @@
|
||||
"noEmptyString": "No Empty String",
|
||||
"defaultType": "Default Type",
|
||||
"seeMoreDisabled": "Disable Text Cut",
|
||||
"entityList": "Entity List"
|
||||
"entityList": "Entity List",
|
||||
"isSorted": "Is Sorted (alphabetically)"
|
||||
},
|
||||
"messages": {
|
||||
"upgradeVersion": "Your EspoCRM will be upgraded to version <strong>{version}</strong>. This can take some time.",
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
"name":"default",
|
||||
"type":"varchar"
|
||||
},
|
||||
{
|
||||
"name":"isSorted",
|
||||
"type":"bool"
|
||||
},
|
||||
{
|
||||
"name":"translation",
|
||||
"type":"varchar",
|
||||
|
||||
@@ -77,6 +77,17 @@ Espo.define('Views.Fields.Enum', ['Views.Fields.Base', 'lib!Selectize'], functio
|
||||
this.translatedOptions = translatedOptions;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.translatedOptions === null) {
|
||||
this.translatedOptions = this.getLanguage().get(this.model.name, 'options', this.name) || {};
|
||||
}
|
||||
|
||||
if (this.params.isSorted && this.translatedOptions) {
|
||||
this.params.options = Espo.Utils.clone(this.params.options);
|
||||
this.params.options = this.params.options.sort(function (v1, v2) {
|
||||
return (this.translatedOptions[v1] || v1).localeCompare(this.translatedOptions[v2] || v2);
|
||||
}.bind(this));
|
||||
}
|
||||
},
|
||||
|
||||
afterRender: function () {
|
||||
|
||||
Reference in New Issue
Block a user