-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Full width search bar + explicit action buttons for search facets (#1434
) * Full width search bar (#1426) * First steps * Beautify * Use shared search bar component * Remove search bar from facets * Some clean ups * Some clean ups * Some clean ups * Code formatting * Separating full text search from shared search bar * Add search and clear buttons; some clean ups * Fix lint issue * Fix lint issue * Fix lint issue * Explicit action button search facets (#1457) * Change label * Add button * Add button * Full width search bar (#1426) * First steps * Beautify * Use shared search bar component * Remove search bar from facets * Some clean ups * Some clean ups * Some clean ups * Code formatting * Fix layout * Add functionality to the button * Fix lint issue, finally?! * Fix lint issue, finally! * Fix tests * Click Search button after typing search query * Refactor full text search * Apply prettier * Convert onChange to reactive stream * Fix elastic search test * refactored fulltext-searchbar component and minor css changes for the search bar container * test fix for naming change of the clear button to reset button --------- Co-authored-by: junjiequan <[email protected]>
- Loading branch information
1 parent
3d8220b
commit f137de8
Showing
13 changed files
with
204 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
|
||
|
||
mat-sidenav-container { | ||
mat-sidenav-content { | ||
padding: 0.5rem; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/app/datasets/dashboard/full-text-search/full-text-search-bar.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<mat-card> | ||
<div class="search-card-container"> | ||
<mat-form-field appearance="fill" class="full-text-search-field"> | ||
<mat-label>Search</mat-label> | ||
<input | ||
matInput | ||
placeholder="Type to search..." | ||
type="search" | ||
[(ngModel)]="searchTerm" | ||
(ngModelChange)="onSearchTermChange($event)" | ||
/> | ||
</mat-form-field> | ||
<div class="search-button-group"> | ||
<button | ||
mat-flat-button | ||
color="accent" | ||
data-cy="search-button" | ||
(click)="onSearch()" | ||
> | ||
<mat-icon>search</mat-icon> | ||
Search | ||
</button> | ||
<button mat-flat-button data-cy="search-clear-button" (click)="onClear()"> | ||
<mat-icon>close</mat-icon> | ||
Clear | ||
</button> | ||
</div> | ||
</div> | ||
</mat-card> |
19 changes: 19 additions & 0 deletions
19
src/app/datasets/dashboard/full-text-search/full-text-search-bar.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
mat-card { | ||
padding: 0.4em; | ||
margin: 1.5em 0.5em 0.5em; | ||
|
||
.search-card-container { | ||
display: flex; | ||
width: 100%; | ||
align-items: center; | ||
margin: 0.5em; | ||
} | ||
.search-button-group { | ||
flex-shrink: 0.6; | ||
margin: 0 0.5em; | ||
} | ||
|
||
mat-form-field.full-text-search-field { | ||
flex: 1; | ||
} | ||
} |
Empty file.
96 changes: 96 additions & 0 deletions
96
src/app/datasets/dashboard/full-text-search/full-text-search-bar.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import { Component, Input, OnDestroy, OnInit } from "@angular/core"; | ||
import { FormsModule, ReactiveFormsModule } from "@angular/forms"; | ||
import { MatSelectModule } from "@angular/material/select"; | ||
import { MatFormFieldModule } from "@angular/material/form-field"; | ||
import { MatInputModule } from "@angular/material/input"; | ||
import { MatCardModule } from "@angular/material/card"; | ||
import { MatIconModule } from "@angular/material/icon"; | ||
import { MatButtonModule } from "@angular/material/button"; | ||
import { | ||
fetchDatasetsAction, | ||
fetchFacetCountsAction, | ||
setSearchTermsAction, | ||
setTextFilterAction, | ||
} from "../../../state-management/actions/datasets.actions"; | ||
import { Store } from "@ngrx/store"; | ||
import { BehaviorSubject, Subject, Subscription } from "rxjs"; | ||
import { | ||
debounceTime, | ||
distinctUntilChanged, | ||
withLatestFrom, | ||
} from "rxjs/operators"; | ||
import { selectSearchTerms } from "../../../state-management/selectors/datasets.selectors"; | ||
|
||
@Component({ | ||
selector: "full-text-search-bar", | ||
templateUrl: "./full-text-search-bar.component.html", | ||
styleUrls: ["./full-text-search-bar.component.scss"], | ||
standalone: true, | ||
imports: [ | ||
MatFormFieldModule, | ||
MatSelectModule, | ||
FormsModule, | ||
ReactiveFormsModule, | ||
MatInputModule, | ||
MatIconModule, | ||
MatCardModule, | ||
MatButtonModule, | ||
], | ||
}) | ||
export class FullTextSearchBarComponent implements OnInit, OnDestroy { | ||
@Input() prefilledValue = ""; | ||
@Input() placeholder = "Text Search"; | ||
@Input() clear: boolean; | ||
|
||
searchTerm = ""; | ||
|
||
searchTermSubject = new BehaviorSubject<string>(""); | ||
searchClickSubject = new Subject<void>(); | ||
subscriptions: Subscription[] = []; | ||
|
||
constructor(private store: Store) {} | ||
|
||
ngOnInit(): void { | ||
this.searchTermSubject.next(this.prefilledValue); | ||
|
||
this.subscriptions.push( | ||
this.searchTermSubject | ||
.pipe(debounceTime(200), distinctUntilChanged()) | ||
.subscribe((terms) => { | ||
console.log(`set terms: ${terms}`); | ||
this.store.dispatch(setSearchTermsAction({ terms })); | ||
this.store.dispatch(setTextFilterAction({ text: terms })); | ||
}), | ||
); | ||
|
||
const searchTerms$ = this.store.select(selectSearchTerms); | ||
|
||
this.subscriptions.push( | ||
this.searchClickSubject | ||
.pipe(debounceTime(250), withLatestFrom(searchTerms$)) | ||
.subscribe(([_, terms]) => { | ||
console.log(`latest terms: ${terms}`); | ||
this.store.dispatch(fetchDatasetsAction()); | ||
this.store.dispatch(fetchFacetCountsAction()); | ||
}), | ||
); | ||
} | ||
|
||
onSearch(): void { | ||
this.searchClickSubject.next(); | ||
} | ||
|
||
onSearchTermChange(terms: string) { | ||
this.searchTermSubject.next(terms); | ||
} | ||
|
||
onClear(): void { | ||
this.searchTerm = ""; | ||
this.searchTermSubject.next(undefined); | ||
this.searchClickSubject.next(); | ||
} | ||
|
||
ngOnDestroy(): void { | ||
this.subscriptions.forEach((s) => s.unsubscribe()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters