Skip to content
Snippets Groups Projects
Commit 6b292aab authored by lotte's avatar lotte
Browse files

53881: bugfixing facet search box

parent ac4a1b17
No related branches found
No related tags found
No related merge requests found
Showing
with 43 additions and 25 deletions
<div>
<div class="filters py-2">
<a *ngFor="let value of selectedValues" class="d-block"
<a *ngFor="let value of selectedValues" class="d-flex flex-row"
[routerLink]="[getSearchLink()]"
[queryParams]="getRemoveParams(value)" queryParamsHandling="merge">
<input type="checkbox" [checked]="true"/>
<span class="filter-value">{{value}}</span>
<input type="checkbox" [checked]="true" class="my-1 align-self-stretch"/>
<span class="filter-value pl-1">{{value}}</span>
</a>
<ng-container *ngFor="let page of (filterValues$ | async)">
<ng-container *ngFor="let value of (page | async)?.payload.page; let i=index">
<a *ngIf="!selectedValues.includes(value.value)" class="d-block clearfix"
<a *ngIf="!selectedValues.includes(value.value)" class="d-flex flex-row"
[routerLink]="[getSearchLink()]"
[queryParams]="getAddParams(value.value)" queryParamsHandling="merge" >
<input type="checkbox" [checked]="false"/>
<span class="filter-value">{{value.value}}</span>
<span class="float-right filter-value-count">
[queryParams]="getAddParams(value.value)" queryParamsHandling="merge">
<input type="checkbox" [checked]="false" class="my-1 align-self-stretch"/>
<span class="filter-value px-1">{{value.value}}</span>
<span class="float-right filter-value-count ml-auto">
<span class="badge badge-secondary badge-pill">{{value.count}}</span>
</span>
</a>
......@@ -34,7 +34,7 @@
[name]="filterConfig.paramName"
[(ngModel)]="filter"
(submitSuggestion)="onSubmit($event)"
(clickSuggestion)="clickFilter($event)"
(clickSuggestion)="onSubmit($event)"
(findSuggestions)="findSuggestions($event)"
[getDisplayValue]="getDisplayValue"
ngDefaultControl
......
......@@ -14,4 +14,7 @@
cursor: pointer;
}
}
::ng-deep em {
font-weight: bold;
font-style: normal;
}
......@@ -68,6 +68,7 @@ export class SearchFacetFilterComponent implements OnInit, OnDestroy {
this.filterValues$.next(this.filterValues);
newValues$.first().subscribe((rd) => this.isLastPage$.next(hasNoValue(rd.payload.next)));
});
this.filter = '';
}
isChecked(value: FacetValue): Observable<boolean> {
......@@ -99,7 +100,7 @@ export class SearchFacetFilterComponent implements OnInit, OnDestroy {
if (isNotEmpty(data)) {
this.router.navigate([this.getSearchLink()], {
queryParams:
{ [this.filterConfig.paramName]: [...this.selectedValues, data[this.filterConfig.paramName]] },
{ [this.filterConfig.paramName]: [...this.selectedValues, data] },
queryParamsHandling: 'merge'
});
this.filter = '';
......@@ -107,10 +108,6 @@ export class SearchFacetFilterComponent implements OnInit, OnDestroy {
this.filterSearchResults = Observable.of([]);
}
clickFilter(data: string) {
this.onSubmit({ [this.filterConfig.paramName]: data });
}
hasValue(o: any): boolean {
return hasValue(o);
}
......
<div>
<div (click)="toggle()" class="filter-name"><h5 class="d-inline-block mb-0">{{'search.filters.filter.' + filter.name + '.head'| translate}}</h5> <span class="filter-toggle fa float-right"
[ngClass]="(isCollapsed() | async) ? 'fa-plus' : 'fa-minus'"></span></div>
<div [@slide]="(isCollapsed() | async) ? 'collapsed' : 'expanded'" class="search-filter-wrapper">
<div [@slide]="(isCollapsed() | async) ? 'collapsed' : 'expanded'" (@slide.start)="startSlide($event)" (@slide.done)="finishSlide($event)" class="search-filter-wrapper" [ngClass]="{closed: collapsed}">
<ds-search-facet-filter [filterConfig]="filter" [selectedValues]="getSelectedValues() | async"></ds-search-facet-filter>
</div>
</div>
\ No newline at end of file
......@@ -3,10 +3,7 @@
:host {
border: 1px solid map-get($theme-colors, light);
>div {
position: relative;
}
.search-filter-wrapper {
.search-filter-wrapper.closed {
overflow: hidden;
}
.filter-toggle {
......
import { Component, Input, OnInit } from '@angular/core';
import { SearchFilterConfig } from '../../search-service/search-filter-config.model';
import { SearchService } from '../../search-service/search.service';
import { RemoteData } from '../../../core/data/remote-data';
import { FacetValue } from '../../search-service/facet-value.model';
import { SearchFilterService } from './search-filter.service';
import { Observable } from 'rxjs/Observable';
import { slide } from '../../../shared/animations/slide';
import { PaginatedList } from '../../../core/data/paginated-list';
/**
* This component renders a simple item page.
......@@ -23,6 +19,7 @@ import { PaginatedList } from '../../../core/data/paginated-list';
export class SearchFilterComponent implements OnInit {
@Input() filter: SearchFilterConfig;
collapsed;
constructor(private filterService: SearchFilterService) {
}
......@@ -47,13 +44,27 @@ export class SearchFilterComponent implements OnInit {
initialCollapse() {
this.filterService.initialCollapse(this.filter.name);
this.collapsed = true;
}
initialExpand() {
this.filterService.initialExpand(this.filter.name);
this.collapsed = false;
}
getSelectedValues(): Observable<string[]> {
return this.filterService.getSelectedValuesForFilter(this.filter);
}
finishSlide(event: any): void {
if (event.fromState === 'collapsed') {
this.collapsed = false;
}
}
startSlide(event: any): void {
if (event.toState === 'collapsed') {
this.collapsed = true;
}
}
}
<form #form="ngForm" (ngSubmit)="submitSuggestion.emit(form.value)"
<form #form="ngForm" (ngSubmit)="submitSuggestion.emit(ngModel)"
[action]="action" (keydown)="onKeydown($event)"
(keydown.arrowdown)="shiftFocusDown($event)"
(keydown.arrowup)="shiftFocusUp($event)" (keydown.esc)="close()"
......
......@@ -3,5 +3,14 @@
.dropdown-item {
white-space: normal;
word-break: break-word;
&:focus {
outline: none;
}
}
}
form {
> div {
position: relative;
}
}
\ No newline at end of file
......@@ -9,6 +9,7 @@ import {
} from '@angular/core';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
import { hasValue, isNotEmpty } from '../empty.util';
import { ActivatedRoute } from '@angular/router';
/**
* This component renders a simple item page.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment