Skip to content
Snippets Groups Projects
Commit 75124e15 authored by Adam G-H's avatar Adam G-H Committed by Tim Plunkett
Browse files

Issue #3511079 by phenaproxima, tim.plunkett, utkarsh_33: [Svelte] Remove...

Issue #3511079 by phenaproxima, tim.plunkett, utkarsh_33: [Svelte] Remove special-casing of the 'categories' filter
parent 4ac6f675
Branches
Tags
1 merge request!770Issue #3511079: Remove special-casing for categories
Pipeline #441113 canceled
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
......@@ -198,20 +198,20 @@
pb-filter__multi-dropdown__items--{filterVisible ? 'visible' : 'hidden'}"
bind:this={dropdownItemsElement}
>
{#each Object.entries(choices) as [id, name]}
{#each Object.entries(choices) as [id, label]}
<div class="pb-filter__checkbox__container">
<label for={id}>
<input
type="checkbox"
{id}
class="pb-filter__checkbox form-checkbox form-boolean form-boolean--type-checkbox"
bind:group={$filters.categories}
bind:group={$filters[name]}
on:change={onChange}
on:blur={onBlur}
on:keydown={onKeyDown}
value={id}
/>
{name}
{label}
</label>
</div>
{/each}
......
......@@ -16,6 +16,12 @@
export let filterDefinitions;
export let sorts;
// List all of the multiple-choice filters, which will be amalgamated into
// a lozenge cloud.
const multipleChoiceFilterNames = Object.keys(filterDefinitions).filter(
(name) => filterDefinitions[name]._type === 'multiple_choice',
);
if (!($sort in sorts)) {
// eslint-disable-next-line prefer-destructuring
$sort = Object.keys(sorts)[0];
......@@ -115,21 +121,18 @@
aria-label={Drupal.t('Search results')}
>
<div class="search__results-count">
{#if 'categories' in $filters}
{#each $filters.categories as category}
{#each multipleChoiceFilterNames as name}
{#each $filters[name] as value}
<FilterApplied
label={filterDefinitions.categories.choices[category]}
label={filterDefinitions[name].choices[value]}
clickHandler={() => {
$filters.categories.splice(
$filters.categories.indexOf(category),
1,
);
$filters.categories = $filters.categories;
$filters[name].splice($filters[name].indexOf(value), 1);
$filters[name] = $filters[name];
onFilterChange();
}}
/>
{/each}
{/if}
{/each}
<button
class="search__filter-button"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment