From a0de03403be70741dfa6c6f18218bee7e8220c19 Mon Sep 17 00:00:00 2001 From: Simon Sippert Date: Tue, 22 Oct 2024 11:06:28 +0200 Subject: [PATCH] Remove overall section from list filter --- blocks/filter/filter-library.js | 6 +++++- scripts/list.js | 5 +++-- scripts/tenants.js | 7 +++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/blocks/filter/filter-library.js b/blocks/filter/filter-library.js index 7f6fd866..260d7050 100644 --- a/blocks/filter/filter-library.js +++ b/blocks/filter/filter-library.js @@ -9,6 +9,8 @@ * license@techdivision.com */ +import { sectionsForListItemsForAllTenants } from '../../scripts/tenants.js'; + /** * Get filter value for element * @@ -23,7 +25,9 @@ function getFilterValuesForElement(element, filterField) { } else { value = element.getAttribute(`data-${filterField}`)?.toString(); } - return value?.split(',') || []; + const values = value?.split(',').map((item) => item.trim()) || []; + return values.filter((item) => !sectionsForListItemsForAllTenants.map((gs) => gs.toLowerCase()) + .includes(item.toLowerCase())); } /** diff --git a/scripts/list.js b/scripts/list.js index 26b4e3dd..915a8efb 100644 --- a/scripts/list.js +++ b/scripts/list.js @@ -11,7 +11,7 @@ import { getCurrentUrl, getUrlParam, setUrlParam } from './helpers.js'; import { loadPlaceholders, tContent, ts } from './i18n.js'; -import { getTenants, getTenantUrl } from './tenants.js'; +import { getTenants, getTenantUrl, sectionsForListItemsForAllTenants } from './tenants.js'; import { defaultTenant, queryParamPage } from './defaults.js'; import { cachedFetch } from './load-resource.js'; @@ -436,7 +436,8 @@ async function decorateList(container, config, listType, renderer, itemManipulat [defaultTenant], await fetchListItems(listType), (item) => item.section.toLowerCase().split(',').some( - (s) => ['überall', 'overall', 'global'].includes(s.trim()), + (s) => sectionsForListItemsForAllTenants.map((gs) => gs.toLowerCase()) + .includes(s.trim().toLowerCase()), ), ); } else { diff --git a/scripts/tenants.js b/scripts/tenants.js index 0ad842f0..b42c300d 100644 --- a/scripts/tenants.js +++ b/scripts/tenants.js @@ -31,6 +31,13 @@ const tenants = { // lelycenterinbayern: 'https://main--eds-lelycenterinbayern--techdivision.aem.live/', }; +/** + * Sections for list items, that should be published on all tenants + * + * @type {string[]} + */ +export const sectionsForListItemsForAllTenants = ['Überall']; + /** * Get all tenant keys *