diff --git a/client/src/views/fields/currency-list.js b/client/src/views/fields/currency-list.js index 8c455c3159..71ae100f0a 100644 --- a/client/src/views/fields/currency-list.js +++ b/client/src/views/fields/currency-list.js @@ -26,17 +26,16 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -Espo.define('views/fields/currency-list', 'views/fields/enum', function (Dep) { +define('views/fields/currency-list', ['views/fields/enum'], function (Dep) { return Dep.extend({ setupOptions: function () { this.params.options = []; - (this.getConfig().get('currencyList') || []).forEach(function (item) { + (this.getConfig().get('currencyList') || []).forEach(item => { this.params.options.push(item); - }, this); + }); }, - }); }); diff --git a/client/src/views/global-search/name-field.js b/client/src/views/global-search/name-field.js index 137ede4bbd..c757f678d6 100644 --- a/client/src/views/global-search/name-field.js +++ b/client/src/views/global-search/name-field.js @@ -26,7 +26,7 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -Espo.define('views/global-search/name-field', 'views/fields/base', function (Dep) { +define('views/global-search/name-field', ['views/fields/base'], function (Dep) { return Dep.extend({ @@ -39,7 +39,6 @@ Espo.define('views/global-search/name-field', 'views/fields/base', function (Dep id: this.model.id, iconHtml: this.getHelper().getScopeColorIconHtml(this.model.get('_scope')) }; - } - + }, }); }); diff --git a/client/src/views/global-search/scope-badge.js b/client/src/views/global-search/scope-badge.js index 0b37f72bb3..cd67189a7a 100644 --- a/client/src/views/global-search/scope-badge.js +++ b/client/src/views/global-search/scope-badge.js @@ -26,7 +26,7 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -Espo.define('views/global-search/scope-badge', 'view', function (Dep) { +define('views/global-search/scope-badge', ['view'], function (Dep) { return Dep.extend({ @@ -34,11 +34,8 @@ Espo.define('views/global-search/scope-badge', 'view', function (Dep) { data: function () { return { - label: this.translate(this.model.get('_scope'), 'scopeNames') + label: this.translate(this.model.get('_scope'), 'scopeNames'), }; }, - }); - }); - diff --git a/client/src/views/modals/image-crop.js b/client/src/views/modals/image-crop.js index 1781a42c5b..185a752c14 100644 --- a/client/src/views/modals/image-crop.js +++ b/client/src/views/modals/image-crop.js @@ -26,7 +26,7 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -Espo.define('views/modals/image-crop', ['views/modal', 'lib!Cropper'], function (Dep, Cropper) { +define('views/modals/image-crop', ['views/modal', 'lib!Cropper'], function (Dep, Cropper) { return Dep.extend({ @@ -48,24 +48,26 @@ Espo.define('views/modals/image-crop', ['views/modal', 'lib!Cropper'], function { name: 'crop', label: 'Submit', - style: 'primary' + style: 'primary', }, { name: 'cancel', - label: 'Cancel' - } + label: 'Cancel', + }, ]; - this.on('remove', function () { + this.on('remove', () => { if (this.$img.length) { this.$img.cropper('destroy'); this.$img.parent().empty(); } - }, this); + }); }, afterRender: function () { - var $img = this.$img = $('').attr('src', this.options.contents).addClass('hidden'); + var $img = this.$img = $('') + .attr('src', this.options.contents) + .addClass('hidden'); this.$el.find('.image-container').append($img); @@ -77,15 +79,12 @@ Espo.define('views/modals/image-crop', ['views/modal', 'lib!Cropper'], function rotatable: false, }); }, 50); - }, actionCrop: function () { var dataUrl = this.$img.cropper('getDataURL', 'image/jpeg'); this.trigger('crop', dataUrl); this.close(); - } - + }, }); }); - diff --git a/client/src/views/note/record/edit.js b/client/src/views/note/record/edit.js index 160aebd0ce..98011ecb95 100644 --- a/client/src/views/note/record/edit.js +++ b/client/src/views/note/record/edit.js @@ -26,7 +26,7 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -Espo.define('views/note/record/edit', 'views/record/edit', function (Dep) { +define('views/note/record/edit', ['views/record/edit'], function (Dep) { return Dep.extend({ @@ -38,9 +38,10 @@ Espo.define('views/note/record/edit', 'views/record/edit', function (Dep) { Dep.prototype.setup.call(this); this.controlRequiredFields(); - this.listenTo(this.model, 'change:attachmentsIds', function () { + + this.listenTo(this.model, 'change:attachmentsIds', () => { this.controlRequiredFields(); - }, this); + }); }, controlRequiredFields: function () { @@ -53,11 +54,6 @@ Espo.define('views/note/record/edit', 'views/record/edit', function (Dep) { afterRender: function () { Dep.prototype.afterRender.call(this); - - - } - + }, }); }); - - diff --git a/client/src/views/role/list.js b/client/src/views/role/list.js index 81e2508fe1..b31a40e0c8 100644 --- a/client/src/views/role/list.js +++ b/client/src/views/role/list.js @@ -25,12 +25,11 @@ * In accordance with Section 7(b) of the GNU General Public License version 3, * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -Espo.define('views/role/list', 'views/list', function (Dep) { + +define('views/role/list', ['views/list'], function (Dep) { return Dep.extend({ - searchPanel: false - + searchPanel: false, }); - }); diff --git a/client/src/views/role/record/detail-side.js b/client/src/views/role/record/detail-side.js index d92357a99a..5f9ac1e184 100644 --- a/client/src/views/role/record/detail-side.js +++ b/client/src/views/role/record/detail-side.js @@ -26,7 +26,7 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -Espo.define('views/role/record/detail-side', 'views/record/detail-side', function (Dep) { +define('views/role/record/detail-side', ['views/record/detail-side'], function (Dep) { return Dep.extend({ @@ -34,11 +34,8 @@ Espo.define('views/role/record/detail-side', 'views/record/detail-side', functio { name: 'default', label: false, - view: 'views/role/record/panels/side' + view: 'views/role/record/panels/side', } ], - }); }); - - diff --git a/client/src/views/role/record/detail.js b/client/src/views/role/record/detail.js index 7f6429df2e..cc6e08acd7 100644 --- a/client/src/views/role/record/detail.js +++ b/client/src/views/role/record/detail.js @@ -26,7 +26,7 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -Espo.define('views/role/record/detail', 'views/record/detail', function (Dep) { +define('views/role/record/detail', ['views/record/detail'], function (Dep) { return Dep.extend({ @@ -42,6 +42,7 @@ Espo.define('views/role/record/detail', 'views/record/detail', function (Dep) { setup: function () { Dep.prototype.setup.call(this); + this.createView('extra', this.tableView, { el: this.options.el + ' .extra', model: this.model diff --git a/client/src/views/role/record/edit.js b/client/src/views/role/record/edit.js index 12bbece24a..5c95a2e707 100644 --- a/client/src/views/role/record/edit.js +++ b/client/src/views/role/record/edit.js @@ -26,7 +26,7 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -Espo.define('views/role/record/edit', 'views/record/edit', function (Dep) { +define('views/role/record/edit', ['views/record/edit'], function (Dep) { return Dep.extend({ @@ -49,20 +49,25 @@ Espo.define('views/role/record/edit', 'views/record/edit', function (Dep) { for (var i in scopeList) { var scope = scopeList[i]; - if (this.$el.find('select[name="' + scope + '"]').val() == 'not-set') { + + if (this.$el.find('select[name="' + scope + '"]').val() === 'not-set') { continue; } - if (this.$el.find('select[name="' + scope + '"]').val() == 'disabled') { + + if (this.$el.find('select[name="' + scope + '"]').val() === 'disabled') { data['data'][scope] = false; } else { var o = true; - if (aclTypeMap[scope] != 'boolean') { + + if (aclTypeMap[scope] !== 'boolean') { o = {}; + for (var j in actionList) { var action = actionList[j]; o[action] = this.$el.find('select[name="' + scope + '-' + action + '"]').val(); } } + data['data'][scope] = o; } } @@ -97,16 +102,13 @@ Espo.define('views/role/record/edit', 'views/record/edit', function (Dep) { this.createView('extra', this.tableView, { mode: 'edit', el: this.options.el + ' .extra', - model: this.model - }, function (view) { - this.listenTo(view, 'change', function () { + model: this.model, + }, (view) => { + this.listenTo(view, 'change', () => { var data = this.fetch(); this.model.set(data); - }, this); - }, this); - } - + }); + }); + }, }); }); - - diff --git a/client/src/views/role/record/list.js b/client/src/views/role/record/list.js index 08f74f41cb..cb60c6f58b 100644 --- a/client/src/views/role/record/list.js +++ b/client/src/views/role/record/list.js @@ -26,7 +26,7 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -define('views/role/record/list', 'views/record/list', function (Dep) { +define('views/role/record/list', ['views/record/list'], function (Dep) { return Dep.extend({ diff --git a/client/src/views/role/record/panels/side.js b/client/src/views/role/record/panels/side.js index 1720a141bc..3c009612bd 100644 --- a/client/src/views/role/record/panels/side.js +++ b/client/src/views/role/record/panels/side.js @@ -26,7 +26,7 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -Espo.define('views/role/record/panels/side', 'views/record/panels/side', function (Dep) { +define('views/role/record/panels/side', ['views/record/panels/side'], function (Dep) { return Dep.extend({ diff --git a/client/src/views/user/fields/auto-follow-entity-type-list.js b/client/src/views/user/fields/auto-follow-entity-type-list.js index 4f2ac1abc2..b47da7c5af 100644 --- a/client/src/views/user/fields/auto-follow-entity-type-list.js +++ b/client/src/views/user/fields/auto-follow-entity-type-list.js @@ -25,19 +25,23 @@ * In accordance with Section 7(b) of the GNU General Public License version 3, * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -Espo.define('views/preferences/fields/auto-follow-entity-type-list', 'views/fields/multi-enum', function (Dep) { + +define('views/preferences/fields/auto-follow-entity-type-list', ['views/fields/multi-enum'], 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 + '.stream'); - }, this).sort(function (v1, v2) { - return this.translate(v1, 'scopeNamesPlural').localeCompare(this.translate(v2, 'scopeNamesPlural')); - }.bind(this)); + this.params.options = Object.keys(this.getMetadata().get('scopes')) + .filter(scope => { + return this.getMetadata().get('scopes.' + scope + '.entity') && + this.getMetadata().get('scopes.' + scope + '.stream'); + }) + .sort((v1, v2) => { + return this.translate(v1, 'scopeNamesPlural') + .localeCompare(this.translate(v2, 'scopeNamesPlural')); + }); Dep.prototype.setup.call(this); }, - }); }); diff --git a/client/src/views/user/fields/contact.js b/client/src/views/user/fields/contact.js index 4c3f98436f..cbaaeb0c20 100644 --- a/client/src/views/user/fields/contact.js +++ b/client/src/views/user/fields/contact.js @@ -26,7 +26,7 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -Espo.define('views/user/fields/contact', 'views/fields/link', function (Dep) { +define('views/user/fields/contact', ['views/fields/link'], function (Dep) { return Dep.extend({ @@ -37,10 +37,10 @@ Espo.define('views/user/fields/contact', 'views/fields/link', function (Dep) { if (model.get('accountId')) { var names = {}; - names[model.get('accountId')] = model.get('accountName'); - attributes.accountsIds = [model.get('accountId')], - attributes.accountsNames = names; + names[model.get('accountId')] = model.get('accountName'); + attributes.accountsIds = [model.get('accountId')]; + attributes.accountsNames = names; } attributes.firstName = model.get('firstName'); @@ -58,8 +58,6 @@ Espo.define('views/user/fields/contact', 'views/fields/link', function (Dep) { } this.model.set(attributes); - } - + }, }); - }); diff --git a/client/src/views/user/list.js b/client/src/views/user/list.js index 3180565a9d..99181d82af 100644 --- a/client/src/views/user/list.js +++ b/client/src/views/user/list.js @@ -26,7 +26,7 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -Espo.define('views/user/list', 'views/list', function (Dep) { +define('views/user/list', ['views/list'], function (Dep) { return Dep.extend({ @@ -34,8 +34,6 @@ Espo.define('views/user/list', 'views/list', function (Dep) { setup: function () { Dep.prototype.setup.call(this); - } - + }, }); }); - diff --git a/client/src/views/user/modals/detail.js b/client/src/views/user/modals/detail.js index 053bf46935..e28b230871 100644 --- a/client/src/views/user/modals/detail.js +++ b/client/src/views/user/modals/detail.js @@ -26,7 +26,7 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -Espo.define('views/user/modals/detail', 'views/modals/detail', function (Dep) { +define('views/user/modals/detail', ['views/modals/detail'], function (Dep) { return Dep.extend({ @@ -34,8 +34,8 @@ Espo.define('views/user/modals/detail', 'views/modals/detail', function (Dep) { if (this.model.isPortal()) { return 'PortalUser'; } - return 'User'; - } + return 'User'; + }, }); }); diff --git a/client/src/views/user/record/detail-quick-side.js b/client/src/views/user/record/detail-quick-side.js index 9baf80d622..799d9ba07b 100644 --- a/client/src/views/user/record/detail-quick-side.js +++ b/client/src/views/user/record/detail-quick-side.js @@ -26,15 +26,13 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -Espo.define('views/user/record/detail-quick-side', ['views/record/detail-side', 'views/user/record/detail-side'], function (Dep, UserDetailSide) { +define('views/user/record/detail-quick-side', +['views/record/detail-side', 'views/user/record/detail-side'], function (Dep, UserDetailSide) { return Dep.extend({ setupPanels: function () { UserDetailSide.prototype.setupPanels.call(this); - } - + }, }); - }); - diff --git a/client/src/views/user/record/detail-quick.js b/client/src/views/user/record/detail-quick.js index 7d28e2ff5b..ff2c8aa944 100644 --- a/client/src/views/user/record/detail-quick.js +++ b/client/src/views/user/record/detail-quick.js @@ -26,7 +26,8 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -Espo.define('views/user/record/detail-quick', ['views/record/detail-small', 'views/user/record/detail'], function (Dep, Detail) { +define('views/user/record/detail-quick', +['views/record/detail-small', 'views/user/record/detail'], function (Dep, Detail) { return Dep.extend({ @@ -44,8 +45,6 @@ Espo.define('views/user/record/detail-quick', ['views/record/detail-small', 'vie controlFieldAppearance: function () { Detail.prototype.controlFieldAppearance.call(this); - } - + }, }); - }); diff --git a/client/src/views/user/record/edit-quick.js b/client/src/views/user/record/edit-quick.js index c9a1427532..5b2f8e68b4 100644 --- a/client/src/views/user/record/edit-quick.js +++ b/client/src/views/user/record/edit-quick.js @@ -26,7 +26,7 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -Espo.define('views/user/record/edit-quick', ['views/record/edit-small', 'views/user/record/detail'], function (Dep, Detail) { +define('views/user/record/edit-quick', ['views/record/edit-small', 'views/user/record/detail'], function (Dep, Detail) { return Dep.extend({ @@ -40,7 +40,6 @@ Espo.define('views/user/record/edit-quick', ['views/record/edit-small', 'views/u controlFieldAppearance: function () { Detail.prototype.controlFieldAppearance.call(this); - } - + }, }); }); diff --git a/client/src/views/user/record/edit-side.js b/client/src/views/user/record/edit-side.js index 7e034f1826..79f623a882 100644 --- a/client/src/views/user/record/edit-side.js +++ b/client/src/views/user/record/edit-side.js @@ -26,11 +26,10 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -Espo.define('views/user/record/edit-side', 'views/record/edit-side', function (Dep) { +define('views/user/record/edit-side', ['views/record/edit-side'], function (Dep) { return Dep.extend({ }); - }); diff --git a/client/src/views/user/record/list.js b/client/src/views/user/record/list.js index abcdebbaca..c5249c741e 100644 --- a/client/src/views/user/record/list.js +++ b/client/src/views/user/record/list.js @@ -26,7 +26,7 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -Espo.define('views/user/record/list', 'views/record/list', function (Dep) { +define('views/user/record/list', ['views/record/list'], function (Dep) { return Dep.extend({ @@ -47,9 +47,11 @@ Espo.define('views/user/record/list', 'views/record/list', function (Dep) { this.layoutName = 'listApi'; } + if (this.scope === 'PortalUser') { this.layoutName = 'listPortal'; } + if (!this.getUser().isAdmin()) { this.removeMassAction('massUpdate'); this.removeMassAction('export'); @@ -62,9 +64,8 @@ Espo.define('views/user/record/list', 'views/record/list', function (Dep) { if (model.isPortal()) { return 'PortalUser'; } + return this.scope; - } + }, }); - }); - diff --git a/client/src/views/user/record/panels/default-side.js b/client/src/views/user/record/panels/default-side.js index 2fb349cde2..4d3528ea0f 100644 --- a/client/src/views/user/record/panels/default-side.js +++ b/client/src/views/user/record/panels/default-side.js @@ -26,15 +26,13 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -Espo.define('views/user/record/panels/default-side', 'views/record/panels/default-side', function (Dep) { +define('views/user/record/panels/default-side', ['views/record/panels/default-side'], function (Dep) { return Dep.extend({ complexCreatedDisabled: true, - complexModifiedDisabled: true + complexModifiedDisabled: true, }); - }); - diff --git a/client/src/views/user/record/panels/stream.js b/client/src/views/user/record/panels/stream.js index 29dd52adbd..714a7aac2b 100644 --- a/client/src/views/user/record/panels/stream.js +++ b/client/src/views/user/record/panels/stream.js @@ -26,7 +26,7 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -Espo.define('views/user/record/panels/stream', 'views/stream/panel', function (Dep) { +define('views/user/record/panels/stream', ['views/stream/panel'], function (Dep) { return Dep.extend({ @@ -35,10 +35,11 @@ Espo.define('views/user/record/panels/stream', 'views/stream/panel', function (D var assignmentPermission = this.getAcl().checkAssignmentPermission(this.model); - if (this.model.id == this.getUser().id) { + if (this.model.id === this.getUser().id) { this.placeholderText = this.translate('writeMessageToSelf', 'messages'); } else { - this.placeholderText = this.translate('writeMessageToUser', 'messages').replace('{user}', this.model.get('name')); + this.placeholderText = this.translate('writeMessageToUser', 'messages') + .replace('{user}', this.model.get('name')); } if (!assignmentPermission) { @@ -46,13 +47,14 @@ Espo.define('views/user/record/panels/stream', 'views/stream/panel', function (D if (this.getAcl().get('assignmentPermission') === 'team') { if (!this.model.has('teamsIds')) { - this.listenToOnce(this.model, 'sync', function () { + this.listenToOnce(this.model, 'sync', () => { assignmentPermission = this.getAcl().checkUserPermission(this.model); + if (assignmentPermission) { this.postDisabled = false; this.$el.find('.post-container').removeClass('hidden');; } - }, this); + }); } } } @@ -61,14 +63,12 @@ Espo.define('views/user/record/panels/stream', 'views/stream/panel', function (D prepareNoteForPost: function (model) { var userIdList = [this.model.id]; var userNames = {}; + userNames[userIdList] = this.model.get('name'); model.set('usersIds', userIdList); model.set('usersNames', userNames); model.set('targetType', 'users'); - } - + }, }); - }); - diff --git a/client/src/views/user/record/row-actions/default.js b/client/src/views/user/record/row-actions/default.js index 277e5397c9..f4abc4fd6c 100644 --- a/client/src/views/user/record/row-actions/default.js +++ b/client/src/views/user/record/row-actions/default.js @@ -26,12 +26,13 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -Espo.define('views/user/record/row-actions/default', 'views/record/row-actions/default', function (Dep) { +define('views/user/record/row-actions/default', ['views/record/row-actions/default'], function (Dep) { return Dep.extend({ getActionList: function () { var scope = 'User'; + if (this.model.isPortal()) { scope = 'PortalUser'; } else if (this.model.isApi()) { @@ -47,6 +48,7 @@ Espo.define('views/user/record/row-actions/default', 'views/record/row-actions/d }, link: '#' + scope + '/view/' + this.model.id }]; + if (this.options.acl.edit) { list.push({ action: 'quickEdit', @@ -58,8 +60,8 @@ Espo.define('views/user/record/row-actions/default', 'views/record/row-actions/d link: '#' + scope + '/edit/' + this.model.id }); } - return list; - } - }); + return list; + }, + }); });