From 7f68fef7ad2135696ae8cae0dc967e9ebcb3db91 Mon Sep 17 00:00:00 2001 From: Maximilian Krambach Date: Mon, 21 Jan 2019 11:44:08 +0100 Subject: [PATCH] search History --- .../os-sort-filter-bar.component.html | 47 +++++++++---------- .../history-list/history-list.component.html | 6 +++ .../history-list/history-list.component.ts | 37 ++++++++++++++- client/src/styles.scss | 13 +---- 4 files changed, 65 insertions(+), 38 deletions(-) diff --git a/client/src/app/shared/components/os-sort-filter-bar/os-sort-filter-bar.component.html b/client/src/app/shared/components/os-sort-filter-bar/os-sort-filter-bar.component.html index 86bbad96a..beea3aacc 100644 --- a/client/src/app/shared/components/os-sort-filter-bar/os-sort-filter-bar.component.html +++ b/client/src/app/shared/components/os-sort-filter-bar/os-sort-filter-bar.component.html @@ -4,27 +4,23 @@  {{ filterService.totalCount }}
-
- Active filters:  -
-
- -
-
- -
+
Active filters
+
+ +
+
+ +
- + + + diff --git a/client/src/app/site/history/components/history-list/history-list.component.html b/client/src/app/site/history/components/history-list/history-list.component.html index c6236fa77..874da32ca 100644 --- a/client/src/app/site/history/components/history-list/history-list.component.html +++ b/client/src/app/site/history/components/history-list/history-list.component.html @@ -8,6 +8,12 @@
+
+ + + search + +
diff --git a/client/src/app/site/history/components/history-list/history-list.component.ts b/client/src/app/site/history/components/history-list/history-list.component.ts index 1f660646d..39262824d 100644 --- a/client/src/app/site/history/components/history-list/history-list.component.ts +++ b/client/src/app/site/history/components/history-list/history-list.component.ts @@ -48,6 +48,7 @@ export class HistoryListComponent extends ListViewBaseComponent imp public ngOnInit(): void { super.setTitle('History'); this.initTable(); + this.setFilters(); this.repo.getViewModelListObservable().subscribe(history => { this.sortAndPublish(history); @@ -115,7 +116,7 @@ export class HistoryListComponent extends ListViewBaseComponent imp * * @param information history information string */ - public parseInformation(information: string): void { + public parseInformation(information: string): string { if (information.length) { const base_string = this.translate.instant(information[0]); let argument_string; @@ -125,4 +126,38 @@ export class HistoryListComponent extends ListViewBaseComponent imp return base_string.replace(/\\{arg1\\}/g, argument_string); } } + + /** + * Handles the search fields' inputs + * + * @param value: a filter string. Matching is case-insensitive + */ + public applySearch(value: string): void { + this.dataSource.filter = value; + } + + /** + * Overwrites the dataSource's string filter with a more advanced option + * using the display methods of this class. + */ + private setFilters(): void { + this.dataSource.filterPredicate = (data, filter) => { + filter = filter.toLowerCase(); + if ( + this.getElementInfo(data) + .toLowerCase() + .indexOf(filter) >= 0 + ) { + return true; + } + if (data.user.full_name.toLowerCase().indexOf(filter) >= 0) { + return true; + } + return ( + this.parseInformation(data.information) + .toLowerCase() + .indexOf(filter) >= 0 + ); + }; + } } diff --git a/client/src/styles.scss b/client/src/styles.scss index 97cafae9a..3dfc1512d 100644 --- a/client/src/styles.scss +++ b/client/src/styles.scss @@ -205,18 +205,10 @@ mat-card { position: relative; max-width: 400px; z-index: 2; - background-color: #eee; padding-right: 5px; margin-right: 0px; } - input.vp { - margin-left: -100%; - max-width: 100%; - animation-name: fadeIn; - animation-duration: 0.3s; - } - mat-icon { vertical-align: text-bottom; } @@ -411,7 +403,7 @@ button.mat-menu-item.selected { margin: 0 25px; } .content-container h1 { - font-size: 30px + font-size: 30px; } } /* small */ @@ -420,11 +412,10 @@ button.mat-menu-item.selected { margin: 0 15px; } .content-container h1 { - font-size: 30px + font-size: 30px; } } - /** more helper classes **/ .center { text-align: center;