From 0e267ca2a62b50bd5d0efd9ab9b8db23d19a1442 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Mon, 6 Jun 2022 10:01:21 +0300 Subject: [PATCH] cs fix --- client/src/views/notification/list.js | 26 +++++++++++--------- client/src/views/notification/record/list.js | 22 ++++++++++------- 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/client/src/views/notification/list.js b/client/src/views/notification/list.js index 1fee12ffed..65a56fcf17 100644 --- a/client/src/views/notification/list.js +++ b/client/src/views/notification/list.js @@ -26,7 +26,7 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -Espo.define('views/notification/list', 'view', function (Dep) { +define('views/notification/list', 'view', function (Dep) { return Dep.extend({ @@ -37,10 +37,10 @@ Espo.define('views/notification/list', 'view', function (Dep) { $.ajax({ url: 'Notification/action/markAllRead', type: 'POST' - }).done(function (count) { + }).then((count) => { this.trigger('all-read'); this.$el.find('.badge-circle-warning').remove(); - }.bind(this)); + }); }, 'click [data-action="refresh"]': function () { this.getView('list').showNewRecords(); @@ -49,16 +49,20 @@ Espo.define('views/notification/list', 'view', function (Dep) { setup: function () { this.wait(true); - this.getCollectionFactory().create('Notification', function (collection) { + + this.getCollectionFactory().create('Notification', (collection) => { this.collection = collection; collection.maxSize = this.getConfig().get('recordsPerPage') || 20; + this.wait(false); - }, this); + }); }, afterRender: function () { - this.listenToOnce(this.collection, 'sync', function () { - var viewName = this.getMetadata().get(['clientDefs', 'Notification', 'recordViews', 'list']) || 'views/notification/record/list'; + this.listenToOnce(this.collection, 'sync', () => { + var viewName = this.getMetadata().get(['clientDefs', 'Notification', 'recordViews', 'list']) || + 'views/notification/record/list'; + this.createView('list', viewName, { el: this.options.el + ' .list-container', collection: this.collection, @@ -81,13 +85,13 @@ Espo.define('views/notification/list', 'view', function (Dep) { width: '10px' } } - }, function (view) { + }, (view) => { view.render(); }); - }, this); + }); + this.collection.fetch(); - } + }, }); - }); diff --git a/client/src/views/notification/record/list.js b/client/src/views/notification/record/list.js index 32d942e2a1..ef2f8543c5 100644 --- a/client/src/views/notification/record/list.js +++ b/client/src/views/notification/record/list.js @@ -26,7 +26,7 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -Espo.define('views/notification/record/list', 'views/record/list-expanded', function (Dep) { +define('views/notification/record/list', 'views/record/list-expanded', function (Dep) { return Dep.extend({ @@ -36,37 +36,41 @@ Espo.define('views/notification/record/list', 'views/record/list-expanded', func var $list = this.$el.find(this.listContainerEl); - var success = function () { + var success = () => { if (initialCount === 0) { this.reRender(); + return; } + var rowCount = collection.length - initialCount; var rowsReady = 0; + for (var i = rowCount - 1; i >= 0; i--) { var model = collection.at(i); - this.buildRow(i, model, function (view) { - view.getHtml(function (html) { + this.buildRow(i, model, view => { + view.getHtml(html => { var $row = $(this.getRowContainerHtml(model.id)); + $row.append(html); $list.prepend($row); rowsReady++; view._afterRender(); + if (view.options.el) { view.setElement(view.options.el); } - }.bind(this)); + }); }); } + this.noRebuild = true; - }.bind(this); + }; collection.fetchNew({ success: success, }); - } - + }, }); - });