Skip to content

Commit

Permalink
Remove overall section from list filter
Browse files Browse the repository at this point in the history
  • Loading branch information
sippsolutions committed Oct 22, 2024
1 parent 6e0b249 commit a0de034
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
6 changes: 5 additions & 1 deletion blocks/filter/filter-library.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
* [email protected]
*/

import { sectionsForListItemsForAllTenants } from '../../scripts/tenants.js';

/**
* Get filter value for element
*
Expand All @@ -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()));
}

/**
Expand Down
5 changes: 3 additions & 2 deletions scripts/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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 {
Expand Down
7 changes: 7 additions & 0 deletions scripts/tenants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down

0 comments on commit a0de034

Please sign in to comment.