Skip to content

Commit

Permalink
fix(admin-ui): Limit FacetValues in Facet list component
Browse files Browse the repository at this point in the history
Relates to #1257
  • Loading branch information
michaelbromley committed Jul 27, 2023
1 parent 09c7175 commit b445955
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,22 @@
<ng-template let-facet="item">
<div class="facet-values-list">
<vdr-facet-value-chip
*ngFor="let value of facet.values | slice : 0 : displayLimit[facet.id] || 3"
*ngFor="let value of facet.valueList.items | slice : 0 : displayLimit[facet.id] || 3"
[facetValue]="value"
[removable]="false"
[displayFacetName]="false"
></vdr-facet-value-chip>
<vdr-chip *ngIf="displayLimit[facet.id] < facet.valueList.totalItems && (displayLimit[facet.id] || 0) === facet.valueList.items.length">
... + {{ facet.valueList.totalItems - facet.valueList.items.length }}
</vdr-chip>
<button
class="button-small"
*ngIf="facet.values.length > initialLimit"
*ngIf="facet.valueList.items.length > initialLimit"
(click)="toggleDisplayLimit(facet)"
>
<ng-container *ngIf="(displayLimit[facet.id] || 0) < facet.values.length; else collapse">
<ng-container *ngIf="(displayLimit[facet.id] || 0) < facet.valueList.items.length; else collapse">
<clr-icon shape="plus"></clr-icon>
{{ facet.values.length - initialLimit }}
{{ facet.valueList.totalItems - initialLimit }}
</ng-container>
<ng-template #collapse>
<clr-icon shape="minus"></clr-icon>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Component, OnInit } from '@angular/core';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import {
DataService,
FACET_WITH_VALUE_LIST_FRAGMENT,
FACET_WITH_VALUES_FRAGMENT,
GetFacetListDocument,
GetFacetListQuery,
Expand All @@ -15,12 +16,12 @@ export const FACET_LIST_QUERY = gql`
query GetFacetList($options: FacetListOptions) {
facets(options: $options) {
items {
...FacetWithValues
...FacetWithValueList
}
totalItems
}
}
${FACET_WITH_VALUES_FRAGMENT}
${FACET_WITH_VALUE_LIST_FRAGMENT}
`;

@Component({
Expand Down Expand Up @@ -82,10 +83,10 @@ export class FacetListComponent
}

toggleDisplayLimit(facet: ItemOf<GetFacetListQuery, 'facets'>) {
if (this.displayLimit[facet.id] === facet.values.length) {
if (this.displayLimit[facet.id] === facet.valueList.items.length) {
this.displayLimit[facet.id] = this.initialLimit;
} else {
this.displayLimit[facet.id] = facet.values.length;
this.displayLimit[facet.id] = facet.valueList.items.length;
}
}

Expand Down
Loading

0 comments on commit b445955

Please sign in to comment.