From ed7d24bc8fb5bc954a879b3dac2e56f91b103a62 Mon Sep 17 00:00:00 2001 From: yuri Date: Mon, 1 Feb 2016 17:09:45 +0200 Subject: [PATCH] notification fronend refactor --- application/Espo/Controllers/Notification.php | 2 + .../Espo/Resources/i18n/en_US/Global.json | 4 +- .../metadata/clientDefs/Notification.json | 8 +- application/Espo/Services/Notification.php | 9 +- .../{notifications => notification}/badge.tpl | 0 .../fields/container.tpl} | 0 .../fields}/read.tpl | 0 .../items/assign.tpl | 0 .../items/email-received.tpl | 0 .../items/entity-removed.tpl | 0 .../items/message.tpl | 0 .../items/system.tpl | 0 .../res/templates/notification/list.tpl | 19 ++++ .../{notifications => notification}/panel.tpl | 0 frontend/client/res/templates/stream.tpl | 2 +- .../list.js => controllers/notification.js} | 12 ++- .../{notifications => notification}/badge.js | 6 +- .../fields/container.js} | 10 +- .../fields}/read.js | 20 ++-- .../items/assign.js | 4 +- .../items/base.js} | 2 +- .../items/email-received.js | 4 +- .../items/entity-removed.js | 4 +- .../items/message.js | 4 +- .../items/system.js | 4 +- .../client/src/views/notification/list.js | 92 +++++++++++++++++++ .../{notifications => notification}/panel.js | 13 +-- .../src/views/notification/record/list.js | 72 +++++++++++++++ frontend/client/src/views/site/navbar.js | 2 +- 29 files changed, 249 insertions(+), 44 deletions(-) rename frontend/client/res/templates/{notifications => notification}/badge.tpl (100%) rename frontend/client/res/templates/{notifications/field.tpl => notification/fields/container.tpl} (100%) rename frontend/client/res/templates/{notifications => notification/fields}/read.tpl (100%) rename frontend/client/res/templates/{notifications => notification}/items/assign.tpl (100%) rename frontend/client/res/templates/{notifications => notification}/items/email-received.tpl (100%) rename frontend/client/res/templates/{notifications => notification}/items/entity-removed.tpl (100%) rename frontend/client/res/templates/{notifications => notification}/items/message.tpl (100%) rename frontend/client/res/templates/{notifications => notification}/items/system.tpl (100%) create mode 100644 frontend/client/res/templates/notification/list.tpl rename frontend/client/res/templates/{notifications => notification}/panel.tpl (100%) rename frontend/client/src/{views/notifications/list.js => controllers/notification.js} (83%) rename frontend/client/src/views/{notifications => notification}/badge.js (98%) rename frontend/client/src/views/{notifications/field.js => notification/fields/container.js} (90%) rename frontend/client/src/views/{notifications => notification/fields}/read.js (84%) rename frontend/client/src/views/{notifications => notification}/items/assign.js (92%) rename frontend/client/src/views/{notifications/notification.js => notification/items/base.js} (97%) rename frontend/client/src/views/{notifications => notification}/items/email-received.js (93%) rename frontend/client/src/views/{notifications => notification}/items/entity-removed.js (92%) rename frontend/client/src/views/{notifications => notification}/items/message.js (93%) rename frontend/client/src/views/{notifications => notification}/items/system.js (91%) create mode 100644 frontend/client/src/views/notification/list.js rename frontend/client/src/views/{notifications => notification}/panel.js (86%) create mode 100644 frontend/client/src/views/notification/record/list.js diff --git a/application/Espo/Controllers/Notification.php b/application/Espo/Controllers/Notification.php index 3554c8b084..9ec5c1f3f4 100644 --- a/application/Espo/Controllers/Notification.php +++ b/application/Espo/Controllers/Notification.php @@ -44,10 +44,12 @@ class Notification extends \Espo\Core\Controllers\Base $offset = intval($request->get('offset')); $maxSize = intval($request->get('maxSize')); + $after = $request->get('after'); $params = array( 'offset' => $offset, 'maxSize' => $maxSize, + 'after' => $after ); $result = $this->getService('Notification')->getList($userId, $params); diff --git a/application/Espo/Resources/i18n/en_US/Global.json b/application/Espo/Resources/i18n/en_US/Global.json index f157c1f790..e8b54e58d4 100644 --- a/application/Espo/Resources/i18n/en_US/Global.json +++ b/application/Espo/Resources/i18n/en_US/Global.json @@ -217,7 +217,9 @@ "writeYourCommentHere": "Write your comment here", "writeMessageToUser": "Write a message to {user}", "writeMessageToSelf": "Write a message to self", - "typeAndPressEnter": "Type & press enter" + "typeAndPressEnter": "Type & press enter", + "checkForNewNotifications": "Check for new notifications", + "checkForNewNotes": "Check for new Stream entries" }, "boolFilters": { "onlyMy": "Only My", diff --git a/application/Espo/Resources/metadata/clientDefs/Notification.json b/application/Espo/Resources/metadata/clientDefs/Notification.json index ce1ff68a2d..66258073b0 100644 --- a/application/Espo/Resources/metadata/clientDefs/Notification.json +++ b/application/Espo/Resources/metadata/clientDefs/Notification.json @@ -1,5 +1,7 @@ { - "itemViews": { - "System": "Notifications.Items.System" - } + "controller": "controllers/notification", + "collection": "collections/note", + "itemViews": { + "System": "views/notification/items/system" + } } diff --git a/application/Espo/Services/Notification.php b/application/Espo/Services/Notification.php index 20243c1804..f91b87d9e8 100644 --- a/application/Espo/Services/Notification.php +++ b/application/Espo/Services/Notification.php @@ -152,9 +152,16 @@ class Notification extends \Espo\Core\Services\Base public function getList($userId, array $params = array()) { $searchParams = array(); - $searchParams['whereClause'] = array( + + $whereClause = array( 'userId' => $userId ); + if (!empty($params['after'])) { + $whereClause['createdAt>'] = $params['after']; + } + + $searchParams['whereClause'] = $whereClause; + if (array_key_exists('offset', $params)) { $searchParams['offset'] = $params['offset']; } diff --git a/frontend/client/res/templates/notifications/badge.tpl b/frontend/client/res/templates/notification/badge.tpl similarity index 100% rename from frontend/client/res/templates/notifications/badge.tpl rename to frontend/client/res/templates/notification/badge.tpl diff --git a/frontend/client/res/templates/notifications/field.tpl b/frontend/client/res/templates/notification/fields/container.tpl similarity index 100% rename from frontend/client/res/templates/notifications/field.tpl rename to frontend/client/res/templates/notification/fields/container.tpl diff --git a/frontend/client/res/templates/notifications/read.tpl b/frontend/client/res/templates/notification/fields/read.tpl similarity index 100% rename from frontend/client/res/templates/notifications/read.tpl rename to frontend/client/res/templates/notification/fields/read.tpl diff --git a/frontend/client/res/templates/notifications/items/assign.tpl b/frontend/client/res/templates/notification/items/assign.tpl similarity index 100% rename from frontend/client/res/templates/notifications/items/assign.tpl rename to frontend/client/res/templates/notification/items/assign.tpl diff --git a/frontend/client/res/templates/notifications/items/email-received.tpl b/frontend/client/res/templates/notification/items/email-received.tpl similarity index 100% rename from frontend/client/res/templates/notifications/items/email-received.tpl rename to frontend/client/res/templates/notification/items/email-received.tpl diff --git a/frontend/client/res/templates/notifications/items/entity-removed.tpl b/frontend/client/res/templates/notification/items/entity-removed.tpl similarity index 100% rename from frontend/client/res/templates/notifications/items/entity-removed.tpl rename to frontend/client/res/templates/notification/items/entity-removed.tpl diff --git a/frontend/client/res/templates/notifications/items/message.tpl b/frontend/client/res/templates/notification/items/message.tpl similarity index 100% rename from frontend/client/res/templates/notifications/items/message.tpl rename to frontend/client/res/templates/notification/items/message.tpl diff --git a/frontend/client/res/templates/notifications/items/system.tpl b/frontend/client/res/templates/notification/items/system.tpl similarity index 100% rename from frontend/client/res/templates/notifications/items/system.tpl rename to frontend/client/res/templates/notification/items/system.tpl diff --git a/frontend/client/res/templates/notification/list.tpl b/frontend/client/res/templates/notification/list.tpl new file mode 100644 index 0000000000..0551c8ac9f --- /dev/null +++ b/frontend/client/res/templates/notification/list.tpl @@ -0,0 +1,19 @@ + + +
+
+
{{{list}}}
+
+
diff --git a/frontend/client/res/templates/notifications/panel.tpl b/frontend/client/res/templates/notification/panel.tpl similarity index 100% rename from frontend/client/res/templates/notifications/panel.tpl rename to frontend/client/res/templates/notification/panel.tpl diff --git a/frontend/client/res/templates/stream.tpl b/frontend/client/res/templates/stream.tpl index 0badddf234..6fc26b3606 100644 --- a/frontend/client/res/templates/stream.tpl +++ b/frontend/client/res/templates/stream.tpl @@ -10,7 +10,7 @@ {{#each filterList}} {{/each}} - + diff --git a/frontend/client/src/views/notifications/list.js b/frontend/client/src/controllers/notification.js similarity index 83% rename from frontend/client/src/views/notifications/list.js rename to frontend/client/src/controllers/notification.js index a2a64b2beb..c6cc2b32ac 100644 --- a/frontend/client/src/views/notifications/list.js +++ b/frontend/client/src/controllers/notification.js @@ -25,11 +25,19 @@ * In accordance with Section 7(b) of the GNU General Public License version 3, * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ - -Espo.define('views/notifications/list', 'views/record/list-expanded', function (Dep) { +Espo.define('controllers/notification', 'controller', function (Dep) { return Dep.extend({ + defaultAction: 'index', + + index: function () { + this.main('views/notification/list', { + }, function (view) { + view.render(); + }); + } + }); }); diff --git a/frontend/client/src/views/notifications/badge.js b/frontend/client/src/views/notification/badge.js similarity index 98% rename from frontend/client/src/views/notifications/badge.js rename to frontend/client/src/views/notification/badge.js index 98612c2190..52dc8d2a32 100644 --- a/frontend/client/src/views/notifications/badge.js +++ b/frontend/client/src/views/notification/badge.js @@ -26,11 +26,11 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -Espo.define('views/notifications/badge', 'view', function (Dep) { +Espo.define('views/notification/badge', 'view', function (Dep) { return Dep.extend({ - template: 'notifications/badge', + template: 'notification/badge', notificationsCheckInterval: 10, @@ -237,7 +237,7 @@ Espo.define('views/notifications/badge', 'view', function (Dep) { $container.appendTo(this.$el.find('.notifications-panel-container')); - this.createView('panel', 'Notifications.Panel', { + this.createView('panel', 'views/notification/panel', { el: '#notifications-panel', }, function (view) { view.render(); diff --git a/frontend/client/src/views/notifications/field.js b/frontend/client/src/views/notification/fields/container.js similarity index 90% rename from frontend/client/src/views/notifications/field.js rename to frontend/client/src/views/notification/fields/container.js index 0a1afd16fd..5ba277486b 100644 --- a/frontend/client/src/views/notifications/field.js +++ b/frontend/client/src/views/notification/fields/container.js @@ -26,15 +26,15 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -Espo.define('views/notifications/field', 'views/fields/base', function (Dep) { +Espo.define('views/notification/fields/container', 'views/fields/base', function (Dep) { return Dep.extend({ type: 'notification', - listTemplate: 'notifications/field', + listTemplate: 'notification/fields/container', - detailTemplate: 'notifications/field', + detailTemplate: 'notification/fields/container', setup: function () { switch (this.model.get('type')) { @@ -54,7 +54,7 @@ Espo.define('views/notifications/field', 'views/fields/base', function (Dep) { if (!type) return; type = type.replace(/ /g, ''); - var viewName = this.getMetadata().get('clientDefs.Notification.itemViews.' + type) || 'views/notifications/items/' + Espo.Utils.camelCaseToHyphen(type); + var viewName = this.getMetadata().get('clientDefs.Notification.itemViews.' + type) || 'views/notification/items/' + Espo.Utils.camelCaseToHyphen(type); this.createView('notification', viewName, { model: this.model, el: this.params.containerEl + ' li[data-id="' + this.model.id + '"]', @@ -81,7 +81,7 @@ Espo.define('views/notifications/field', 'views/fields/base', function (Dep) { this.wait(true); this.getModelFactory().create('Note', function (model) { model.set(data); - var viewName = 'Stream.Notes.MentionInPost'; + var viewName = 'views/stream/notes/mention-in-post'; this.createView('notification', viewName, { model: model, userId: this.model.get('userId'), diff --git a/frontend/client/src/views/notifications/read.js b/frontend/client/src/views/notification/fields/read.js similarity index 84% rename from frontend/client/src/views/notifications/read.js rename to frontend/client/src/views/notification/fields/read.js index 66718e0c2d..5b8ce4f8c1 100644 --- a/frontend/client/src/views/notifications/read.js +++ b/frontend/client/src/views/notification/fields/read.js @@ -24,24 +24,24 @@ * * In accordance with Section 7(b) of the GNU General Public License version 3, * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. - ************************************************************************/ + ************************************************************************/ -Espo.define('Views.Notifications.Read', 'Views.Fields.Base', function (Dep) { +Espo.define('views/notification/fields/read', 'views/fields/base', function (Dep) { return Dep.extend({ - type: 'read', - - listTemplate: 'notifications.read', - - detailTemplate: 'notifications.read', - + type: 'read', + + listTemplate: 'notification/fields/read', + + detailTemplate: 'notification/fields/read', + data: function () { return { isRead: this.model.get('read') }; - }, - + }, + }); }); diff --git a/frontend/client/src/views/notifications/items/assign.js b/frontend/client/src/views/notification/items/assign.js similarity index 92% rename from frontend/client/src/views/notifications/items/assign.js rename to frontend/client/src/views/notification/items/assign.js index 292d97f879..686075e1d8 100644 --- a/frontend/client/src/views/notifications/items/assign.js +++ b/frontend/client/src/views/notification/items/assign.js @@ -26,13 +26,13 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -Espo.define('views/notifications/items/assign', 'views/notifications/notification', function (Dep) { +Espo.define('views/notification/items/assign', 'views/notification/items/base', function (Dep) { return Dep.extend({ messageName: 'assign', - template: 'notifications/items/assign', + template: 'notification/items/assign', setup: function () { var data = this.model.get('data') || {}; diff --git a/frontend/client/src/views/notifications/notification.js b/frontend/client/src/views/notification/items/base.js similarity index 97% rename from frontend/client/src/views/notifications/notification.js rename to frontend/client/src/views/notification/items/base.js index 7df9160ae0..7b7bc0667b 100644 --- a/frontend/client/src/views/notifications/notification.js +++ b/frontend/client/src/views/notification/items/base.js @@ -26,7 +26,7 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -Espo.define('views/notifications/notification', 'view', function (Dep) { +Espo.define('views/notification/items/base', 'view', function (Dep) { return Dep.extend({ diff --git a/frontend/client/src/views/notifications/items/email-received.js b/frontend/client/src/views/notification/items/email-received.js similarity index 93% rename from frontend/client/src/views/notifications/items/email-received.js rename to frontend/client/src/views/notification/items/email-received.js index f13e8236c1..b2978a3ecc 100644 --- a/frontend/client/src/views/notifications/items/email-received.js +++ b/frontend/client/src/views/notification/items/email-received.js @@ -26,13 +26,13 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -Espo.define('views/notifications/items/email-received', 'views/notifications/notification', function (Dep) { +Espo.define('views/notification/items/email-received', 'views/notification/items/base', function (Dep) { return Dep.extend({ messageName: 'emailReceived', - template: 'notifications/items/email-received', + template: 'notification/items/email-received', data: function () { return _.extend({ diff --git a/frontend/client/src/views/notifications/items/entity-removed.js b/frontend/client/src/views/notification/items/entity-removed.js similarity index 92% rename from frontend/client/src/views/notifications/items/entity-removed.js rename to frontend/client/src/views/notification/items/entity-removed.js index 12d3434e8f..53fd527f01 100644 --- a/frontend/client/src/views/notifications/items/entity-removed.js +++ b/frontend/client/src/views/notification/items/entity-removed.js @@ -26,13 +26,13 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -Espo.define('views/notifications/items/entity-removed', 'views/notifications/notification', function (Dep) { +Espo.define('views/notification/items/entity-removed', 'views/notification/items/base', function (Dep) { return Dep.extend({ messageName: 'entityRemoved', - template: 'notifications/items/entity-removed', + template: 'notification/items/entity-removed', setup: function () { var data = this.model.get('data') || {}; diff --git a/frontend/client/src/views/notifications/items/message.js b/frontend/client/src/views/notification/items/message.js similarity index 93% rename from frontend/client/src/views/notifications/items/message.js rename to frontend/client/src/views/notification/items/message.js index a2860833d8..76a695edfe 100644 --- a/frontend/client/src/views/notifications/items/message.js +++ b/frontend/client/src/views/notification/items/message.js @@ -26,11 +26,11 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -Espo.define('views/notifications/items/message', 'views/notifications/notification', function (Dep) { +Espo.define('views/notification/items/message', 'views/notification/items/base', function (Dep) { return Dep.extend({ - template: 'notifications/items/message', + template: 'notification/items/message', data: function () { return _.extend({ diff --git a/frontend/client/src/views/notifications/items/system.js b/frontend/client/src/views/notification/items/system.js similarity index 91% rename from frontend/client/src/views/notifications/items/system.js rename to frontend/client/src/views/notification/items/system.js index 88aa5557db..dfbc020d36 100644 --- a/frontend/client/src/views/notifications/items/system.js +++ b/frontend/client/src/views/notification/items/system.js @@ -26,11 +26,11 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -Espo.define('views/notifications/items/system', 'views/notifications/notification', function (Dep) { +Espo.define('views/notification/items/system', 'views/notification/items/base', function (Dep) { return Dep.extend({ - template: 'notifications/items/system', + template: 'notification/items/system', data: function () { var data = Dep.prototype.data.call(this); diff --git a/frontend/client/src/views/notification/list.js b/frontend/client/src/views/notification/list.js new file mode 100644 index 0000000000..4ce087e10a --- /dev/null +++ b/frontend/client/src/views/notification/list.js @@ -0,0 +1,92 @@ +/************************************************************************ + * This file is part of EspoCRM. + * + * EspoCRM - Open Source CRM application. + * Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko + * Website: http://www.espocrm.com + * + * EspoCRM is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * EspoCRM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with EspoCRM. If not, see http://www.gnu.org/licenses/. + * + * The interactive user interfaces in modified source and object code versions + * of this program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU General Public License version 3. + * + * In accordance with Section 7(b) of the GNU General Public License version 3, + * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. + ************************************************************************/ + +Espo.define('views/notification/list', 'view', function (Dep) { + + return Dep.extend({ + + template: 'notification/list', + + events: { + 'click [data-action="markAllNotificationsRead"]': function () { + $.ajax({ + url: 'Notification/action/markAllRead', + type: 'POST' + }).done(function (count) { + this.trigger('all-read'); + }.bind(this)); + }, + 'click [data-action="refresh"]': function () { + this.getView('list').showNewRecords(); + }, + }, + + setup: function () { + this.wait(true); + this.getCollectionFactory().create('Notification', function (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.createView('list', viewName, { + el: this.options.el + ' .list-container', + collection: this.collection, + showCount: false, + listLayout: { + rows: [ + [ + { + name: 'data', + view: 'views/notification/fields/container', + params: { + containerEl: this.options.el + }, + } + ] + ], + right: { + name: 'read', + view: 'views/notification/fields/read', + width: '10px' + } + } + }, function (view) { + view.render(); + }); + }, this); + this.collection.fetch(); + } + + }); + +}); diff --git a/frontend/client/src/views/notifications/panel.js b/frontend/client/src/views/notification/panel.js similarity index 86% rename from frontend/client/src/views/notifications/panel.js rename to frontend/client/src/views/notification/panel.js index c853ca9e8e..c58f67614f 100644 --- a/frontend/client/src/views/notifications/panel.js +++ b/frontend/client/src/views/notification/panel.js @@ -26,11 +26,11 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -Espo.define('Views.Notifications.Panel', 'View', function (Dep) { +Espo.define('views/notification/panel', 'view', function (Dep) { return Dep.extend({ - template: 'notifications.panel', + template: 'notification/panel', events: { 'click [data-action="markAllNotificationsRead"]': function () { @@ -54,7 +54,8 @@ Espo.define('Views.Notifications.Panel', 'View', function (Dep) { afterRender: function () { this.listenToOnce(this.collection, 'sync', function () { - this.createView('list', 'Notifications.List', { + 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, showCount: false, @@ -63,7 +64,7 @@ Espo.define('Views.Notifications.Panel', 'View', function (Dep) { [ { name: 'data', - view: 'Notifications.Field', + view: 'views/notification/fields/container', params: { containerEl: this.options.el }, @@ -72,14 +73,14 @@ Espo.define('Views.Notifications.Panel', 'View', function (Dep) { ], right: { name: 'read', - view: 'Notifications.Read', + view: 'views/notification/fields/read', width: '10px' } } }, function (view) { view.render(); }); - }.bind(this)); + }, this); this.collection.fetch(); } diff --git a/frontend/client/src/views/notification/record/list.js b/frontend/client/src/views/notification/record/list.js new file mode 100644 index 0000000000..593e822b9e --- /dev/null +++ b/frontend/client/src/views/notification/record/list.js @@ -0,0 +1,72 @@ +/************************************************************************ + * This file is part of EspoCRM. + * + * EspoCRM - Open Source CRM application. + * Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko + * Website: http://www.espocrm.com + * + * EspoCRM is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * EspoCRM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with EspoCRM. If not, see http://www.gnu.org/licenses/. + * + * The interactive user interfaces in modified source and object code versions + * of this program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU General Public License version 3. + * + * In accordance with Section 7(b) of the GNU General Public License version 3, + * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. + ************************************************************************/ + +Espo.define('views/notification/record/list', 'views/record/list-expanded', function (Dep) { + + return Dep.extend({ + + showNewRecords: function () { + var collection = this.collection; + var initialCount = collection.length; + + var $list = this.$el.find(this.listContainerEl); + + var success = function () { + 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) { + 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, + }); + } + + }); + +}); diff --git a/frontend/client/src/views/site/navbar.js b/frontend/client/src/views/site/navbar.js index 1a19650407..3235f96dce 100644 --- a/frontend/client/src/views/site/navbar.js +++ b/frontend/client/src/views/site/navbar.js @@ -124,7 +124,7 @@ Espo.define('views/site/navbar', 'view', function (Dep) { return true; }, this); - this.createView('notificationsBadge', 'views/notifications/badge', { + this.createView('notificationsBadge', 'views/notification/badge', { el: this.options.el + ' .notifications-badge-container' });