From 094f39e987f3a4a6ebbe9278fa97fa16bdd6400d Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Wed, 3 Dec 2014 12:03:17 +0200 Subject: [PATCH 1/2] fix settings array fields --- .../metadata/entityDefs/Settings.json | 11 +++-- .../Resources/metadata/fields/multiEnum.json | 5 +++ .../client/src/views/admin/outbound-email.js | 3 -- .../client/src/views/admin/user-interface.js | 24 ++--------- ...ignment-email-notifications-entity-list.js | 40 +++++++++++++++++++ .../settings/fields/quick-create-list.js | 39 ++++++++++++++++++ .../src/views/settings/fields/tab-list.js | 39 ++++++++++++++++++ 7 files changed, 134 insertions(+), 27 deletions(-) create mode 100644 frontend/client/src/views/settings/fields/assignment-email-notifications-entity-list.js create mode 100644 frontend/client/src/views/settings/fields/quick-create-list.js create mode 100644 frontend/client/src/views/settings/fields/tab-list.js diff --git a/application/Espo/Resources/metadata/entityDefs/Settings.json b/application/Espo/Resources/metadata/entityDefs/Settings.json index ae1112b058..f981e2ef4a 100644 --- a/application/Espo/Resources/metadata/entityDefs/Settings.json +++ b/application/Espo/Resources/metadata/entityDefs/Settings.json @@ -113,16 +113,18 @@ }, "tabList": { "type": "array", - "translation": "Global.scopeNamesPlural" + "translation": "Global.scopeNamesPlural", + "view": "Settings.Fields.TabList" }, "quickCreateList": { "type": "array", - "translation": "Global.scopeNames" + "translation": "Global.scopeNames", + "view": "Settings.Fields.QuickCreateList" }, "language": { "type": "enum", "options": ["en_US"], - "default": "en_US" + "default": "en_US" }, "exportDelimiter": { "type": "varchar", @@ -204,7 +206,8 @@ }, "assignmentEmailNotificationsEntityList": { "type": "multiEnum", - "translation": "Global.scopeNamesPlural" + "translation": "Global.scopeNamesPlural", + "view": "Settings.Fields.AssignmentEmailNotificationsEntityList" }, "b2cMode": { "type": "bool", diff --git a/application/Espo/Resources/metadata/fields/multiEnum.json b/application/Espo/Resources/metadata/fields/multiEnum.json index f1bf6dcfdc..319eaa78cf 100644 --- a/application/Espo/Resources/metadata/fields/multiEnum.json +++ b/application/Espo/Resources/metadata/fields/multiEnum.json @@ -8,6 +8,11 @@ { "name":"options", "type":"array" + }, + { + "name":"translation", + "type":"varchar", + "hidden": true } ], "filter": false, diff --git a/frontend/client/src/views/admin/outbound-email.js b/frontend/client/src/views/admin/outbound-email.js index 8d94b92c29..5dcccdaeb3 100644 --- a/frontend/client/src/views/admin/outbound-email.js +++ b/frontend/client/src/views/admin/outbound-email.js @@ -63,9 +63,6 @@ Espo.define('Views.Admin.OutboundEmail', 'Views.Settings.Record.Edit', function setup: function () { Dep.prototype.setup.call(this); - this.model.defs.fields.assignmentEmailNotificationsEntityList.options = Object.keys(this.getMetadata().get('scopes')).filter(function (scope) { - return this.getMetadata().get('scopes.' + scope + '.tab') && this.getMetadata().get('scopes.' + scope + '.entity'); - }, this); }, afterRender: function () { diff --git a/frontend/client/src/views/admin/user-interface.js b/frontend/client/src/views/admin/user-interface.js index a988d7645b..19f1730a50 100644 --- a/frontend/client/src/views/admin/user-interface.js +++ b/frontend/client/src/views/admin/user-interface.js @@ -17,31 +17,15 @@ * * 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.UserInterface', 'Views.Settings.Record.Edit', function (Dep) { +Espo.define('Views.Admin.UserInterface', 'Views.Settings.Record.Edit', function (Dep) { return Dep.extend({ - layoutName: 'userInterface', - - setup: function () { - Dep.prototype.setup.call(this); + layoutName: 'userInterface', - this.model.defs.fields.tabList.options = Object.keys(this.getMetadata().get('scopes')).filter(function (scope) { - return this.getMetadata().get('scopes.' + scope + '.tab'); - }, this).sort(function (v1, v2) { - return this.translate(v1, 'scopeNamesPlural').localeCompare(this.translate(v2, 'scopeNamesPlural')); - }.bind(this)); - - this.model.defs.fields.quickCreateList.options = Object.keys(this.getMetadata().get('scopes')).filter(function (scope) { - return this.getMetadata().get('scopes.' + scope + '.entity') && this.getMetadata().get('scopes.' + scope + '.tab'); - }, this).sort(function (v1, v2) { - return this.translate(v1, 'scopeNamesPlural').localeCompare(this.translate(v2, 'scopeNamesPlural')); - }.bind(this)); - }, - - }); + }); }); diff --git a/frontend/client/src/views/settings/fields/assignment-email-notifications-entity-list.js b/frontend/client/src/views/settings/fields/assignment-email-notifications-entity-list.js new file mode 100644 index 0000000000..22b93a7c6e --- /dev/null +++ b/frontend/client/src/views/settings/fields/assignment-email-notifications-entity-list.js @@ -0,0 +1,40 @@ +/************************************************************************ + * 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.Settings.Fields.AssignmentEmailNotificationsEntityList', 'Views.Fields.MultiEnum', function (Dep) { + + return Dep.extend({ + + setup: function () { + + this.params.options = Object.keys(this.getMetadata().get('scopes')).filter(function (scope) { + return this.getMetadata().get('scopes.' + scope + '.tab') && this.getMetadata().get('scopes.' + scope + '.entity'); + }, this).sort(function (v1, v2) { + return this.translate(v1, 'scopeNamesPlural').localeCompare(this.translate(v2, 'scopeNamesPlural')); + }.bind(this)); + + Dep.prototype.setup.call(this); + + console.log(this.translatedOptions); + }, + + }); + +}); diff --git a/frontend/client/src/views/settings/fields/quick-create-list.js b/frontend/client/src/views/settings/fields/quick-create-list.js new file mode 100644 index 0000000000..1876762651 --- /dev/null +++ b/frontend/client/src/views/settings/fields/quick-create-list.js @@ -0,0 +1,39 @@ +/************************************************************************ + * 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.Settings.Fields.QuickCreateList', 'Views.Fields.Array', function (Dep) { + + return Dep.extend({ + + setup: function () { + + this.params.options = Object.keys(this.getMetadata().get('scopes')).filter(function (scope) { + return this.getMetadata().get('scopes.' + scope + '.entity') && this.getMetadata().get('scopes.' + scope + '.tab'); + }, this).sort(function (v1, v2) { + return this.translate(v1, 'scopeNamesPlural').localeCompare(this.translate(v2, 'scopeNamesPlural')); + }.bind(this)); + + Dep.prototype.setup.call(this); + }, + + + }); + +}); diff --git a/frontend/client/src/views/settings/fields/tab-list.js b/frontend/client/src/views/settings/fields/tab-list.js new file mode 100644 index 0000000000..63d5ead258 --- /dev/null +++ b/frontend/client/src/views/settings/fields/tab-list.js @@ -0,0 +1,39 @@ +/************************************************************************ + * 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.Settings.Fields.TabList', 'Views.Fields.Array', function (Dep) { + + return Dep.extend({ + + setup: function () { + + this.params.options = Object.keys(this.getMetadata().get('scopes')).filter(function (scope) { + return this.getMetadata().get('scopes.' + scope + '.tab'); + }, this).sort(function (v1, v2) { + return this.translate(v1, 'scopeNamesPlural').localeCompare(this.translate(v2, 'scopeNamesPlural')); + }.bind(this)); + + Dep.prototype.setup.call(this); + }, + + + }); + +}); From c05a153719282924ca592527792a452538863bac Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Wed, 3 Dec 2014 12:04:01 +0200 Subject: [PATCH 2/2] cleanup --- .../fields/assignment-email-notifications-entity-list.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/frontend/client/src/views/settings/fields/assignment-email-notifications-entity-list.js b/frontend/client/src/views/settings/fields/assignment-email-notifications-entity-list.js index 22b93a7c6e..02f2ccf385 100644 --- a/frontend/client/src/views/settings/fields/assignment-email-notifications-entity-list.js +++ b/frontend/client/src/views/settings/fields/assignment-email-notifications-entity-list.js @@ -31,8 +31,6 @@ Espo.define('Views.Settings.Fields.AssignmentEmailNotificationsEntityList', 'Vie }.bind(this)); Dep.prototype.setup.call(this); - - console.log(this.translatedOptions); }, });