Skip to content

Commit a78210f

Browse files
committed
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.
1 parent 30a4317 commit a78210f

File tree

4 files changed

+60
-22
lines changed

4 files changed

+60
-22
lines changed

cloudapp/src/app/app.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { AppRoutingModule } from './app-routing.module';
1010
import { MainComponent } from './main/main.component';
1111
import { PrintButtonComponent } from './print-button/print-button.component';
1212
import { ApplySortPipe } from './main/apply_sort_pipe';
13+
import { MatInputModule } from '@angular/material/input';
1314

1415
@NgModule({
1516
declarations: [
@@ -21,6 +22,7 @@ import { ApplySortPipe } from './main/apply_sort_pipe';
2122
imports: [
2223
MaterialModule,
2324
BrowserModule,
25+
MatInputModule,
2426
BrowserAnimationsModule,
2527
AppRoutingModule,
2628
HttpClientModule,

cloudapp/src/app/main/main.component.html

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
<mat-progress-spinner mode="indeterminate" diameter="50"></mat-progress-spinner>
33
</div>
44

5+
6+
57
<div *ngIf="requestedResources">
68
<mat-card>
79
<mat-card-title-group>
@@ -19,7 +21,9 @@
1921
<div *ngIf="!loading">
2022
<app-print-button></app-print-button>
2123

22-
<mat-form-field class="sort" appearance="fill">
24+
<br>
25+
<br>
26+
<mat-form-field class="sort" appearance="outline" class="wide">
2327
<mat-label>Sort Selection</mat-label>
2428
<mat-select [(value)]="selectedSort" title="Sort Selection">
2529
<mat-option value="storageLocationIdSort">Sort by RMST</mat-option>
@@ -28,13 +32,30 @@
2832
</mat-form-field>
2933
<br/>
3034
<br/>
35+
36+
37+
38+
<mat-form-field appearance="outline" class="wide">
39+
<mat-label>Filter By</mat-label>
40+
<mat-select [(value)]="selectedFilterType">
41+
<mat-option value="pickupLocation">Pickup Location</mat-option>
42+
<mat-option value="requestDate">Request Date</mat-option>
43+
</mat-select>
44+
</mat-form-field>
45+
46+
<mat-form-field appearance="outline" class="wide">
47+
<mat-label>Filter Text</mat-label>
48+
<input matInput [(ngModel)]="filterText" placeholder="Type to filter...">
49+
</mat-form-field>
50+
51+
3152
</div>
3253
</mat-card-content>
3354
</mat-card>
3455

3556
<div>
36-
<div *ngFor="let resource of getVisibleResources() | applySort:selectedSort; index as i">
37-
<div *ngIf="resource.location.copy[0]">
57+
<div *ngFor="let resource of getFilteredResources() | applySort:selectedSort; index as i">
58+
<div>
3859
<mat-card>
3960
<mat-card-title-group>
4061
<mat-card-title><b></b>{{ i+1 }}. {{ resource.resource_metadata.title }} </mat-card-title>
@@ -47,6 +68,11 @@
4768
<legend>Request {{ request.id }}</legend>
4869

4970
<mat-card-content>
71+
<div *ngIf="resource.location.copy.length === 0">
72+
<mat-card>
73+
Warning! No copy information provided with request.
74+
</mat-card>
75+
</div>
5076
<dl *ngFor="let copy of resource.location.copy">
5177
<dt><strong>RMST</strong></dt>
5278
<dd>{{ copy.storage_location_id }}</dd>

cloudapp/src/app/main/main.component.scss

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,8 @@
1010
.remove-button {
1111
display: none;
1212
}
13-
14-
dl {
15-
display: flex;
16-
flex-direction: row;
17-
flex-wrap: wrap;
18-
border-collapse: collapse;
19-
width: 100%;
20-
margin: 0;
21-
padding: 0;
22-
}
23-
24-
dt, dd {
25-
display: flex;
26-
flex: 1 1 auto;
27-
justify-content: space-between;
28-
align-items: center;
29-
margin-left: 0;
30-
padding: .25em;
31-
box-sizing: border-box;
13+
.wide {
14+
display: none;
3215
}
3316
}
3417

@@ -53,3 +36,7 @@ dt, dd {
5336
dt {
5437
font-weight: bold;
5538
}
39+
40+
.wide {
41+
width: 95%
42+
}

cloudapp/src/app/main/main.component.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ export class MainComponent implements OnInit, OnDestroy {
2020
currentlyAtLibCode: string;
2121
curentlyAtCircDeskCode: string;
2222
selectedSort = 'storageLocationIdSort';
23+
filterText: string = '';
24+
selectedFilterType: string = 'pickupLocation';
2325

2426
constructor(
2527
private alert: AlertService,
@@ -96,6 +98,27 @@ export class MainComponent implements OnInit, OnDestroy {
9698
}
9799
}
98100

101+
getFilteredResources(): RequestedResource[] {
102+
if (!this.filterText) {
103+
return this.getVisibleResources();
104+
}
105+
106+
return this.getVisibleResources().filter(resource => {
107+
return resource.request.some(request => {
108+
switch (this.selectedFilterType) {
109+
case 'pickupLocation':
110+
return request.destination.desc.toLowerCase().includes(this.filterText.toLowerCase());
111+
case 'requestDate':
112+
113+
return new Date(request.request_time).toDateString().toLowerCase().includes(this.filterText.toLowerCase());
114+
default:
115+
return false;
116+
}
117+
});
118+
});
119+
}
120+
121+
99122
ngOnDestroy(): void {
100123
}
101124
}

0 commit comments

Comments
 (0)