Skip to content

Commit

Permalink
Fixed circulation desk list on update
Browse files Browse the repository at this point in the history
  • Loading branch information
Harel92 committed Jan 12, 2022
1 parent 8b966e8 commit fe54839
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion cloudapp/src/app/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export class Constants {
libraryTip =
"The library code of the given circulation desk or department where the action is being performed";
circTip =
"The circulation desk where the action is being performed. Send either this parameter or the department parameter. The circulation desk code should be entered";
"The circulation desk where the action is being performed. Send either this parameter or the department parameter.";
departmentTip =
"The department where the action is being performed. Send either this parameter or the circulation desk parameter. The department code should be entered";
statusTip = "The work order status to which we want to move the item.";
Expand Down
2 changes: 1 addition & 1 deletion cloudapp/src/app/settings/settings.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ <h1>Settings</h1>
required
#library="ngModel"
[(ngModel)]="config.mustConfig.library"
(selectionChange)="onLibraryChange($event)"
(selectionChange)="onLibraryChange($event.value)"
>
<mat-option *ngFor="let lib of libraries" [value]="lib.code">{{
lib.name
Expand Down
18 changes: 9 additions & 9 deletions cloudapp/src/app/settings/settings.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Constants } from "./../constants";
import { Library } from "./../models/library.model";
import { CirculationDesk } from "./../models/circulation-desk.model";
import { Component, ElementRef, OnInit, ViewChild } from "@angular/core";
import { Component, OnInit } from "@angular/core";
import { NgForm } from "@angular/forms";
import {
AlertService,
Expand All @@ -12,7 +12,6 @@ import {
import { Configuration } from "../models/configuration.model";
import { forkJoin } from "rxjs";
import { Router } from "@angular/router";
import { MatSelectChange } from "@angular/material/select";
import { finalize } from "rxjs/operators";

@Component({
Expand Down Expand Up @@ -42,13 +41,14 @@ export class SettingsComponent implements OnInit {
forkJoin({ rest, config }).subscribe({
next: (value) => {
this.libraries = value.rest.library as Library[];

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

if (value.config && Object.keys(value.config).length !== 0) {
this.config = value.config;
this.onLibraryChange(value.config.mustConfig.library, true);
}
},
error: (err) => {
Expand All @@ -67,7 +67,7 @@ export class SettingsComponent implements OnInit {
this.settingsService.set(this.config).subscribe({
next: () => {
this.alert.success("Updated Successfully", { keepAfterRouteChange: true });
this.router.navigate([""]);
this.router.navigate([""]);
},
error: (err: RestErrorResponse) => {
console.error(err.message);
Expand All @@ -78,18 +78,18 @@ export class SettingsComponent implements OnInit {
onRestore() {
this.config = new Configuration();
}
onLibraryChange(event: MatSelectChange){
onLibraryChange(circ_code: string, init=false){
this.loading = true;
let code = event.value;
let code = circ_code;
this.restService.call("/conf/libraries/"+code+"/circ-desks").pipe(finalize(
() => {
this.loading = false;
this.config.from.circ_desk = "";
if (!init) {
this.config.from.circ_desk = "";
}
})).subscribe({
next: (res) => {
this.circulation_desks = res.circ_desk
this.config.from.circ_desk

},
error: (err: RestErrorResponse) => {
this.circulation_desks = [];
Expand Down

0 comments on commit fe54839

Please sign in to comment.