From ef0d3febd8030e007a41380c5ca0400790b86a2a Mon Sep 17 00:00:00 2001 From: yuri Date: Tue, 8 Oct 2019 11:54:15 +0300 Subject: [PATCH] buttons small fix --- client/src/views/detail.js | 43 ++++++++++++++++---------------------- client/src/views/main.js | 4 ++++ 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/client/src/views/detail.js b/client/src/views/detail.js index 6e85ce61de..148a46f81a 100644 --- a/client/src/views/detail.js +++ b/client/src/views/detail.js @@ -136,36 +136,29 @@ define('views/detail', 'views/main', function (Dep) { }, actionFollow: function () { - $el = this.$el.find('[data-action="follow"]'); - $el.addClass('disabled'); - $.ajax({ - url: this.model.name + '/' + this.model.id + '/subscription', - type: 'PUT', - success: function () { - $el.remove(); + this.disableMenuItem('follow'); + + Espo.Ajax.putRequest(this.model.name + '/' + this.model.id + '/subscription') + .then(function () { + this.removeMenuItem('follow', true); this.model.set('isFollowed', true); - }.bind(this), - error: function () { - $el.removeClass('disabled'); - }.bind(this) - }); + }.bind(this)) + .fail(function () { + this.enableMenuItem('follow'); + }.bind(this)); }, actionUnfollow: function () { - $el = this.$el.find('[data-action="unfollow"]'); - $el.addClass('disabled'); - $.ajax({ - url: this.model.name + '/' + this.model.id + '/subscription', - type: 'DELETE', - success: function () { - $el.remove(); - this.model.set('isFollowed', false); - }.bind(this), - error: function () { - $el.removeClass('disabled'); - }.bind(this) - }); + this.disableMenuItem('unfollow'); + Espo.Ajax.deleteRequest(this.model.name + '/' + this.model.id + '/subscription') + .then(function () { + this.removeMenuItem('unfollow', true); + this.model.set('isFollowed', false); + }.bind(this)) + .fail(function () { + this.enableMenuItem('unfollow'); + }.bind(this)); }, getHeader: function () { diff --git a/client/src/views/main.js b/client/src/views/main.js index 497443a014..0f32f003d9 100644 --- a/client/src/views/main.js +++ b/client/src/views/main.js @@ -191,6 +191,10 @@ define('views/main', 'view', function (Dep) { if (!doNotReRender && this.isRendered()) { this.getView('header').reRender(); } + + if (doNotReRender && this.isRendered()) { + this.$el.find('.header .header-buttons [data-name="'+name+'"]').remove(); + } }, disableMenuItem: function (name) {