From 8cc7adee3f79d1926d4deb49a4f6e8a2d26763bf Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Sun, 4 Aug 2024 14:07:11 +0300 Subject: [PATCH] ref --- .../fields/target-type.js | 17 ++- .../action-history-record/fields/target.js | 55 +++---- .../action-history-record/modals/detail.js | 16 +- .../action-history-record/record/list.js | 12 +- client/src/views/address-map/view.js | 138 +++++++++--------- client/src/views/api-user/list.js | 21 +-- client/src/views/attachment/fields/name.js | 27 ++-- client/src/views/attachment/fields/parent.js | 61 ++++---- client/src/views/attachment/modals/detail.js | 9 +- .../src/views/attachment/modals/select-one.js | 52 ++++--- client/src/views/attachment/record/detail.js | 9 +- client/src/views/attachment/record/list.js | 11 +- .../authentication-provider/fields/method.js | 31 ++-- .../authentication-provider/record/detail.js | 50 +++---- .../authentication-provider/record/edit.js | 50 +++---- client/src/views/fields/link-parent.js | 6 + 16 files changed, 284 insertions(+), 281 deletions(-) diff --git a/client/src/views/action-history-record/fields/target-type.js b/client/src/views/action-history-record/fields/target-type.js index adc75ffdeb..aecd93d191 100644 --- a/client/src/views/action-history-record/fields/target-type.js +++ b/client/src/views/action-history-record/fields/target-type.js @@ -26,13 +26,14 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -define('views/action-history-record/fields/target-type', ['views/fields/enum'], function (Dep) { +import EnumFieldView from 'views/fields/enum'; - return Dep.extend({ +export default class extends EnumFieldView { + + setupOptions() { + super.setupOptions(); + + this.params.options = this.getMetadata().getScopeEntityList(); + } +} - setupOptions: function () { - Dep.prototype.setupOptions.call(this); - this.params.options = this.getMetadata().getScopeEntityList(); - }, - }); -}); diff --git a/client/src/views/action-history-record/fields/target.js b/client/src/views/action-history-record/fields/target.js index cd09cfd73b..1acd7b579c 100644 --- a/client/src/views/action-history-record/fields/target.js +++ b/client/src/views/action-history-record/fields/target.js @@ -26,38 +26,43 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -define('views/action-history-record/fields/target', ['views/fields/link-parent'], function (Dep) { +import LinkParentFieldView from 'views/fields/link-parent'; - return Dep.extend({ +class ActionHistoryRecordTargetFieldView extends LinkParentFieldView +{ + displayScopeColorInListMode = true - displayScopeColorInListMode: true, + ignoreScopeList = [ + 'Preferences', + 'ExternalAccount', + 'Notification', + 'Note', + 'ArrayValue', + ] - ignoreScopeList: ['Preferences', 'ExternalAccount', 'Notification', 'Note', 'ArrayValue'], + setup() { + super.setup(); - setup: function () { - Dep.prototype.setup.call(this); + this.foreignScopeList = this.getMetadata().getScopeEntityList().filter(item => { + if (!this.getUser().isAdmin() && !this.getAcl().checkScopeHasAcl(item)) { + return false; + } - this.foreignScopeList = this.getMetadata().getScopeEntityList().filter(item => { - if (!this.getUser().isAdmin()) { - if (!this.getAcl().checkScopeHasAcl(item)) { - return; - } - } + if (this.ignoreScopeList.includes(item)) { + return false; + } - if (~this.ignoreScopeList.indexOf(item)) { - return; - } + if (!this.getAcl().checkScope(item)) { + return false; + } - if (!this.getAcl().checkScope(item)) { - return; - } + return true; + }); - return true; - }); + this.getLanguage().sortEntityList(this.foreignScopeList); - this.getLanguage().sortEntityList(this.foreignScopeList); + this.foreignScope = this.model.get(this.typeName) || this.foreignScopeList[0]; + } +} - this.foreignScope = this.model.get(this.typeName) || this.foreignScopeList[0]; - }, - }); -}); +export default ActionHistoryRecordTargetFieldView; diff --git a/client/src/views/action-history-record/modals/detail.js b/client/src/views/action-history-record/modals/detail.js index e65b387f62..996cadeceb 100644 --- a/client/src/views/action-history-record/modals/detail.js +++ b/client/src/views/action-history-record/modals/detail.js @@ -26,15 +26,11 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -define('views/action-history-record/modals/detail', ['views/modals/detail'], function (Dep) { +import DetailModalView from 'views/modals/detail'; - return Dep.extend({ - - fullFormDisabled: true, - - editDisabled: true, - - sideDisabled: true, - }); -}); +export default class extends DetailModalView { + fullFormDisabled = true + editDisabled = true + sideDisabled = true +} diff --git a/client/src/views/action-history-record/record/list.js b/client/src/views/action-history-record/record/list.js index 8f733c6e95..ce8c337484 100644 --- a/client/src/views/action-history-record/record/list.js +++ b/client/src/views/action-history-record/record/list.js @@ -26,12 +26,10 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -define('views/action-history-record/record/list', ['views/record/list'], function (Dep) { +import ListRecordView from 'views/record/list'; - return Dep.extend({ +export default class extends ListRecordView { - rowActionsView: 'views/record/row-actions/view-and-remove', - - massActionList: ['remove', 'export'], - }); -}); + rowActionsView = 'views/record/row-actions/view-and-remove' + massActionList = ['remove', 'export'] +} diff --git a/client/src/views/address-map/view.js b/client/src/views/address-map/view.js index 573d958cb3..a2a9348499 100644 --- a/client/src/views/address-map/view.js +++ b/client/src/views/address-map/view.js @@ -26,90 +26,92 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -define('views/address-map/view', ['views/main'], function (Dep) { +import MainView from 'views/main'; - return Dep.extend({ +class AddressMapView extends MainView { - templateContent: ` - -
{{{map}}}
- `, + templateContent = ` + +
{{{map}}}
+ ` - setup: function () { - this.scope = this.model.entityType; + setup() { + this.scope = this.model.entityType; - this.createView('header', 'views/header', { - model: this.model, - fullSelector: '#main > .header', - scope: this.model.entityType, - fontSizeFlexible: true, - }); - }, + this.createView('header', 'views/header', { + model: this.model, + fullSelector: '#main > .header', + scope: this.model.entityType, + fontSizeFlexible: true, + }); + } - afterRender: function () { - var field = this.options.field; + afterRender() { + const field = this.options.field; - var viewName = this.model.getFieldParam(field + 'Map', 'view') || - this.getFieldManager().getViewName('map'); + const viewName = this.model.getFieldParam(field + 'Map', 'view') || + this.getFieldManager().getViewName('map'); - this.createView('map', viewName, { - model: this.model, - name: field + 'Map', - selector: '.map-container', - height: this.getHelper().calculateContentContainerHeight(this.$el.find('.map-container')), - }, (view) => { - view.render(); - }); - }, + this.createView('map', viewName, { + model: this.model, + name: field + 'Map', + selector: '.map-container', + height: this.getHelper().calculateContentContainerHeight(this.$el.find('.map-container')), + }, view => { + view.render(); + }); + } - getHeader: function () { - let name = this.model.get('name'); + getHeader() { + let name = this.model.get('name'); - if (!name) { - name = this.model.id; - } + if (!name) { + name = this.model.id; + } - let recordUrl = '#' + this.model.entityType + '/view/' + this.model.id - let scopeLabel = this.getLanguage().translate(this.model.entityType, 'scopeNamesPlural'); - let fieldLabel = this.translate(this.options.field, 'fields', this.model.entityType); - let rootUrl = this.options.rootUrl || - this.options.params.rootUrl || - '#' + this.model.entityType; + const recordUrl = `#${this.model.entityType}/view/${this.model.id}`; + const scopeLabel = this.getLanguage().translate(this.model.entityType, 'scopeNamesPlural'); + const fieldLabel = this.translate(this.options.field, 'fields', this.model.entityType); - let $name = $('') - .attr('href', recordUrl) - .append( - $('') + const rootUrl = this.options.rootUrl || + this.options.params.rootUrl || + '#' + this.model.entityType; + + const $name = $('') + .attr('href', recordUrl) + .append( + $('') .addClass('font-size-flexible title') .text(name) - ); + ); - if (this.model.get('deleted')) { - $name.css('text-decoration', 'line-through'); - } + if (this.model.get('deleted')) { + $name.css('text-decoration', 'line-through'); + } - let $root = $('') - .append( - $('') - .attr('href', rootUrl) - .addClass('action') - .attr('data-action', 'navigateToRoot') - .text(scopeLabel) - ); + const $root = $('') + .append( + $('') + .attr('href', rootUrl) + .addClass('action') + .attr('data-action', 'navigateToRoot') + .text(scopeLabel) + ); - let headerIconHtml = this.getHeaderIconHtml(); + const headerIconHtml = this.getHeaderIconHtml(); - if (headerIconHtml) { - $root.prepend(headerIconHtml); - } + if (headerIconHtml) { + $root.prepend(headerIconHtml); + } - let $field = $('').text(fieldLabel) + const $field = $('').text(fieldLabel); - return this.buildHeaderHtml([ - $root, - $name, - $field, - ]); - }, - }); -}); + return this.buildHeaderHtml([ + $root, + $name, + $field, + ]); + } +} + +export default AddressMapView diff --git a/client/src/views/api-user/list.js b/client/src/views/api-user/list.js index f05c9d119c..1235bdf5f3 100644 --- a/client/src/views/api-user/list.js +++ b/client/src/views/api-user/list.js @@ -26,18 +26,13 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -define('views/api-user/list', ['views/list'], function (Dep) { +import ListView from 'views/list'; - return Dep.extend({ +export default class extends ListView { - setup: function () { - Dep.prototype.setup.call(this); - }, - - getCreateAttributes: function () { - return { - type: 'api', - }; - }, - }); -}); + getCreateAttributes() { + return { + type: 'api', + }; + } +} diff --git a/client/src/views/attachment/fields/name.js b/client/src/views/attachment/fields/name.js index a97f2fbaaa..419c59ef74 100644 --- a/client/src/views/attachment/fields/name.js +++ b/client/src/views/attachment/fields/name.js @@ -26,24 +26,23 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -define('views/attachment/fields/name', ['views/fields/varchar'], function (Dep) { +import VarcharFieldView from 'views/fields/varchar'; - return Dep.extend({ +export default class extends VarcharFieldView { - detailTemplate: 'attachment/fields/name/detail', + detailTemplate = 'attachment/fields/name/detail' - data: function () { - var data = Dep.prototype.data.call(this); + data() { + const data = super.data(); - var url = this.getBasePath() + '?entryPoint=download&id=' + this.model.id; + let url = this.getBasePath() + '?entryPoint=download&id=' + this.model.id; - if (this.getUser().get('portalId')) { - url += '&portalId=' + this.getUser().get('portalId'); - } + if (this.getUser().get('portalId')) { + url += '&portalId=' + this.getUser().get('portalId'); + } - data.url = url; + data.url = url; - return data; - }, - }); -}); + return data; + } +} diff --git a/client/src/views/attachment/fields/parent.js b/client/src/views/attachment/fields/parent.js index 25b29b259e..cefefd043f 100644 --- a/client/src/views/attachment/fields/parent.js +++ b/client/src/views/attachment/fields/parent.js @@ -26,45 +26,42 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -define('views/attachment/fields/parent', ['views/fields/link-parent'], function (Dep) { +import LinkParentFieldView from 'views/fields/link-parent'; - return Dep.extend({ +export default class extends LinkParentFieldView { - ignoreScopeList: [ - 'Preferences', - 'ExternalAccount', - 'Notification', - 'Note', - 'ArrayValue', - 'Attachment', - ], + ignoreScopeList = [ + 'Preferences', + 'ExternalAccount', + 'Notification', + 'Note', + 'ArrayValue', + 'Attachment', + ] - displayEntityType: true, + displayEntityType = true - setup: function () { - Dep.prototype.setup.call(this); + setup() { + super.setup(); - this.foreignScopeList = this.getMetadata().getScopeEntityList().filter(item => { - if (!this.getUser().isAdmin()) { - if (!this.getAcl().checkScopeHasAcl(item)) { - return; - } - } + this.foreignScopeList = this.getMetadata().getScopeEntityList().filter(item => { + if (!this.getUser().isAdmin() && !this.getAcl().checkScopeHasAcl(item)) { + return false; + } - if (~this.ignoreScopeList.indexOf(item)) { - return; - } + if (this.ignoreScopeList.includes(item)) { + return false; + } - if (!this.getAcl().checkScope(item)) { - return; - } + if (!this.getAcl().checkScope(item)) { + return false; + } - return true; - }); + return true; + }); - this.getLanguage().sortEntityList(this.foreignScopeList); + this.getLanguage().sortEntityList(this.foreignScopeList); - this.foreignScope = this.model.get(this.typeName) || this.foreignScopeList[0]; - }, - }); -}); + this.foreignScope = this.model.get(this.typeName) || this.foreignScopeList[0]; + } +} diff --git a/client/src/views/attachment/modals/detail.js b/client/src/views/attachment/modals/detail.js index 2aa6f2b32c..0ca5aa7c4d 100644 --- a/client/src/views/attachment/modals/detail.js +++ b/client/src/views/attachment/modals/detail.js @@ -26,10 +26,9 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -define('views/attachment/modals/detail', ['views/modals/detail'], function (Dep) { +import DetailModalView from 'views/modals/detail'; - return Dep.extend({ +export default class extends DetailModalView { - editDisabled: true, - }); -}); + editDisabled = true +} diff --git a/client/src/views/attachment/modals/select-one.js b/client/src/views/attachment/modals/select-one.js index 796cb11f92..503b775ac7 100644 --- a/client/src/views/attachment/modals/select-one.js +++ b/client/src/views/attachment/modals/select-one.js @@ -26,31 +26,39 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -define('views/attachment/modals/select-one', ['views/modal'], function (Dep) { +import ModalView from 'views/modal'; - return Dep.extend({ +export default class extends ModalView { - backdrop: true, + backdrop = true - // language=Handlebars - templateContent: - '', + // language=Handlebars + templateContent = + ` + ` - setup: function () { - this.headerText = this.translate('Select'); + setup() { + this.headerText = this.translate('Select'); - if (this.options.fieldLabel) { - this.headerText += ': ' + this.options.fieldLabel; - } - }, + if (this.options.fieldLabel) { + this.headerText += ': ' + this.options.fieldLabel; + } + } - actionSelect: function (data) { - this.trigger('select', data.id); - this.remove(); - }, - }); -}); + // noinspection JSUnusedGlobalSymbols + actionSelect(data) { + this.trigger('select', data.id); + + this.remove(); + } +} diff --git a/client/src/views/attachment/record/detail.js b/client/src/views/attachment/record/detail.js index 1519acc767..fb0aa6e1dd 100644 --- a/client/src/views/attachment/record/detail.js +++ b/client/src/views/attachment/record/detail.js @@ -26,10 +26,9 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -define('views/attachment/record/detail', ['views/record/detail'], function (Dep) { +import DetailRecordView from 'views/record/detail'; - return Dep.extend({ +export default class extends DetailRecordView { - readOnly: true, - }); -}); + readOnly = true +} diff --git a/client/src/views/attachment/record/list.js b/client/src/views/attachment/record/list.js index fb703cd773..f89fcbcdd0 100644 --- a/client/src/views/attachment/record/list.js +++ b/client/src/views/attachment/record/list.js @@ -26,11 +26,10 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -define('views/attachment/record/list', ['views/record/list'], function (Dep) { +import ListRecordView from 'views/record/list'; - return Dep.extend({ +export default class extends ListRecordView { - rowActionsView: 'views/record/row-actions/view-and-remove', - massActionList: ['remove'], - }); -}); + rowActionsView = 'views/record/row-actions/view-and-remove' + massActionList = ['remove'] +} diff --git a/client/src/views/authentication-provider/fields/method.js b/client/src/views/authentication-provider/fields/method.js index be38086aa5..a18636b32d 100644 --- a/client/src/views/authentication-provider/fields/method.js +++ b/client/src/views/authentication-provider/fields/method.js @@ -26,25 +26,24 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -define('views/authentication-provider/fields/method', ['views/fields/enum'], function (Dep) { +import EnumFieldView from 'views/fields/enum'; - return Dep.extend({ +export default class extends EnumFieldView { - setupOptions: function () { - /** @var {Object.>} defs */ - let defs = this.getMetadata().get(['authenticationMethods']) || {}; + setupOptions() { + /** @var {Object.>} defs */ + const defs = this.getMetadata().get(['authenticationMethods']) || {}; - let options = Object.keys(defs) - .filter(item => { - /** @var {Object.} */ - let data = defs[item].provider || {}; + const options = Object.keys(defs) + .filter(item => { + /** @var {Record} */ + const data = defs[item].provider || {}; - return data.isAvailable; - }); + return data.isAvailable; + }); - options.unshift(''); + options.unshift(''); - this.params.options = options; - }, - }); -}); + this.params.options = options; + } +} diff --git a/client/src/views/authentication-provider/record/detail.js b/client/src/views/authentication-provider/record/detail.js index 7a301e413a..e9489c611d 100644 --- a/client/src/views/authentication-provider/record/detail.js +++ b/client/src/views/authentication-provider/record/detail.js @@ -26,37 +26,37 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -define('views/authentication-provider/record/detail', ['views/record/detail', 'helpers/misc/authentication-provider'], -function (Dep, Helper) { +import DetailRecordView from 'views/record/detail'; +import Helper from 'helpers/misc/authentication-provider'; - return Dep.extend({ +export default class extends DetailRecordView { - editModeDisabled: true, + editModeDisabled = true - /** - * @private - * @type {module:helpers/misc/authentication-provider.Class} - */ - helper: null, + /** + * @private + * @type {Helper} + */ + helper - setup: function () { - this.helper = new Helper(this); + setup() { + this.helper = new Helper(this); - Dep.prototype.setup.call(this); - }, + super.setup(); + } - setupBeforeFinal: function () { - this.dynamicLogicDefs = this.helper.setupMethods(); + setupBeforeFinal() { + this.dynamicLogicDefs = this.helper.setupMethods(); - Dep.prototype.setupBeforeFinal.call(this); + super.setupBeforeFinal(); - this.helper.setupPanelsVisibility(() => { - this.processDynamicLogic(); - }); - }, + this.helper.setupPanelsVisibility(() => { + this.processDynamicLogic(); + }); + } - modifyDetailLayout: function (layout) { - this.helper.modifyDetailLayout(layout); - }, - }); -}); + // noinspection JSUnusedGlobalSymbols + modifyDetailLayout(layout) { + this.helper.modifyDetailLayout(layout); + } +} diff --git a/client/src/views/authentication-provider/record/edit.js b/client/src/views/authentication-provider/record/edit.js index 370007e7c5..7a897b59d4 100644 --- a/client/src/views/authentication-provider/record/edit.js +++ b/client/src/views/authentication-provider/record/edit.js @@ -26,37 +26,37 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -define('views/authentication-provider/record/edit', ['views/record/edit', 'helpers/misc/authentication-provider'], -function (Dep, Helper) { +import Helper from 'helpers/misc/authentication-provider'; +import EditRecordView from 'views/record/edit'; - return Dep.extend({ +export default class extends EditRecordView { - saveAndNewAction: false, + saveAndNewAction = false - /** - * @private - * @type {module:helpers/misc/authentication-provider} - */ - helper: null, + /** + * @private + * @type {Helper} + */ + helper - setup: function () { - this.helper = new Helper(this); + setup() { + this.helper = new Helper(this); - Dep.prototype.setup.call(this); - }, + super.setup(); + } - setupBeforeFinal: function () { - this.dynamicLogicDefs = this.helper.setupMethods(); + setupBeforeFinal() { + this.dynamicLogicDefs = this.helper.setupMethods(); - Dep.prototype.setupBeforeFinal.call(this); + super.setupBeforeFinal(); - this.helper.setupPanelsVisibility(() => { - this.processDynamicLogic(); - }); - }, + this.helper.setupPanelsVisibility(() => { + this.processDynamicLogic(); + }); + } - modifyDetailLayout: function (layout) { - this.helper.modifyDetailLayout(layout); - }, - }); -}); + // noinspection JSUnusedGlobalSymbols + modifyDetailLayout(layout) { + this.helper.modifyDetailLayout(layout); + } +} diff --git a/client/src/views/fields/link-parent.js b/client/src/views/fields/link-parent.js index bc69d6666a..8941bb235f 100644 --- a/client/src/views/fields/link-parent.js +++ b/client/src/views/fields/link-parent.js @@ -202,6 +202,12 @@ class LinkParentFieldView extends BaseFieldView { */ displayScopeColorInListMode = true + /** + * @protected + * @type {boolean} + */ + displayEntityType + /** @inheritDoc */ events = { /** @this LinkParentFieldView */