From a78210f76745640507005b7a429d3fbb36da21a1 Mon Sep 17 00:00:00 2001 From: Jamie Little Date: Wed, 15 Nov 2023 15:45:19 -0600 Subject: [PATCH] Add Filters This adds a filter input that allows you to filter the pick list by either the request date or the or pickup location. --- cloudapp/src/app/app.module.ts | 2 ++ cloudapp/src/app/main/main.component.html | 32 ++++++++++++++++++++--- cloudapp/src/app/main/main.component.scss | 25 +++++------------- cloudapp/src/app/main/main.component.ts | 23 ++++++++++++++++ 4 files changed, 60 insertions(+), 22 deletions(-) diff --git a/cloudapp/src/app/app.module.ts b/cloudapp/src/app/app.module.ts index 7e9ab26..76b5b89 100644 --- a/cloudapp/src/app/app.module.ts +++ b/cloudapp/src/app/app.module.ts @@ -10,6 +10,7 @@ import { AppRoutingModule } from './app-routing.module'; import { MainComponent } from './main/main.component'; import { PrintButtonComponent } from './print-button/print-button.component'; import { ApplySortPipe } from './main/apply_sort_pipe'; +import { MatInputModule } from '@angular/material/input'; @NgModule({ declarations: [ @@ -21,6 +22,7 @@ import { ApplySortPipe } from './main/apply_sort_pipe'; imports: [ MaterialModule, BrowserModule, + MatInputModule, BrowserAnimationsModule, AppRoutingModule, HttpClientModule, diff --git a/cloudapp/src/app/main/main.component.html b/cloudapp/src/app/main/main.component.html index c87e9d8..a283e86 100644 --- a/cloudapp/src/app/main/main.component.html +++ b/cloudapp/src/app/main/main.component.html @@ -2,6 +2,8 @@ + +
@@ -19,7 +21,9 @@
- +
+
+ Sort Selection Sort by RMST @@ -28,13 +32,30 @@

+ + + + + Filter By + + Pickup Location + Request Date + + + + + Filter Text + + + +
-
-
+
+
{{ i+1 }}. {{ resource.resource_metadata.title }} @@ -47,6 +68,11 @@ Request {{ request.id }} +
+ + Warning! No copy information provided with request. + +
RMST
{{ copy.storage_location_id }}
diff --git a/cloudapp/src/app/main/main.component.scss b/cloudapp/src/app/main/main.component.scss index b99951f..d926295 100644 --- a/cloudapp/src/app/main/main.component.scss +++ b/cloudapp/src/app/main/main.component.scss @@ -10,25 +10,8 @@ .remove-button { display: none; } - - dl { - display: flex; - flex-direction: row; - flex-wrap: wrap; - border-collapse: collapse; - width: 100%; - margin: 0; - padding: 0; - } - - dt, dd { - display: flex; - flex: 1 1 auto; - justify-content: space-between; - align-items: center; - margin-left: 0; - padding: .25em; - box-sizing: border-box; + .wide { + display: none; } } @@ -53,3 +36,7 @@ dt, dd { dt { font-weight: bold; } + +.wide { + width: 95% +} diff --git a/cloudapp/src/app/main/main.component.ts b/cloudapp/src/app/main/main.component.ts index 59677b0..59d2e2d 100644 --- a/cloudapp/src/app/main/main.component.ts +++ b/cloudapp/src/app/main/main.component.ts @@ -20,6 +20,8 @@ export class MainComponent implements OnInit, OnDestroy { currentlyAtLibCode: string; curentlyAtCircDeskCode: string; selectedSort = 'storageLocationIdSort'; + filterText: string = ''; + selectedFilterType: string = 'pickupLocation'; constructor( private alert: AlertService, @@ -96,6 +98,27 @@ export class MainComponent implements OnInit, OnDestroy { } } + getFilteredResources(): RequestedResource[] { + if (!this.filterText) { + return this.getVisibleResources(); + } + + return this.getVisibleResources().filter(resource => { + return resource.request.some(request => { + switch (this.selectedFilterType) { + case 'pickupLocation': + return request.destination.desc.toLowerCase().includes(this.filterText.toLowerCase()); + case 'requestDate': + + return new Date(request.request_time).toDateString().toLowerCase().includes(this.filterText.toLowerCase()); + default: + return false; + } + }); + }); + } + + ngOnDestroy(): void { } }