Enum is Sorted

This commit is contained in:
yuri
2015-08-03 11:43:49 +03:00
parent b7e0a0de23
commit c5ccf8e6da
4 changed files with 20 additions and 3 deletions
@@ -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",
+11
View File
@@ -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 () {