diff --git a/client/modules/crm/src/views/calendar/modals/edit-view.js b/client/modules/crm/src/views/calendar/modals/edit-view.js index 8911fd642e..8ef476cb7b 100644 --- a/client/modules/crm/src/views/calendar/modals/edit-view.js +++ b/client/modules/crm/src/views/calendar/modals/edit-view.js @@ -47,11 +47,7 @@ define('crm:views/calendar/modals/edit-view', ['views/modal', 'model'], function setup: function () { var id = this.options.id; - if (id) { - this.isNew = false; - } else { - this.isNew = true; - } + this.isNew = !id; var calendarViewDataList = this.getPreferences().get('calendarViewDataList') || []; @@ -159,16 +155,16 @@ define('crm:views/calendar/modals/edit-view', ['views/modal', 'model'], function this.getPreferences() .save( { - 'calendarViewDataList': calendarViewDataList + 'calendarViewDataList': calendarViewDataList, }, {patch: true} ) - .then(() =>{ + .then(() => { Espo.Ui.notify(false); this.trigger('after:save', data); this.remove(); }) - .fail(() => { + .catch(() => { this.enableButton('remove'); this.enableButton('save'); }); @@ -206,7 +202,7 @@ define('crm:views/calendar/modals/edit-view', ['views/modal', 'model'], function this.trigger('after:remove'); this.remove(); }) - .fail(() => { + .catch(() => { this.enableButton('remove'); this.enableButton('save'); }); diff --git a/client/src/views/admin/label-manager/edit.js b/client/src/views/admin/label-manager/edit.js index a7f3b25aaf..1426c312d2 100644 --- a/client/src/views/admin/label-manager/edit.js +++ b/client/src/views/admin/label-manager/edit.js @@ -26,7 +26,7 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -define('views/admin/label-manager/edit', 'view', function (Dep) { +define('views/admin/label-manager/edit', ['view'], function (Dep) { return Dep.extend({ @@ -155,7 +155,7 @@ define('views/admin/label-manager/edit', 'view', function (Dep) { this.getLanguage().loadSkipCache(); }) - .fail(() => { + .catch(() => { this.$save.removeClass('disabled').removeAttr('disabled'); this.$cancel.removeClass('disabled').removeAttr('disabled'); }); @@ -210,7 +210,6 @@ define('views/admin/label-manager/edit', 'view', function (Dep) { getCategoryData: function (category) { return this.scopeData[category] || {}; }, - }); }); diff --git a/client/src/views/admin/template-manager/edit.js b/client/src/views/admin/template-manager/edit.js index 55ef9ab119..380843669e 100644 --- a/client/src/views/admin/template-manager/edit.js +++ b/client/src/views/admin/template-manager/edit.js @@ -151,7 +151,9 @@ define('views/admin/template-manager/edit', ['view', 'model'], function (Dep, Mo } Espo.Ui.notify(this.translate('saving', 'messages')); - this.ajaxPostRequest('TemplateManager/action/saveTemplate', data).then(function () { + + this.ajaxPostRequest('TemplateManager/action/saveTemplate', data) + .then(() => { this.setConfirmLeaveOut(false); this.attributes.body = data.body; @@ -162,21 +164,23 @@ define('views/admin/template-manager/edit', ['view', 'model'], function (Dep, Mo this.$resetToDefault.removeClass('disabled').removeAttr('disabled'); Espo.Ui.success(this.translate('Saved')); - }.bind(this)).fail(function () { + }) + .catch(() => { this.$save.removeClass('disabled').removeAttr('disabled'); this.$cancel.removeClass('disabled').removeAttr('disabled'); this.$resetToDefault.removeClass('disabled').removeAttr('disabled'); - }.bind(this)); + }); }, actionCancel: function () { this.model.set('subject', this.attributes.subject); this.model.set('body', this.attributes.body); + this.setConfirmLeaveOut(false); }, actionResetToDefault: function () { - this.confirm(this.translate('confirmation', 'messages'), function () { + this.confirm(this.translate('confirmation', 'messages'), () => { this.$save.addClass('disabled').attr('disabled'); this.$cancel.addClass('disabled').attr('disabled'); this.$resetToDefault.addClass('disabled').attr('disabled'); @@ -192,26 +196,27 @@ define('views/admin/template-manager/edit', ['view', 'model'], function (Dep, Mo Espo.Ui.notify(this.translate('pleaseWait', 'messages')); - this.ajaxPostRequest('TemplateManager/action/resetTemplate', data).then(function (returnData) { - this.$save.removeClass('disabled').removeAttr('disabled'); - this.$cancel.removeClass('disabled').removeAttr('disabled'); - this.$resetToDefault.removeClass('disabled').removeAttr('disabled'); + this.ajaxPostRequest('TemplateManager/action/resetTemplate', data) + .then(returnData => { + this.$save.removeClass('disabled').removeAttr('disabled'); + this.$cancel.removeClass('disabled').removeAttr('disabled'); + this.$resetToDefault.removeClass('disabled').removeAttr('disabled'); - this.attributes.body = returnData.body; - this.attributes.subject = returnData.subject; + this.attributes.body = returnData.body; + this.attributes.subject = returnData.subject; - this.model.set('subject', returnData.subject); - this.model.set('body', returnData.body); - this.setConfirmLeaveOut(false); - - Espo.Ui.notify(false); - }.bind(this)).fail(function () { - this.$save.removeClass('disabled').removeAttr('disabled'); - this.$cancel.removeClass('disabled').removeAttr('disabled'); - this.$resetToDefault.removeClass('disabled').removeAttr('disabled'); - }.bind(this)); - }.bind(this)); - } + this.model.set('subject', returnData.subject); + this.model.set('body', returnData.body); + this.setConfirmLeaveOut(false); + Espo.Ui.notify(false); + }) + .catch(() => { + this.$save.removeClass('disabled').removeAttr('disabled'); + this.$cancel.removeClass('disabled').removeAttr('disabled'); + this.$resetToDefault.removeClass('disabled').removeAttr('disabled'); + }); + }); + }, }); }); diff --git a/client/src/views/email-account/fields/folder.js b/client/src/views/email-account/fields/folder.js index 4be1b55069..3ed327b649 100644 --- a/client/src/views/email-account/fields/folder.js +++ b/client/src/views/email-account/fields/folder.js @@ -26,7 +26,7 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -define('views/email-account/fields/folder', 'views/fields/base', function (Dep) { +define('views/email-account/fields/folder', ['views/fields/base'], function (Dep) { return Dep.extend({ @@ -55,24 +55,26 @@ define('views/email-account/fields/folder', 'views/fields/base', function (Dep) data.id = this.model.id; } - Espo.Ajax.postRequest(this.getFoldersUrl, data).then(function (folders) { + Espo.Ajax.postRequest(this.getFoldersUrl, data).then(folders => { this.createView('modal', 'views/email-account/modals/select-folder', { folders: folders - }, function (view) { + }, (view) => { this.notify(false); view.render(); - this.listenToOnce(view, 'select', function (folder) { + this.listenToOnce(view, 'select', (folder) => { view.close(); + this.addFolder(folder); - }, this); + }); }); - }.bind(this)).fail(function () { + }) + .catch(() => { Espo.Ui.error(this.translate('couldNotConnectToImap', 'messages', 'EmailAccount')); xhr.errorIsHandled = true; - }.bind(this)); + }); } }, diff --git a/client/src/views/personal-data/modals/personal-data.js b/client/src/views/personal-data/modals/personal-data.js index 5aa728ecef..dbe7ab60e0 100644 --- a/client/src/views/personal-data/modals/personal-data.js +++ b/client/src/views/personal-data/modals/personal-data.js @@ -43,7 +43,7 @@ define('views/personal-data/modals/personal-data', ['views/modal'], function (De { name: 'cancel', label: 'Close' - } + }, ]; this.headerText = this.getLanguage().translate('Personal Data'); @@ -54,7 +54,7 @@ define('views/personal-data/modals/personal-data', ['views/modal'], function (De name: 'erase', label: 'Erase', style: 'danger', - disabled: true + disabled: true, }); } @@ -65,9 +65,10 @@ define('views/personal-data/modals/personal-data', ['views/modal'], function (De this.createView('record', 'views/personal-data/record/record', { el: this.getSelector() + ' .record', model: this.model - }, function (view) { - this.listenTo(view, 'check', function (fieldList) { + }, (view) => { + this.listenTo(view, 'check', (fieldList) => { this.fieldList = fieldList; + if (fieldList.length) { this.enableButton('erase'); } else { @@ -85,21 +86,22 @@ define('views/personal-data/modals/personal-data', ['views/modal'], function (De this.confirm({ message: this.translate('erasePersonalDataConfirmation', 'messages'), confirmText: this.translate('Erase') - }, function () { + }, () => { this.disableButton('erase'); + this.ajaxPostRequest('DataPrivacy/action/erase', { fieldList: this.fieldList, entityType: this.scope, - id: this.model.id - }).then(function () { + id: this.model.id, + }).then(() => { Espo.Ui.success(this.translate('Done')); this.trigger('erase'); - }.bind(this)).fail(function () { + }) + .catch(() => { this.enableButton('erase'); - }.bind(this)); - }.bind(this)); - } - + }); + }); + }, }); }); diff --git a/public/install/js/install.js b/public/install/js/install.js index c3b72837b0..d41105b736 100644 --- a/public/install/js/install.js +++ b/public/install/js/install.js @@ -312,8 +312,7 @@ InstallScript.prototype.step5 = function() { }) .fail(function(ajaxData){ - }) - + }); }) $('.field-smtpAuth').find('input[type="checkbox"]').change( function(e){