diff --git a/client/modules/crm/src/controllers/unsubscribe.js b/client/modules/crm/src/controllers/unsubscribe.js index 2afcf298b5..5ce6e52294 100644 --- a/client/modules/crm/src/controllers/unsubscribe.js +++ b/client/modules/crm/src/controllers/unsubscribe.js @@ -26,7 +26,7 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -Espo.define('crm:controllers/unsubscribe', 'controller', function (Dep) { +define('crm:controllers/unsubscribe', ['controller'], function (Dep) { return Dep.extend({ @@ -54,7 +54,6 @@ Espo.define('crm:controllers/unsubscribe', 'controller', function (Dep) { }, function (view) { view.render(); }); - } - + }, }); }); diff --git a/client/modules/crm/src/knowledge-base-helper.js b/client/modules/crm/src/knowledge-base-helper.js index 093221df4d..0615416a99 100644 --- a/client/modules/crm/src/knowledge-base-helper.js +++ b/client/modules/crm/src/knowledge-base-helper.js @@ -26,7 +26,7 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -Espo.define('crm:knowledge-base-helper', 'ajax', function (Ajax) { +define('crm:knowledge-base-helper', ['ajax'], function (Ajax) { var KnowledgeBaseHelper = function (language) { this.language = language; @@ -41,25 +41,27 @@ Espo.define('crm:knowledge-base-helper', 'ajax', function (Ajax) { getAttributesForEmail: function (model, attributes, callback) { attributes = attributes || {}; attributes.body = model.get('body'); + if (attributes.name) { attributes.name = attributes.name + ' '; } else { attributes.name = ''; } - attributes.name += this.getLanguage().translate('KnowledgeBaseArticle', 'scopeNames') + ': ' + model.get('name'); + + attributes.name += this.getLanguage().translate('KnowledgeBaseArticle', 'scopeNames') + ': ' + + model.get('name'); Ajax.postRequest('KnowledgeBaseArticle/action/getCopiedAttachments', { id: model.id - }).then(function (data) { + }).then((data) => { attributes.attachmentsIds = data.ids; attributes.attachmentsNames = data.names; attributes.isHtml = true; callback(attributes); - }.bind(this)); - } + }); + }, }); return KnowledgeBaseHelper; - }); diff --git a/client/modules/crm/src/views/contact/fields/accounts.js b/client/modules/crm/src/views/contact/fields/accounts.js index b90b863247..6d401a1604 100644 --- a/client/modules/crm/src/views/contact/fields/accounts.js +++ b/client/modules/crm/src/views/contact/fields/accounts.js @@ -34,12 +34,19 @@ Espo.define('crm:views/contact/fields/accounts', 'views/fields/link-multiple-wit events: { 'click [data-action="switchPrimary"]': function (e) { - $target = $(e.currentTarget); + let $target = $(e.currentTarget); var id = $target.data('id'); if (!$target.hasClass('active')) { - this.$el.find('button[data-action="switchPrimary"]').removeClass('active').children().addClass('text-muted'); - $target.addClass('active').children().removeClass('text-muted'); + this.$el.find('button[data-action="switchPrimary"]') + .removeClass('active') + .children() + .addClass('text-muted'); + + $target.addClass('active') + .children() + .removeClass('text-muted'); + this.setPrimaryId(id); } } @@ -47,9 +54,11 @@ Espo.define('crm:views/contact/fields/accounts', 'views/fields/link-multiple-wit getAttributeList: function () { var list = Dep.prototype.getAttributeList.call(this); + list.push('accountId'); list.push('accountName'); list.push('title'); + return list; }, @@ -68,7 +77,6 @@ Espo.define('crm:views/contact/fields/accounts', 'views/fields/link-multiple-wit this.primaryName = this.model.get(this.primaryNameFieldName); }, this); - if (this.mode === 'edit' || this.mode === 'detail') { this.events['click a[data-action="setPrimary"]'] = function (e) { var id = $(e.currentTarget).data('id'); @@ -111,6 +119,7 @@ Espo.define('crm:views/contact/fields/accounts', 'views/fields/link-multiple-wit names.push(this.getDetailLinkHtml(id)); } }, this); + return names.join(''); } }, @@ -207,8 +216,6 @@ Espo.define('crm:views/contact/fields/accounts', 'views/fields/link-multiple-wit } return data; - } - + }, }); - }); diff --git a/client/modules/crm/src/views/opportunity/fields/contacts.js b/client/modules/crm/src/views/opportunity/fields/contacts.js index 827386effe..e4ed131b2b 100644 --- a/client/modules/crm/src/views/opportunity/fields/contacts.js +++ b/client/modules/crm/src/views/opportunity/fields/contacts.js @@ -35,12 +35,21 @@ define( events: { 'click [data-action="switchPrimary"]': function (e) { - $target = $(e.currentTarget); + let $target = $(e.currentTarget); + var id = $target.data('id'); if (!$target.hasClass('active')) { - this.$el.find('button[data-action="switchPrimary"]').removeClass('active').children().addClass('text-muted'); - $target.addClass('active').children().removeClass('text-muted'); + this.$el.find('button[data-action="switchPrimary"]') + .removeClass('active') + .children() + .addClass('text-muted'); + + $target + .addClass('active') + .children() + .removeClass('text-muted'); + this.setPrimaryId(id); } } @@ -48,8 +57,10 @@ define( getAttributeList: function () { var list = Dep.prototype.getAttributeList.call(this); + list.push(this.primaryIdFieldName); list.push(this.primaryNameFieldName); + return list; }, @@ -138,7 +149,10 @@ define( var isPrimary = (id == this.primaryId); var iconHtml = ''; var title = this.translate('Primary'); - var $primary = $(''); + + var $primary = $(''); + $primary.insertAfter($el.children().first().children().first()); this.managePrimaryButton(); @@ -148,6 +162,7 @@ define( managePrimaryButton: function () { var $primary = this.$el.find('button[data-action="switchPrimary"]'); + if ($primary.length > 1) { $primary.removeClass('hidden'); } else { @@ -175,7 +190,9 @@ define( getSelectFilters: function () { if (this.model.get('accountId')) { var nameHash = {}; + nameHash[this.model.get('accountId')] = this.model.get('accountName'); + return { 'accounts': { type: 'linkedWith', @@ -197,6 +214,5 @@ define( } } }, - }); }); diff --git a/client/modules/crm/src/views/target/detail.js b/client/modules/crm/src/views/target/detail.js index 8bd9388a86..641dd9dfc7 100644 --- a/client/modules/crm/src/views/target/detail.js +++ b/client/modules/crm/src/views/target/detail.js @@ -24,9 +24,9 @@ * * 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('Crm:Views.Target.Detail', 'Views.Detail', function (Dep) { +define('crm:views/target/detail', ['views/detail'], function (Dep) { return Dep.extend({ @@ -50,4 +50,3 @@ Espo.define('Crm:Views.Target.Detail', 'Views.Detail', function (Dep) { }); }); - diff --git a/client/src/views/admin/entity-manager/index.js b/client/src/views/admin/entity-manager/index.js index 5c6cae3bab..9a1e3ec0eb 100644 --- a/client/src/views/admin/entity-manager/index.js +++ b/client/src/views/admin/entity-manager/index.js @@ -89,7 +89,7 @@ define('views/admin/entity-manager/index', 'view', function (Dep) { isRemovable = false; } - hasView = d.customizable; + let hasView = d.customizable; this.scopeDataList.push({ name: scope, diff --git a/client/src/views/dashlets/fields/records/expanded-layout.js b/client/src/views/dashlets/fields/records/expanded-layout.js index d6c1328602..5a0c8f61e8 100644 --- a/client/src/views/dashlets/fields/records/expanded-layout.js +++ b/client/src/views/dashlets/fields/records/expanded-layout.js @@ -68,7 +68,7 @@ Espo.define('views/dashlets/fields/records/expanded-layout', 'views/fields/base' this.$container.append($row); - $input = $row.find('input'); + let $input = $row.find('input'); $input.selectize({ options: fieldDataList, diff --git a/client/src/views/email-filter/fields/action.js b/client/src/views/email-filter/fields/action.js index 85f10c0139..44146d0e96 100644 --- a/client/src/views/email-filter/fields/action.js +++ b/client/src/views/email-filter/fields/action.js @@ -25,13 +25,16 @@ * 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/email-filter/fields/action', 'views/fields/enum', function (Dep) { + +define('views/email-filter/fields/action', ['views/fields/enum'], function (Dep) { return Dep.extend({ setup: function () { Dep.prototype.setup.call(this); + this.controlActionOptions(); + this.listenTo(this.model, 'change:parentType', this.controlActionOptions, this); }, @@ -41,11 +44,10 @@ Espo.define('views/email-filter/fields/action', 'views/fields/enum', function (D } else { this.params.options = ['Skip']; } + if (this.isRendered()) { this.reRender(); } - } - + }, }); - }); diff --git a/client/src/views/fields/base.js b/client/src/views/fields/base.js index 9b34973e15..7de60cf194 100644 --- a/client/src/views/fields/base.js +++ b/client/src/views/fields/base.js @@ -802,7 +802,8 @@ define('views/fields/base', ['view'], function (Dep) { var $sign = $label.find('span.required-sign'); if ($label.length && !$sign.length) { - $text = $label.find('span.label-text'); + let $text = $label.find('span.label-text'); + $(' *').insertAfter($text); $sign = $label.find('span.required-sign'); } diff --git a/client/src/views/fields/link-multiple-with-columns.js b/client/src/views/fields/link-multiple-with-columns.js index 0ea7ea75e2..1fec9773b2 100644 --- a/client/src/views/fields/link-multiple-with-columns.js +++ b/client/src/views/fields/link-multiple-with-columns.js @@ -326,7 +326,7 @@ define('views/fields/link-multiple-with-columns', 'views/fields/link-multiple', } }, this); - $left = $('
'); + let $left = $('
'); if (columnFormElementJQList.length === 1) { $left.append(columnFormElementJQList[0]); @@ -358,7 +358,7 @@ define('views/fields/link-multiple-with-columns', 'views/fields/link-multiple', $el.append($left); - $right = $('
'); + let $right = $('
'); $right.append(removeHtml); $el.append($right); diff --git a/client/src/views/fields/link-multiple-with-primary.js b/client/src/views/fields/link-multiple-with-primary.js index 4551b789d7..8354af50c7 100644 --- a/client/src/views/fields/link-multiple-with-primary.js +++ b/client/src/views/fields/link-multiple-with-primary.js @@ -34,7 +34,7 @@ define('views/fields/link-multiple-with-primary', 'views/fields/link-multiple', events: { 'click [data-action="switchPrimary"]': function (e) { - $target = $(e.currentTarget); + let $target = $(e.currentTarget); var id = $target.data('id'); @@ -161,11 +161,11 @@ define('views/fields/link-multiple-with-primary', 'views/fields/link-multiple', var removeHtml = '' + ''; - $left = $('
'); + let $left = $('
'); $left.append(nameHtml); $el.append($left); - $right = $('
'); + let $right = $('
'); $right.append(removeHtml); $el.append($right); diff --git a/client/src/views/fields/link-multiple-with-role.js b/client/src/views/fields/link-multiple-with-role.js index 13590e3365..27b9a44c72 100644 --- a/client/src/views/fields/link-multiple-with-role.js +++ b/client/src/views/fields/link-multiple-with-role.js @@ -237,7 +237,7 @@ define('views/fields/link-multiple-with-role', 'views/fields/link-multiple', fun ); } - $left = $('
'); + let $left = $('
'); if ($role) { $left.append($role); @@ -247,7 +247,7 @@ define('views/fields/link-multiple-with-role', 'views/fields/link-multiple', fun $el.append($left); - $right = $('
'); + let $right = $('
'); $right.append(removeHtml); diff --git a/client/src/views/global-search/global-search.js b/client/src/views/global-search/global-search.js index 15c7c56ebb..1fedb240be 100644 --- a/client/src/views/global-search/global-search.js +++ b/client/src/views/global-search/global-search.js @@ -26,7 +26,7 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -define('views/global-search/global-search', 'view', function (Dep) { +define('views/global-search/global-search', ['view'], function (Dep) { return Dep.extend({ @@ -34,7 +34,7 @@ define('views/global-search/global-search', 'view', function (Dep) { events: { 'keypress input.global-search-input': function (e) { - if (e.keyCode == 13) { + if (e.keyCode === 13) { this.runSearch(); } }, @@ -48,12 +48,13 @@ define('views/global-search/global-search', 'view', function (Dep) { setup: function () { this.wait(true); - this.getCollectionFactory().create('GlobalSearch', function (collection) { + + this.getCollectionFactory().create('GlobalSearch', (collection) => { this.collection = collection; collection.name = 'GlobalSearch'; - this.wait(false); - }, this); + this.wait(false); + }); }, afterRender: function () { @@ -62,8 +63,8 @@ define('views/global-search/global-search', 'view', function (Dep) { runSearch: function () { var text = this.$input.val().trim(); - if (text != '' && text.length >= 2) { - text = text; + + if (text !== '' && text.length >= 2) { this.search(text); } }, @@ -90,39 +91,44 @@ define('views/global-search/global-search', 'view', function (Dep) { this.listenToOnce(view, 'close', this.closePanel); }); - $document = $(document); - $document.on('mouseup.global-search', function (e) { - if (e.which !== 1) return; + let $document = $(document); + + $document.on('mouseup.global-search', (e) => { + if (e.which !== 1) { + return; + } + if (!$container.is(e.target) && $container.has(e.target).length === 0) { this.closePanel(); } - }.bind(this)); - $document.on('click.global-search', function (e) { + }); + + $document.on('click.global-search', (e) => { if ( - e.target.tagName == 'A' && - $(e.target).data('action') != 'showMore' && + e.target.tagName === 'A' && + $(e.target).data('action') !== 'showMore' && !$(e.target).hasClass('global-search-button') ) { - setTimeout(function () { + setTimeout(() => { this.closePanel(); - }.bind(this), 100); - return; + }, 100); } - }.bind(this)); + }); }, closePanel: function () { - $container = $('#global-search-panel'); + let $container = $('#global-search-panel'); + + $container.remove(); + + let $document = $(document); - $('#global-search-panel').remove(); - $document = $(document); if (this.hasView('panel')) { this.getView('panel').remove(); - }; + } + $document.off('mouseup.global-search'); $document.off('click.global-search'); - $container.remove(); }, - }); }); diff --git a/client/src/views/import/step1.js b/client/src/views/import/step1.js index 3041c73325..3a4ae890ff 100644 --- a/client/src/views/import/step1.js +++ b/client/src/views/import/step1.js @@ -458,10 +458,11 @@ define('views/import/step1', ['view', 'model'], function (Dep, Model) { return; } - $row = $(''); + let $row = $(''); row.forEach((value) => { - $cell = $('').html(value); + let $cell = $('').html(value); + $row.append($cell); }); diff --git a/client/src/views/import/step2.js b/client/src/views/import/step2.js index cc776cf1c6..dc89b729db 100644 --- a/client/src/views/import/step2.js +++ b/client/src/views/import/step2.js @@ -106,7 +106,7 @@ define('views/import/step2', 'view', function (Dep) { }, afterRender: function () { - $container = $('#mapping-container'); + let $container = $('#mapping-container'); var $table = $('').addClass('table').addClass('table-bordered').css('table-layout', 'fixed'); @@ -152,7 +152,8 @@ define('views/import/step2', 'view', function (Dep) { } - $select = this.getFieldDropdown(i, selectedName); + let $select = this.getFieldDropdown(i, selectedName); + $cell = $('
').append($select); $row.append($cell); diff --git a/client/src/views/modals/password-change-request.js b/client/src/views/modals/password-change-request.js index d8e62914b9..ad3afea824 100644 --- a/client/src/views/modals/password-change-request.js +++ b/client/src/views/modals/password-change-request.js @@ -130,7 +130,8 @@ define('views/modals/password-change-request', 'views/modal', function (Dep) { if (!isValid) return; - $submit = this.$el.find('button[data-name="submit"]'); + let $submit = this.$el.find('button[data-name="submit"]'); + $submit.addClass('disabled'); Espo.Ui.notify(this.translate('pleaseWait', 'messages')); diff --git a/client/src/views/notification/badge.js b/client/src/views/notification/badge.js index 176c3f3832..16adcd3b4f 100644 --- a/client/src/views/notification/badge.js +++ b/client/src/views/notification/badge.js @@ -445,7 +445,7 @@ define('views/notification/badge', 'view', function (Dep) { }); }); - $document = $(document); + let $document = $(document); $document.on('mouseup.notification', e => { if (!$container.is(e.target) && $container.has(e.target).length === 0) { diff --git a/client/src/views/record/detail.js b/client/src/views/record/detail.js index be3605fa3f..1e2f4f5774 100644 --- a/client/src/views/record/detail.js +++ b/client/src/views/record/detail.js @@ -774,7 +774,7 @@ define('views/record/detail', ['views/record/base', 'view-record-helper'], funct var $p = $('.popover'); $p.each(function (i, el) { - $el = $(el); + let $el = $(el); $el.css('top', ($el.position().top - blockHeight) + 'px'); }); } @@ -787,7 +787,7 @@ define('views/record/detail', ['views/record/base', 'view-record-helper'], funct var $p = $('.popover'); $p.each(function (i, el) { - $el = $(el); + let $el = $(el); $el.css('top', ($el.position().top + blockHeight) + 'px'); }); } diff --git a/client/src/views/record/list.js b/client/src/views/record/list.js index 689051b90e..f8a641e873 100644 --- a/client/src/views/record/list.js +++ b/client/src/views/record/list.js @@ -200,7 +200,7 @@ define( }, 'click .actions-menu a.mass-action': function (e) { - $el = $(e.currentTarget); + let $el = $(e.currentTarget); var action = $el.data('action'); diff --git a/client/src/views/role/record/table.js b/client/src/views/role/record/table.js index aab5bfb37f..829602001a 100644 --- a/client/src/views/role/record/table.js +++ b/client/src/views/role/record/table.js @@ -121,7 +121,8 @@ define('views/role/record/table', 'view', function (Dep) { $dropdowns.removeAttr('disabled'); $dropdowns.removeClass('hidden'); $dropdowns.each(function (i, select) { - $select = $(select); + let $select = $(select); + if (this.lowestLevelByDefault) { $select.find('option').last().prop('selected', true); } else { @@ -140,7 +141,9 @@ define('views/role/record/table', 'view', function (Dep) { $select.find('option').first().prop('selected', true); } } + $select.trigger('change'); + this.controlSelectColor($select); }.bind(this)); } else { diff --git a/client/src/views/site/navbar.js b/client/src/views/site/navbar.js index d9b80b8255..a3dbd33cda 100644 --- a/client/src/views/site/navbar.js +++ b/client/src/views/site/navbar.js @@ -552,8 +552,8 @@ define('views/site/navbar', 'view', function (Dep) { this.adjustBodyMinHeightMethodName = 'adjustBodyMinHeightHorizontal'; - $moreDd = $('#nav-more-tabs-dropdown'); - $moreLi = $moreDd.closest('li'); + let $moreDd = $('#nav-more-tabs-dropdown'); + let $moreLi = $moreDd.closest('li'); var updateWidth = () => { var windowWidth = window.innerWidth; diff --git a/client/src/views/stream/record/edit.js b/client/src/views/stream/record/edit.js index 68c1e4cde7..40dc25f4e5 100644 --- a/client/src/views/stream/record/edit.js +++ b/client/src/views/stream/record/edit.js @@ -128,7 +128,7 @@ define('views/stream/record/edit', 'views/record/base', function (Dep) { this.post(); } else if (e.keyCode === 9) { - $text = $(e.currentTarget); + let $text = $(e.currentTarget); if ($text.val() === '') { this.disablePostingMode(); @@ -301,4 +301,4 @@ define('views/stream/record/edit', 'views/record/base', function (Dep) { }, }); -}); \ No newline at end of file +}); diff --git a/client/src/views/user/fields/teams.js b/client/src/views/user/fields/teams.js index cd380ed1f9..d083800a0b 100644 --- a/client/src/views/user/fields/teams.js +++ b/client/src/views/user/fields/teams.js @@ -96,10 +96,13 @@ define('views/user/fields/teams', 'views/fields/link-multiple-with-role', functi if (role != '') { role = this.getHelper().escapeString(role); - roleHtml = ' ' + role + ''; + + roleHtml = ' ' + role + + ''; } - var lineHtml = '
' + '' + name + ' ' + roleHtml + '
'; + var lineHtml = '
' + '' + name + ' ' + + roleHtml + '
'; return lineHtml; }, @@ -109,25 +112,33 @@ define('views/user/fields/teams', 'views/fields/link-multiple-with-role', functi if (!roleList.length) { return; - }; + } + if (roleList.length || roleValue) { - $role = $(''); roleList.unshift(''); - roleList.forEach(function (role) { + + roleList.forEach(role => { var selectedHtml = (role == roleValue) ? 'selected': ''; + role = this.getHelper().escapeString(role); + var label = role; + if (role == '') { label = '--' + this.translate('None', 'labels') + '--'; } - option = ''; - $role.append(option); - }, this); + + let optionHtml = ''; + + $role.append(optionHtml); + }); + return $role; - } else { - return $('
').html(roleValue); } + + return $('
').html(roleValue); }, }); }); diff --git a/client/src/views/user/modals/access.js b/client/src/views/user/modals/access.js index 9f318dc06e..8924907b2d 100644 --- a/client/src/views/user/modals/access.js +++ b/client/src/views/user/modals/access.js @@ -26,7 +26,7 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -Espo.define('views/user/modals/access', 'views/modal', function (Dep) { +define('views/user/modals/access', ['views/modal'], function (Dep) { return Dep.extend({ @@ -68,14 +68,22 @@ Espo.define('views/user/modals/access', 'views/modal', function (Dep) { ]; var fieldTable = Espo.Utils.cloneDeep(this.options.aclData.fieldTable || {}); + for (var scope in fieldTable) { var scopeData = fieldTable[scope] || {}; + for (var field in scopeData) { - if (this.getMetadata().get(['app', 'acl', 'mandatory', 'scopeFieldLevel', scope, field]) !== null) { + if ( + this.getMetadata() + .get(['app', 'acl', 'mandatory', 'scopeFieldLevel', scope, field]) !== null + ) { delete scopeData[field]; } - if (scopeData[field] && this.getMetadata().get(['entityDefs', scope, 'fields', field, 'readOnly'])) { + if ( + scopeData[field] && + this.getMetadata().get(['entityDefs', scope, 'fields', field, 'readOnly']) + ) { if (scopeData[field].edit === 'no' && scopeData[field].read === 'yes') { delete scopeData[field]; } @@ -92,7 +100,6 @@ Espo.define('views/user/modals/access', 'views/modal', function (Dep) { }); this.headerHtml = this.translate('Access'); - } - + }, }); });