Skip to content

Commit

Permalink
Add Filters
Browse files Browse the repository at this point in the history
This adds a filter input that allows you to filter
the pick list by either the request date or the
or pickup location.
  • Loading branch information
little9 committed Nov 15, 2023
1 parent 30a4317 commit a78210f
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 22 deletions.
2 changes: 2 additions & 0 deletions cloudapp/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand All @@ -21,6 +22,7 @@ import { ApplySortPipe } from './main/apply_sort_pipe';
imports: [
MaterialModule,
BrowserModule,
MatInputModule,
BrowserAnimationsModule,
AppRoutingModule,
HttpClientModule,
Expand Down
32 changes: 29 additions & 3 deletions cloudapp/src/app/main/main.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<mat-progress-spinner mode="indeterminate" diameter="50"></mat-progress-spinner>
</div>



<div *ngIf="requestedResources">
<mat-card>
<mat-card-title-group>
Expand All @@ -19,7 +21,9 @@
<div *ngIf="!loading">
<app-print-button></app-print-button>

<mat-form-field class="sort" appearance="fill">
<br>
<br>
<mat-form-field class="sort" appearance="outline" class="wide">
<mat-label>Sort Selection</mat-label>
<mat-select [(value)]="selectedSort" title="Sort Selection">
<mat-option value="storageLocationIdSort">Sort by RMST</mat-option>
Expand All @@ -28,13 +32,30 @@
</mat-form-field>
<br/>
<br/>



<mat-form-field appearance="outline" class="wide">
<mat-label>Filter By</mat-label>
<mat-select [(value)]="selectedFilterType">
<mat-option value="pickupLocation">Pickup Location</mat-option>
<mat-option value="requestDate">Request Date</mat-option>
</mat-select>
</mat-form-field>

<mat-form-field appearance="outline" class="wide">
<mat-label>Filter Text</mat-label>
<input matInput [(ngModel)]="filterText" placeholder="Type to filter...">
</mat-form-field>


</div>
</mat-card-content>
</mat-card>

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

<mat-card-content>
<div *ngIf="resource.location.copy.length === 0">
<mat-card>
Warning! No copy information provided with request.
</mat-card>
</div>
<dl *ngFor="let copy of resource.location.copy">
<dt><strong>RMST</strong></dt>
<dd>{{ copy.storage_location_id }}</dd>
Expand Down
25 changes: 6 additions & 19 deletions cloudapp/src/app/main/main.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand All @@ -53,3 +36,7 @@ dt, dd {
dt {
font-weight: bold;
}

.wide {
width: 95%
}
23 changes: 23 additions & 0 deletions cloudapp/src/app/main/main.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
}
}

0 comments on commit a78210f

Please sign in to comment.