Skip to content

Commit

Permalink
Enrich Bulk Scan-In cloud app
Browse files Browse the repository at this point in the history
Show dropdown values for "Department", "Word order type" and "Status"
  • Loading branch information
YehuditAdler committed Jan 1, 2024
1 parent 7a51421 commit 808a175
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 19 deletions.
8 changes: 8 additions & 0 deletions cloudapp/src/app/models/departments.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export interface Departments {
code: string;
name: string;
type: {
value :string
};
}

6 changes: 6 additions & 0 deletions cloudapp/src/app/models/statuses.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export interface Statuses {
column0: string;
column1: string;
column2: string;
}

36 changes: 23 additions & 13 deletions cloudapp/src/app/settings/settings.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ <h1>Settings</h1>
name="circ_desk"
[(ngModel)]="config.from.circ_desk"
#circ_desk
(selectionChange)="onCircDeskOrDepartmentChange(config.from.circ_desk,config.from.department)"
>
<mat-option *ngFor="let circ of circulation_desks" [value]="circ.code">{{
circ.name
Expand All @@ -74,15 +75,18 @@ <h1>Settings</h1>
</mat-form-field>
<mat-form-field>
<mat-label>Department</mat-label>
<input
matInput
type="text"
[matTooltip]="constants.departmentTip"
<mat-select
ngModel
name="department"
[matTooltip]="constants.departmentTip"
[(ngModel)]="config.from.department"
(selectionChange)="onCircDeskOrDepartmentChange(config.from.circ_desk,config.from.department)"
#department
/>
>
<mat-option *ngFor="let department of departments" [value]="department.code">{{
department.name
}}</mat-option>
</mat-select>
</mat-form-field>
</div>
<span *ngIf="!from.valid && from.touched"
Expand All @@ -92,26 +96,32 @@ <h1>Settings</h1>
>
<mat-form-field>
<mat-label>Work order type</mat-label>
<input
matInput
type="text"
<mat-select
[matTooltip]="constants.workOrderTypeTip"
ngModel
name="work_order_type"
[(ngModel)]="config.mustConfig.work_order_type"
#work_order_type
/>
(selectionChange)="onWorkOrderTypeChange($event.value)"
>
<mat-option *ngFor="let type of work_order_types" [value]="type">{{
type
}}</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field>
<mat-label>Status</mat-label>
<input
matInput
type="text"
<mat-select
#status
[matTooltip]="constants.statusTip"
ngModel
name="status"
[(ngModel)]="config.mustConfig.status"
/>
>
<mat-option *ngFor="let status of statuses" [value]="status.column1">{{
status.column2
}}</mat-option>
</mat-select>
</mat-form-field>

<mat-slide-toggle
Expand Down
88 changes: 82 additions & 6 deletions cloudapp/src/app/settings/settings.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import {
import { Configuration } from "../models/configuration.model";
import { forkJoin } from "rxjs";
import { Router } from "@angular/router";
import { finalize } from "rxjs/operators";
import { finalize, map } from "rxjs/operators";
import { Departments } from "../models/departments.model";
import { Statuses } from "../models/statuses.model";

@Component({
selector: "app-settings",
Expand All @@ -24,7 +26,10 @@ export class SettingsComponent implements OnInit {
config: Configuration = new Configuration();
libraries: Library[] = [];
circulation_desks: CirculationDesk[] = [];
departments : Departments[] = [];
statuses : Statuses[] = [];
loading: boolean = false;
work_order_types :string[] =[];

constructor(
private settingsService: CloudAppSettingsService,
Expand All @@ -42,7 +47,7 @@ export class SettingsComponent implements OnInit {
next: (value) => {
this.libraries = value.rest.library as Library[];

let emptyLib: Library = { link:"", code:"INST_LEVEL", path:"", name:"Institution Level", description:"",
let emptyLib: Library = { link:"", code:"", path:"", name:"Institution Level", description:"",
resource_sharing:null, campus: null, proxy:"", default_location:null};
this.libraries.unshift(emptyLib);

Expand Down Expand Up @@ -81,20 +86,91 @@ export class SettingsComponent implements OnInit {
onLibraryChange(circ_code: string, init=false){
this.loading = true;
let code = circ_code;
this.restService.call("/conf/libraries/"+code+"/circ-desks").pipe(finalize(
this.work_order_types = [];
this.statuses =[];
if (!init) {
this.config.from.circ_desk = "";
this.config.from.department = "";
}

let rests = [this.restService.call("/conf/departments?library="+code)];
if(code != ''){
rests.push(this.restService.call("/conf/libraries/"+code+"/circ-desks"));
}

forkJoin(rests)
.pipe(finalize(
() => {
this.loading = false;
if (!init) {
this.config.from.circ_desk = "";
}
})).subscribe({
next: (res) => {
this.circulation_desks = res.circ_desk
}))
.subscribe({
next: (res ) => {
this.departments = res[0].department;
this.departments.unshift({name : ' ',code:'',type:{value : ' '} });
if(res.length >1){
this.circulation_desks = res[1].circ_desk
this.circulation_desks.unshift({name : ' ',code:'',link:''});
}

},
error: (err: RestErrorResponse) => {
this.circulation_desks = [];
this.departments = [];
console.error(err.message);
}
});

}


onCircDeskOrDepartmentChange(circ_desk : string,department_code: string){
this.work_order_types =[];
this.statuses =[];
if(circ_desk != undefined && circ_desk != ''){
this.restService.call("/conf/departments?library="+this.config.mustConfig.library).pipe(finalize(
() => {
this.loading = false;
})).subscribe({
next: (res) => {
res.department.forEach(department => department.circ_desk?.value === circ_desk ? this.work_order_types.push(department.type.value): '');
this.work_order_types.unshift(' ');
},
error: (err: RestErrorResponse) => {
console.error(err.message);
}
});
}else if(department_code != undefined && department_code != ''){
this.onDepartmentChange(department_code);
}
}

onDepartmentChange(department_code: string){
this.departments.forEach(d => {
if(d.code == department_code){
this.work_order_types = [d.type.value];
this.onWorkOrderTypeChange(d.type.value);
return;
}
});
}

onWorkOrderTypeChange(work_order_type: string){
this.restService.call("/conf/mapping-tables/WorkOrderTypeStatuses?scope="+this.config.mustConfig.library).pipe(finalize(
() => {
this.loading = false;
})).subscribe({
next: (res) => {
this.statuses = res.row.filter(row => row.column0 ==work_order_type );
this.statuses.unshift({column2 : ' ',column1 : ' ',column0:''});
},
error: (err: RestErrorResponse) => {
this.statuses = [];
console.error(err.message);
}
});
}

}

0 comments on commit 808a175

Please sign in to comment.