From 7598c18ad63cf3b0f7d113ec8b810d32e19d8e58 Mon Sep 17 00:00:00 2001 From: Molkobain Date: Wed, 28 Jul 2021 10:07:03 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B04203=20-=20Activity=20panel:=20Hide=20"l?= =?UTF-8?q?oad=20more=20entries"=20button=20when=20only=20"logs"=20filter?= =?UTF-8?q?=20is=20active?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/layouts/activity-panel/activity-panel.js | 30 ++++++++++++++++++- .../layouts/activity-panel/layout.html.twig | 4 ++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/js/layouts/activity-panel/activity-panel.js b/js/layouts/activity-panel/activity-panel.js index 6e672eaf8..4de163183 100644 --- a/js/layouts/activity-panel/activity-panel.js +++ b/js/layouts/activity-panel/activity-panel.js @@ -1143,6 +1143,7 @@ $(function() }); this._UpdateEntryGroupsVisibility(); + this._UpdateLoadMoreEntriesButtonVisibility(); this._UpdateMessagesCounters(); }, _ShowAllEntries: function() @@ -1200,6 +1201,12 @@ $(function() this._UpdateEntryGroupsVisibility(); }, + /** + * Update the entry groups visibility regarding if they have visible entries themself + * + * @private + * @return {void} + */ _UpdateEntryGroupsVisibility: function () { const me = this; @@ -1211,6 +1218,27 @@ $(function() } }); }, + /** + * Update the "load more entries" button visibility regarding the current filters + * + * @private + * @return {void} + */ + _UpdateLoadMoreEntriesButtonVisibility: function () { + const oButtonElem = this.element.find(this.js_selectors.load_more_entries); + + // Check if button exists (if all entries have been loaded, we might have remove it + if (oButtonElem.length === 0) { + return; + } + + // Show button only if the states / edits filters are selected as log entries are always fully loaded + if (this._GetActiveTabToolbarElement().find(this.js_selectors.activity_filter + '[data-target-entry-types!="'+this.enums.entry_types.caselog+'"]:checked').length > 0) { + oButtonElem.removeClass(this.css_classes.is_hidden); + } else { + oButtonElem.addClass(this.css_classes.is_hidden); + } + }, /** * Load the next entries and append them to the current ones * @@ -1266,7 +1294,7 @@ $(function() me.options.last_loaded_entries_ids = oData.data.last_loaded_entries_ids; // - Update button state if (Object.keys(me.options.last_loaded_entries_ids).length === 0) { - me.element.find(me.js_selectors.load_more_entries).addClass(me.css_classes.is_hidden); + me.element.find(me.js_selectors.load_more_entries).remove(); } }) .always(function () { diff --git a/templates/base/layouts/activity-panel/layout.html.twig b/templates/base/layouts/activity-panel/layout.html.twig index a8caeca53..ade855275 100644 --- a/templates/base/layouts/activity-panel/layout.html.twig +++ b/templates/base/layouts/activity-panel/layout.html.twig @@ -83,7 +83,9 @@ {% endfor %} {% if oUIBlock.HasMoreEntriesToLoad() %}
- + {# Note: The "more entries" button is hidden by default to avoid a visual glitch. #} + {# Otherwise when the page is loaded, the button is displayed even if the current tab only show log entries (which are all loaded) #} +