diff --git a/application/Espo/Core/Utils/FieldManager.php b/application/Espo/Core/Utils/FieldManager.php
index 27cc6e1730..707e7bfef5 100644
--- a/application/Espo/Core/Utils/FieldManager.php
+++ b/application/Espo/Core/Utils/FieldManager.php
@@ -94,6 +94,12 @@ class FieldManager
$res &= $this->setLabel($name, $fieldDef['label'], $scope);
}
+ if (isset($fieldDef['type']) && $fieldDef['type'] == 'enum') {
+ if (isset($fieldDef['translatedOptions'])) {
+ $res &= $this->setTranslatedOptions($name, $fieldDef['translatedOptions'], $scope);
+ }
+ }
+
if ($this->isDefsChanged($name, $fieldDef, $scope)) {
$res &= $this->setEntityDefs($name, $fieldDef, $scope);
}
@@ -129,6 +135,11 @@ class FieldManager
return $res;
}
+ protected function setTranslatedOptions($name, $value, $scope)
+ {
+ return $this->getLanguage()->set($name, $value, 'options', $scope);
+ }
+
protected function setLabel($name, $value, $scope)
{
return $this->getLanguage()->set($name, $value, 'fields', $scope);
diff --git a/application/Espo/Resources/i18n/de_DE/Admin.json b/application/Espo/Resources/i18n/de_DE/Admin.json
index 1144292ae2..a5ee0dced0 100644
--- a/application/Espo/Resources/i18n/de_DE/Admin.json
+++ b/application/Espo/Resources/i18n/de_DE/Admin.json
@@ -74,7 +74,7 @@
"required": "Erforderlich",
"default": "Standard",
"maxLength": "Maximallänge",
- "options": "Optionen (Datenbank Werte, nicht übersetzt)",
+ "options": "Optionen",
"after": "Nach (Feld)",
"before": "Vor (Feld)",
"link": "Link",
diff --git a/application/Espo/Resources/i18n/en_US/Admin.json b/application/Espo/Resources/i18n/en_US/Admin.json
index ea1d97d205..b0e4abb281 100644
--- a/application/Espo/Resources/i18n/en_US/Admin.json
+++ b/application/Espo/Resources/i18n/en_US/Admin.json
@@ -88,7 +88,7 @@
"required": "Required",
"default": "Default",
"maxLength": "Max Length",
- "options": "Options (raw values, not translated)",
+ "options": "Options",
"after": "After (field)",
"before": "Before (field)",
"link": "Link",
diff --git a/application/Espo/Resources/i18n/es_ES/Admin.json b/application/Espo/Resources/i18n/es_ES/Admin.json
index 3540539fe7..7b9a8da7cd 100644
--- a/application/Espo/Resources/i18n/es_ES/Admin.json
+++ b/application/Espo/Resources/i18n/es_ES/Admin.json
@@ -71,7 +71,7 @@
"required": "Requerido",
"default": "Por Defecto",
"maxLength": "Longitud máxima",
- "options": "Options (raw values, not translated)",
+ "options": "Options",
"after": "After (field)",
"before": "Before (field)",
"link": "Enlace",
diff --git a/application/Espo/Resources/i18n/fr_FR/Admin.json b/application/Espo/Resources/i18n/fr_FR/Admin.json
index fee8dac0aa..da5f330549 100644
--- a/application/Espo/Resources/i18n/fr_FR/Admin.json
+++ b/application/Espo/Resources/i18n/fr_FR/Admin.json
@@ -73,7 +73,7 @@
"required": "Requis",
"default": "Standard",
"maxLength": "Taille Maximum",
- "options": "Options (raw values, not translated)",
+ "options": "Options",
"after": "After (field)",
"before": "Before (field)",
"link": "Lien",
diff --git a/application/Espo/Resources/i18n/nl_NL/Admin.json b/application/Espo/Resources/i18n/nl_NL/Admin.json
index f09b7c1714..53239b54ba 100644
--- a/application/Espo/Resources/i18n/nl_NL/Admin.json
+++ b/application/Espo/Resources/i18n/nl_NL/Admin.json
@@ -87,7 +87,7 @@
"required": "Verplicht",
"default": "Standaard",
"maxLength": "Max Lengte",
- "options": "Opties (ruwe waarden, niet vertaald)",
+ "options": "Opties",
"after": "Achter (veld)",
"before": "Voor (veld)",
"link": "Link",
diff --git a/application/Espo/Resources/i18n/pt_BR/Admin.json b/application/Espo/Resources/i18n/pt_BR/Admin.json
index 9b1286a8f6..0d9ac88d66 100644
--- a/application/Espo/Resources/i18n/pt_BR/Admin.json
+++ b/application/Espo/Resources/i18n/pt_BR/Admin.json
@@ -78,7 +78,7 @@
"required": "Obrigatório",
"default": "Padrão",
"maxLength": "Tamanho máximo",
- "options": "Opções (valores raw, não traduzíveis)",
+ "options": "Opções",
"after": "Antes (field)",
"before": "Após (field)",
"link": "Link",
diff --git a/application/Espo/Resources/i18n/ru_RU/Admin.json b/application/Espo/Resources/i18n/ru_RU/Admin.json
index c55f6662e0..6caf148a9e 100644
--- a/application/Espo/Resources/i18n/ru_RU/Admin.json
+++ b/application/Espo/Resources/i18n/ru_RU/Admin.json
@@ -74,7 +74,7 @@
"required": "Required",
"default": "Default",
"maxLength": "Max Length",
- "options": "Options (raw values, not translated)",
+ "options": "Options",
"after": "After (field)",
"before": "Before (field)",
"link": "Link",
diff --git a/application/Espo/Resources/metadata/fields/enum.json b/application/Espo/Resources/metadata/fields/enum.json
index 0c669276ba..b3236239eb 100644
--- a/application/Espo/Resources/metadata/fields/enum.json
+++ b/application/Espo/Resources/metadata/fields/enum.json
@@ -7,7 +7,8 @@
},
{
"name":"options",
- "type":"array"
+ "type":"array",
+ "view": "Admin.FieldManager.Fields.Options"
},
{
"name":"default",
diff --git a/frontend/client/res/templates/fields/array/edit.tpl b/frontend/client/res/templates/fields/array/edit.tpl
index e86cafd537..39b393e1c5 100644
--- a/frontend/client/res/templates/fields/array/edit.tpl
+++ b/frontend/client/res/templates/fields/array/edit.tpl
@@ -1,13 +1,6 @@
-{{#each selected}}
-
- {{#if ../translatedOptions}}
- {{prop ../../translatedOptions this}}
- {{else}}
- {{./this}}
- {{/if}}
-
-
+{{#each itemHtmlList}}
+ {{{./this}}}
{{/each}}
{{#if hasOptions}}
diff --git a/frontend/client/src/views/admin/field-manager/edit.js b/frontend/client/src/views/admin/field-manager/edit.js
index 1c77e68dd9..4e3d4d2853 100644
--- a/frontend/client/src/views/admin/field-manager/edit.js
+++ b/frontend/client/src/views/admin/field-manager/edit.js
@@ -133,7 +133,8 @@ Espo.define('Views.Admin.FieldManager.Edit', 'View', function (Dep) {
},
createFieldView: function (type, name, readOnly, params) {
- this.createView(name, this.getFieldManager().getViewName(type), {
+ var viewName = (params || {}).view || this.getFieldManager().getViewName(type);
+ this.createView(name, viewName, {
model: this.model,
el: this.options.el + ' .field-' + name,
defs: {
@@ -142,6 +143,8 @@ Espo.define('Views.Admin.FieldManager.Edit', 'View', function (Dep) {
},
mode: readOnly ? 'detail' : 'edit',
readOnly: readOnly,
+ scope: this.scope,
+ field: this.field,
});
this.fieldList.push(name);
},
@@ -175,6 +178,14 @@ Espo.define('Views.Admin.FieldManager.Edit', 'View', function (Dep) {
data[this.scope]['fields'] = {};
}
data[this.scope]['fields'][this.model.get('name')] = this.model.get('label');
+
+
+ if (this.model.get('type') == 'enum' && this.model.get('translatedOptions')) {
+ if (!('options' in data[this.scope])) {
+ data[this.scope]['options'] = {};
+ }
+ data[this.scope]['options'][this.model.get('name')] = this.model.get('translatedOptions') || {};
+ }
}
this.getRouter().navigate('#Admin/fieldManager/scope=' + this.scope + '&field=' + this.model.get('name'), {trigger: true});
diff --git a/frontend/client/src/views/admin/field-manager/fields/options.js b/frontend/client/src/views/admin/field-manager/fields/options.js
new file mode 100644
index 0000000000..7daebface4
--- /dev/null
+++ b/frontend/client/src/views/admin/field-manager/fields/options.js
@@ -0,0 +1,61 @@
+/************************************************************************
+ * This file is part of EspoCRM.
+ *
+ * EspoCRM - Open Source CRM application.
+ * Copyright (C) 2014 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
+ * Website: http://www.espocrm.com
+ *
+ * EspoCRM is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * EspoCRM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with EspoCRM. If not, see http://www.gnu.org/licenses/.
+ ************************************************************************/
+
+Espo.define('Views.Admin.FieldManager.Fields.Options', 'Views.Fields.Array', function (Dep) {
+
+ return Dep.extend({
+
+ setup: function () {
+ Dep.prototype.setup.call(this);
+
+ this.translatedOptions = this.getLanguage().get(this.options.scope, 'options', this.options.field) || {};
+ },
+
+ getItemHtml: function (value) {
+ var translatedValue = this.translatedOptions[value] || value;
+
+ var html = '' +
+ '';
+
+ return html;
+ },
+
+ fetch: function () {
+ var data = Dep.prototype.fetch.call(this);
+ data.translatedOptions = {};
+ (data[this.name] || []).forEach(function (value) {
+ data.translatedOptions[value] = this.$el.find('input[name="translatedValue"][data-value="'+value+'"]').val() || value;
+ }, this);
+
+ return data;
+ },
+
+ });
+
+});
diff --git a/frontend/client/src/views/fields/array.js b/frontend/client/src/views/fields/array.js
index fe53777c3e..2fd955b0b5 100644
--- a/frontend/client/src/views/fields/array.js
+++ b/frontend/client/src/views/fields/array.js
@@ -32,10 +32,16 @@ Espo.define('Views.Fields.Array', 'Views.Fields.Enum', function (Dep) {
editTemplate: 'fields.array.edit',
data: function () {
+ var itemHtmlList = [];
+ (this.selected || []).forEach(function (value) {
+ itemHtmlList.push(this.getItemHtml(value));
+ }, this);
+
return _.extend({
selected: this.selected,
translatedOptions: this.translatedOptions,
- hasOptions: this.params.options ? true : false
+ hasOptions: this.params.options ? true : false,
+ itemHtmlList: itemHtmlList
}, Dep.prototype.data.call(this));
},
@@ -143,8 +149,8 @@ Espo.define('Views.Fields.Array', 'Views.Fields.Enum', function (Dep) {
return item;
}, this).join(', ');
},
-
- addValue: function (value) {
+
+ getItemHtml: function (value) {
if (this.translatedOptions != null) {
for (var item in this.translatedOptions) {
if (this.translatedOptions[item] == value) {
@@ -153,16 +159,21 @@ Espo.define('Views.Fields.Array', 'Views.Fields.Enum', function (Dep) {
}
}
}
-
- if (this.selected.indexOf(value) == -1) {
- var label = value;
- if (this.translatedOptions) {
- label = ((value in this.translatedOptions) ? this.translatedOptions [value]: value);
- }
- var html = '';
+ var label = value;
+ if (this.translatedOptions) {
+ label = ((value in this.translatedOptions) ? this.translatedOptions [value]: value);
+ }
+ var html = '';
+
+ return html;
+ },
+
+ addValue: function (value) {
+ if (this.selected.indexOf(value) == -1) {
+ var html = this.getItemHtml(value);
this.$list.append(html);
this.selected.push(value);
this.trigger('change');