diff --git a/client/src/views/record/list.js b/client/src/views/record/list.js index 54342d0662..309a4e69b5 100644 --- a/client/src/views/record/list.js +++ b/client/src/views/record/list.js @@ -143,26 +143,7 @@ Espo.define('views/record/list', 'view', function (Dep) { } }, 'click .select-all': function (e) { - this.checkedList = []; - - if (e.currentTarget.checked) { - this.$el.find('input.record-checkbox').prop('checked', true); - this.$el.find('.actions-button').removeAttr('disabled'); - this.collection.models.forEach(function (model) { - this.checkedList.push(model.id); - }, this); - - this.$el.find('.list > table tbody tr').addClass('active'); - } else { - if (this.allResultIsChecked) { - this.unselectAllResult(); - } - this.$el.find('input.record-checkbox').prop('checked', false); - this.$el.find('.actions-button').attr('disabled', true); - this.$el.find('.list > table tbody tr').removeClass('active'); - } - - this.trigger('check'); + this.selectAllHandler(e.currentTarget.checked); }, 'click .action': function (e) { var $el = $(e.currentTarget); @@ -190,6 +171,30 @@ Espo.define('views/record/list', 'view', function (Dep) { } }, + selectAllHandler: function (isChecked) { + this.checkedList = []; + + var $actionsButton = this.$el.find('.actions-button'); + + if (isChecked) { + this.$el.find('input.record-checkbox').prop('checked', true); + $actionsButton.removeAttr('disabled'); + this.collection.models.forEach(function (model) { + this.checkedList.push(model.id); + }, this); + this.$el.find('.list > table tbody tr').addClass('active'); + } else { + if (this.allResultIsChecked) { + this.unselectAllResult(); + } + this.$el.find('input.record-checkbox').prop('checked', false); + $actionsButton.attr('disabled', true); + this.$el.find('.list > table tbody tr').removeClass('active'); + } + + this.trigger('check'); + }, + /** * @param {string} or {bool} ['both', 'top', 'bottom', false, true] Where to display paginations. */ @@ -304,7 +309,10 @@ Espo.define('views/record/list', 'view', function (Dep) { } }, this); - this.$el.find('.actions-button').removeAttr('disabled'); + if (this.checkAllResultMassActionList.length) { + this.$el.find('.actions-button').removeAttr('disabled'); + } + this.$el.find('.list > table tbody tr').removeClass('active'); },