From 2dfd00dd2ec2a81024918796357cd9653bda4904 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Fri, 16 Sep 2022 21:46:09 +0300 Subject: [PATCH] cs fix --- .../src/views/email-account/fields/folders.js | 65 ++++++++----------- 1 file changed, 28 insertions(+), 37 deletions(-) diff --git a/client/src/views/email-account/fields/folders.js b/client/src/views/email-account/fields/folders.js index 8af5caf32e..f3b6a0f77d 100644 --- a/client/src/views/email-account/fields/folders.js +++ b/client/src/views/email-account/fields/folders.js @@ -26,14 +26,14 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -define('views/email-account/fields/folders', 'views/fields/array', function (Dep) { +define('views/email-account/fields/folders', ['views/fields/array'], function (Dep) { return Dep.extend({ getFoldersUrl: 'EmailAccount/action/getFolders', fetchFolders: function () { - return new Promise(function (resolve) { + return new Promise(resolve => { var data = { host: this.model.get('host'), port: this.model.get('port'), @@ -52,54 +52,45 @@ define('views/email-account/fields/folders', 'views/fields/array', function (Dep } Espo.Ajax.postRequest(this.getFoldersUrl, data) - .then( - function (folders) { - resolve(folders); - }.bind(this) - ) - .fail( - function (xhr) { - Espo.Ui.error(this.translate('couldNotConnectToImap', 'messages', 'EmailAccount')); + .then(folders => { + resolve(folders); + }) + .catch(xhr =>{ + Espo.Ui.error(this.translate('couldNotConnectToImap', 'messages', 'EmailAccount')); - xhr.errorIsHandled = true; + xhr.errorIsHandled = true; - resolve(["INBOX"]); - }.bind(this) - ); - }.bind(this)); + resolve(["INBOX"]); + }); + }); }, actionAddItem: function () { Espo.Ui.notify(this.translate('loading', 'messages')); this.fetchFolders() - .then( - function (options) { - Espo.Ui.notify(false); + .then(options => { + Espo.Ui.notify(false); - this.createView( 'addModal', this.addItemModalView, {options: options}) - .then( - function (view) { - view.render(); + this.createView( 'addModal', this.addItemModalView, {options: options}) + .then(view => { + view.render(); - view.once('add', function (item) { - this.addValue(item); + view.once('add', item =>{ + this.addValue(item); - view.close(); - }.bind(this)); + view.close(); + }); - view.once('add-mass', function (items) { - items.forEach(function (item) { - this.addValue(item); - }.bind(this)); - - view.close(); - }.bind(this)); - }.bind(this) - ); - }.bind(this) - ); + view.once('add-mass', items => { + items.forEach(item => { + this.addValue(item); + }); + view.close(); + }); + }); + }); }, }); });