From 6ca4e5410ee5a1684dccb55c403ee9bc1bc4c77b Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Thu, 27 Jun 2024 11:47:41 +0200 Subject: [PATCH] Remove load-more functionality --- asset/js/widget/ActionList.js | 127 +--------------------------------- 1 file changed, 2 insertions(+), 125 deletions(-) diff --git a/asset/js/widget/ActionList.js b/asset/js/widget/ActionList.js index c569e433..e8686c69 100644 --- a/asset/js/widget/ActionList.js +++ b/asset/js/widget/ActionList.js @@ -7,7 +7,6 @@ define(["../notjQuery"], function (notjQuery) { this.lastActivatedItemUrl = null; this.lastTimeoutId = null; - this.isProcessingLoadMore = false; this.activeRequests = {}; this.listIdentifier = '[data-interactable-action-list]'; @@ -20,11 +19,7 @@ define(["../notjQuery"], function (notjQuery) { this.on('column-moved', this.onColumnMoved, this);*/ notjQuery(document).on('keydown','body', this.onKeyDown, this); - /*notjQuery(this.list).on('rendered', this.onRendered, this); - - - this.on('click', '.load-more[data-no-icinga-ajax] a', this.onLoadMoreClick, this); - this.on('keypress', '.load-more[data-no-icinga-ajax] a', this.onKeyPress, this);*/ + //notjQuery(this.list).on('rendered', this.onRendered, this); // this.onRendered(this.list); @@ -243,8 +238,7 @@ define(["../notjQuery"], function (notjQuery) { let focusedElement = document.activeElement; if ( - _this.isProcessingLoadMore - || ! event.key // input auto-completion is triggered + ! event.key // input auto-completion is triggered || (event.key.toLowerCase() !== 'a' && ! pressedArrowDownKey && ! pressedArrowUpKey) ) { return; @@ -305,9 +299,6 @@ define(["../notjQuery"], function (notjQuery) { toActiveItem = pressedArrowDownKey ? firstListItem : lastListItem; // reset all on manual page refresh _this.clearSelection(activeItems); - if (toActiveItem.classList.contains('load-more')) { - toActiveItem = toActiveItem.previousElementSibling; - } } else if (isMultiSelectableList && event.shiftKey) { if (activeItems.length === 1) { toActiveItem = directionalNextItem; @@ -334,15 +325,6 @@ define(["../notjQuery"], function (notjQuery) { } } else { toActiveItem = directionalNextItem; - - if (toActiveItem) { - if (toActiveItem.classList.contains('load-more')) { - clearTimeout(_this.lastTimeoutId); - _this.handleLoadMoreNavigate(toActiveItem, lastActivatedItem, event.key); - return; - } - } - while (toActiveItem) { if (toActiveItem.hasAttribute(this.removeBrackets(this.listItemIdentifier))) { _this.clearSelection(activeItems); @@ -564,111 +546,6 @@ define(["../notjQuery"], function (notjQuery) { return Array.from(items); } - /** - * Handle the navigation on load-more button - * - * @param loadMoreElement - * @param lastActivatedItem - * @param pressedKey Pressed key (`ArrowUp` or `ArrowDown`) - */ - handleLoadMoreNavigate(loadMoreElement, lastActivatedItem, pressedKey) { - let req = this.loadMore(loadMoreElement.firstChild); - this.isProcessingLoadMore = true; - req.done(() => { - this.isProcessingLoadMore = false; - // list has now new items, so select the lastActivatedItem and then move forward - let toActiveItem = lastActivatedItem.nextElementSibling; - while (toActiveItem) { - if (toActiveItem.hasAttribute(this.removeBrackets(this.listItemIdentifier))) { - this.clearSelection([lastActivatedItem]); - this.setActive(toActiveItem); - this.setLastActivatedItemUrl(toActiveItem.dataset.icingaDetailFilter); - this.scrollItemIntoView(toActiveItem, pressedKey); - this.addSelectionCountToFooter(toActiveItem.parentElement); - this.loadDetailUrl(toActiveItem.parentElement); - return; - } - - toActiveItem = toActiveItem.nextElementSibling; - } - }); - } - - /** - * Click on load-more button - * - * @param event - * - * @returns {boolean} - */ - onLoadMoreClick(event) { - event.stopPropagation(); - event.preventDefault(); - - event.data.self.loadMore(event.target); - - return false; - } - - onKeyPress(event) { - if (event.key === ' ') { // space - event.data.self.onLoadMoreClick(event); - } - } - - /** - * Load more list items based on the given anchor - * - * @param anchor - * - * @returns {*|{getAllResponseHeaders: function(): *|null, abort: function(*): this, setRequestHeader: function(*, *): this, readyState: number, getResponseHeader: function(*): null|*, overrideMimeType: function(*): this, statusCode: function(*): this}|jQuery|boolean} - */ - loadMore(anchor) { - let showMore = anchor.parentElement; - var progressTimer = this.icinga.timer.register(function () { - var label = anchor.innerText; - - var dots = label.substr(-3); - if (dots.slice(0, 1) !== '.') { - dots = '. '; - } else { - label = label.slice(0, -3); - if (dots === '...') { - dots = '. '; - } else if (dots === '.. ') { - dots = '...'; - } else if (dots === '. ') { - dots = '.. '; - } - } - - anchor.innerText = label + dots; - }, null, 250); - - let url = anchor.getAttribute('href'); - let req = this.icinga.loader.loadUrl( - // Add showCompact, we don't want controls in paged results - this.icinga.utils.addUrlFlag(url, 'showCompact'), - $(showMore.parentElement), - undefined, - undefined, - 'append', - false, - progressTimer - ); - req.addToHistory = false; - req.done(function () { - showMore.remove(); - - // Set data-icinga-url to make it available for Icinga.History.getCurrentState() - req.$target.closest('.container').data('icingaUrl', url); - - this.icinga.history.replaceCurrentState(); - }); - - return req; - } - /** * Create the detail url for multi selectable list *