From fc24840a7b8bbdf50c59ba56571e60c9635fe6f0 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Tue, 20 Aug 2024 15:43:54 +0300 Subject: [PATCH] ref --- .../src/views/settings/fields/date-format.js | 13 +++-- .../views/settings/fields/default-currency.js | 48 +++++++++---------- .../email-address-lookup-entity-type-list.js | 45 +++++++++-------- .../settings/fields/fiscal-year-shift.js | 26 +++++----- .../fields/global-search-entity-list.js | 38 +++++++-------- .../views/settings/fields/group-tab-list.js | 12 ++--- .../settings/fields/history-entity-list.js | 26 +++++----- client/src/views/settings/fields/language.js | 15 +++--- 8 files changed, 107 insertions(+), 116 deletions(-) diff --git a/client/src/views/settings/fields/date-format.js b/client/src/views/settings/fields/date-format.js index 8dadc0bba0..25c57eb136 100644 --- a/client/src/views/settings/fields/date-format.js +++ b/client/src/views/settings/fields/date-format.js @@ -26,12 +26,11 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -define('views/settings/fields/date-format', ['views/fields/enum'], function (Dep) { +import EnumFieldView from 'views/fields/enum'; - return Dep.extend({ +export default class extends EnumFieldView { - setupOptions: function () { - this.params.options = this.getMetadata().get(['app', 'dateTime', 'dateFormatList']) || []; - }, - }); -}); + setupOptions() { + this.params.options = this.getMetadata().get(['app', 'dateTime', 'dateFormatList']) || []; + } +} diff --git a/client/src/views/settings/fields/default-currency.js b/client/src/views/settings/fields/default-currency.js index 5a7d3e05dc..5dcd435b10 100644 --- a/client/src/views/settings/fields/default-currency.js +++ b/client/src/views/settings/fields/default-currency.js @@ -26,38 +26,38 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -define('views/settings/fields/default-currency', ['views/fields/enum'], function (Dep) { +import EnumFieldView from 'views/fields/enum'; - return Dep.extend({ +export default class extends EnumFieldView { - setup: function () { - Dep.prototype.setup.call(this); + setup() { + super.setup(); - this.validations.push('existing'); - }, + this.validations.push(() => this.validateExisting()); + } - setupOptions: function () { - this.params.options = Espo.Utils.clone(this.getConfig().get('currencyList') || []); - }, + setupOptions() { + this.params.options = Espo.Utils.clone(this.getConfig().get('currencyList') || []); + } - validateExisting: function () { - var currencyList = this.model.get('currencyList'); + validateExisting() { + /** @type {string[]} */ + const currencyList = this.model.get('currencyList'); - if (!currencyList) { - return; - } + if (!currencyList) { + return false; + } - var value = this.model.get(this.name); + const value = this.model.get(this.name); - if (~currencyList.indexOf(value)) { - return; - } + if (currencyList.includes(value)) { + return false; + } - var msg = this.translate('fieldInvalid', 'messages').replace('{field}', this.getLabelText()); + const msg = this.translate('fieldInvalid', 'messages').replace('{field}', this.getLabelText()); - this.showValidationMessage(msg); + this.showValidationMessage(msg); - return true; - }, - }); -}); + return true; + } +} diff --git a/client/src/views/settings/fields/email-address-lookup-entity-type-list.js b/client/src/views/settings/fields/email-address-lookup-entity-type-list.js index 7874e67ff2..161d294354 100644 --- a/client/src/views/settings/fields/email-address-lookup-entity-type-list.js +++ b/client/src/views/settings/fields/email-address-lookup-entity-type-list.js @@ -26,33 +26,32 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -define('views/settings/fields/email-address-lookup-entity-type-list', -['views/fields/entity-type-list'], function (Dep) { +import EntityTypeListFieldView from 'views/fields/entity-type-list'; - return Dep.extend({ +// noinspection JSUnusedGlobalSymbols +export default class extends EntityTypeListFieldView { - setupOptions: function () { - Dep.prototype.setupOptions.call(this); + setupOptions() { + super.setupOptions(); - this.params.options = this.params.options.filter(scope => { - if (this.getMetadata().get(['scopes', scope, 'disabled'])) { - return; - } + this.params.options = this.params.options.filter(scope => { + if (this.getMetadata().get(['scopes', scope, 'disabled'])) { + return; + } - if (!this.getMetadata().get(['scopes', scope, 'object'])) { - return; - } + if (!this.getMetadata().get(['scopes', scope, 'object'])) { + return; + } - if (~['User', 'Contact', 'Lead', 'Account'].indexOf(scope)) { - return true; - } + if (['User', 'Contact', 'Lead', 'Account'].includes(scope)) { + return true; + } - var type = this.getMetadata().get(['scopes', scope, 'type']); + const type = this.getMetadata().get(['scopes', scope, 'type']); - if (type === 'Company' || type === 'Person') { - return true; - } - }) - }, - }); -}); + if (type === 'Company' || type === 'Person') { + return true; + } + }) + } +} diff --git a/client/src/views/settings/fields/fiscal-year-shift.js b/client/src/views/settings/fields/fiscal-year-shift.js index 37f92f8a0f..2c39c3eb72 100644 --- a/client/src/views/settings/fields/fiscal-year-shift.js +++ b/client/src/views/settings/fields/fiscal-year-shift.js @@ -26,20 +26,20 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -define('views/settings/fields/fiscal-year-shift', ['views/fields/enum-int'], function (Dep) { +import EnumIntFieldView from 'views/fields/enum-int'; - return Dep.extend({ +// noinspection JSUnusedGlobalSymbols +export default class extends EnumIntFieldView { - setupOptions: function () { - this.params.options = []; - this.translatedOptions = {}; + setupOptions() { + this.params.options = []; + this.translatedOptions = {}; - var monthNameList = this.getLanguage().get('Global', 'lists', 'monthNames') || []; + const monthNameList = this.getLanguage().get('Global', 'lists', 'monthNames') || []; - monthNameList.forEach((name, i) => { - this.params.options.push(i); - this.translatedOptions[i] = name; - }); - }, - }); -}); + monthNameList.forEach((name, i) => { + this.params.options.push(i); + this.translatedOptions[i] = name; + }); + } +} diff --git a/client/src/views/settings/fields/global-search-entity-list.js b/client/src/views/settings/fields/global-search-entity-list.js index 4246055104..87f65fc134 100644 --- a/client/src/views/settings/fields/global-search-entity-list.js +++ b/client/src/views/settings/fields/global-search-entity-list.js @@ -26,28 +26,26 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -define('views/settings/fields/global-search-entity-list', ['views/fields/multi-enum'], function (Dep) { +import MultiEnumFieldView from 'views/fields/multi-enum'; - return Dep.extend({ +export default class extends MultiEnumFieldView { - setup: function () { + setup() { + this.params.options = Object.keys(this.getMetadata().get('scopes')) + .filter(scope => { + const defs = this.getMetadata().get(['scopes', scope]) || {}; - this.params.options = Object.keys(this.getMetadata().get('scopes')) - .filter(scope => { - let defs = this.getMetadata().get(['scopes', scope]) || {}; + if (defs.disabled || scope === 'Note') { + return; + } - if (defs.disabled || scope === 'Note') { - return; - } + return defs.customizable && defs.entity; + }) + .sort((v1, v2) => { + return this.translate(v1, 'scopeNamesPlural') + .localeCompare(this.translate(v2, 'scopeNamesPlural')); + }); - return defs.customizable && defs.entity; - }) - .sort((v1, v2) => { - return this.translate(v1, 'scopeNamesPlural') - .localeCompare(this.translate(v2, 'scopeNamesPlural')); - }); - - Dep.prototype.setup.call(this); - }, - }); -}); + super.setup(); + } +} diff --git a/client/src/views/settings/fields/group-tab-list.js b/client/src/views/settings/fields/group-tab-list.js index f2bc39c4ac..69498dea0a 100644 --- a/client/src/views/settings/fields/group-tab-list.js +++ b/client/src/views/settings/fields/group-tab-list.js @@ -26,12 +26,10 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -define('views/settings/fields/group-tab-list', ['views/settings/fields/tab-list'], function (Dep) { +import TabListFieldView from 'views/settings/fields/tab-list'; - return Dep.extend({ +export default class extends TabListFieldView { - noGroups: true, - - noDelimiters: true, - }); -}); + noGroups = true + noDelimiters = true +} diff --git a/client/src/views/settings/fields/history-entity-list.js b/client/src/views/settings/fields/history-entity-list.js index a8fffad097..40bb8890cd 100644 --- a/client/src/views/settings/fields/history-entity-list.js +++ b/client/src/views/settings/fields/history-entity-list.js @@ -26,21 +26,19 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -define('views/settings/fields/history-entity-list', ['views/fields/entity-type-list'], function (Dep) { +import EntityTypeListFieldView from 'views/fields/entity-type-list'; - return Dep.extend({ +export default class extends EntityTypeListFieldView { - setupOptions: function () { + setupOptions() { + super.setupOptions(); - Dep.prototype.setupOptions.call(this); + this.params.options = this.params.options.filter(scope => { + if (this.getMetadata().get('scopes.' + scope + '.disabled')) return; + if (!this.getMetadata().get('scopes.' + scope + '.object')) return; + if (!this.getMetadata().get('scopes.' + scope + '.activity')) return; - this.params.options = this.params.options.filter(scope => { - if (this.getMetadata().get('scopes.' + scope + '.disabled')) return; - if (!this.getMetadata().get('scopes.' + scope + '.object')) return; - if (!this.getMetadata().get('scopes.' + scope + '.activity')) return; - - return true; - }) - }, - }); -}); + return true; + }) + } +} diff --git a/client/src/views/settings/fields/language.js b/client/src/views/settings/fields/language.js index e31b56b6d0..3e2b122b67 100644 --- a/client/src/views/settings/fields/language.js +++ b/client/src/views/settings/fields/language.js @@ -26,13 +26,12 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -define('views/settings/fields/language', ['views/fields/enum'], function (Dep) { +import EnumFieldView from 'views/fields/enum'; - return Dep.extend({ +export default class extends EnumFieldView { - setupOptions: function () { - this.params.options = Espo.Utils.clone(this.getMetadata().get(['app', 'language', 'list']) || []); - this.translatedOptions = Espo.Utils.clone(this.getLanguage().translate('language', 'options') || {}); - }, - }); -}); + setupOptions() { + this.params.options = Espo.Utils.clone(this.getMetadata().get(['app', 'language', 'list']) || []); + this.translatedOptions = Espo.Utils.clone(this.getLanguage().translate('language', 'options') || {}); + } +}