From 80c4ed5251c48a8210893e0207c5ed61d02930e1 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 2 Mar 2020 14:17:55 -0500 Subject: [PATCH] LPXXX Missing pieces angular port WIP Signed-off-by: Bill Erickson --- .../src/app/staff/sandbox/sandbox.component.html | 8 ++ .../eg2/src/app/staff/sandbox/sandbox.component.ts | 7 ++ .../eg2/src/app/staff/sandbox/sandbox.module.ts | 4 +- .../app/staff/share/holdings/holdings.service.ts | 5 ++ .../src/app/staff/share/patron/patron.module.ts | 7 +- .../share/patron/penalty-dialog.component.html | 55 +++++++++++++ .../staff/share/patron/penalty-dialog.component.ts | 91 ++++++++++++++++++++++ 7 files changed, 174 insertions(+), 3 deletions(-) create mode 100644 Open-ILS/src/eg2/src/app/staff/share/patron/penalty-dialog.component.html create mode 100644 Open-ILS/src/eg2/src/app/staff/share/patron/penalty-dialog.component.ts diff --git a/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.html b/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.html index 3b9609b399..1f8db17977 100644 --- a/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.html +++ b/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.html @@ -405,6 +405,14 @@
+

Add Patron Penalty

+ + +
+ +

Grid Stock Selector Display and Filtering

console.log('penalty value', val)); + } } diff --git a/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.module.ts b/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.module.ts index a33deb86ce..7864052860 100644 --- a/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.module.ts @@ -7,6 +7,7 @@ import {SandboxComponent} from './sandbox.component'; import {ReactiveFormsModule} from '@angular/forms'; import {SampleDataService} from '@eg/share/util/sample-data.service'; import {OrgFamilySelectModule} from '@eg/share/org-family-select/org-family-select.module'; +import {PatronModule} from '@eg/staff/share/patron/patron.module'; @NgModule({ declarations: [ @@ -18,7 +19,8 @@ import {OrgFamilySelectModule} from '@eg/share/org-family-select/org-family-sele FmRecordEditorModule, OrgFamilySelectModule, SandboxRoutingModule, - ReactiveFormsModule + ReactiveFormsModule, + PatronModule ], providers: [ SampleDataService diff --git a/Open-ILS/src/eg2/src/app/staff/share/holdings/holdings.service.ts b/Open-ILS/src/eg2/src/app/staff/share/holdings/holdings.service.ts index 5c91a68474..3df5ce91e2 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/holdings/holdings.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/holdings/holdings.service.ts @@ -57,5 +57,10 @@ export class HoldingsService { }); }); } + + /* + markItemMissingPieces(copyId: number): Promise { + } + */ } diff --git a/Open-ILS/src/eg2/src/app/staff/share/patron/patron.module.ts b/Open-ILS/src/eg2/src/app/staff/share/patron/patron.module.ts index ac6e9b30f4..9987c64a86 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/patron/patron.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/patron/patron.module.ts @@ -5,12 +5,14 @@ import {PatronService} from './patron.service'; import {PatronSearchComponent} from './search.component'; import {PatronSearchDialogComponent} from './search-dialog.component'; import {ProfileSelectComponent} from './profile-select.component'; +import {PatronPenaltyDialogComponent} from './penalty-dialog.component'; @NgModule({ declarations: [ PatronSearchComponent, PatronSearchDialogComponent, - ProfileSelectComponent + ProfileSelectComponent, + PatronPenaltyDialogComponent ], imports: [ StaffCommonModule, @@ -19,7 +21,8 @@ import {ProfileSelectComponent} from './profile-select.component'; exports: [ PatronSearchComponent, PatronSearchDialogComponent, - ProfileSelectComponent + ProfileSelectComponent, + PatronPenaltyDialogComponent ], providers: [ PatronService diff --git a/Open-ILS/src/eg2/src/app/staff/share/patron/penalty-dialog.component.html b/Open-ILS/src/eg2/src/app/staff/share/patron/penalty-dialog.component.html new file mode 100644 index 0000000000..40db306974 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/share/patron/penalty-dialog.component.html @@ -0,0 +1,55 @@ + + + + + + diff --git a/Open-ILS/src/eg2/src/app/staff/share/patron/penalty-dialog.component.ts b/Open-ILS/src/eg2/src/app/staff/share/patron/penalty-dialog.component.ts new file mode 100644 index 0000000000..209bff0cca --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/share/patron/penalty-dialog.component.ts @@ -0,0 +1,91 @@ +import {Component, OnInit, Input, Output, ViewChild} from '@angular/core'; +import {merge, from, Observable} from 'rxjs'; +import {tap, take, switchMap} from 'rxjs/operators'; +import {IdlService, IdlObject} from '@eg/core/idl.service'; +import {OrgService} from '@eg/core/org.service'; +import {AuthService} from '@eg/core/auth.service'; +import {PcrudService} from '@eg/core/pcrud.service'; +import {NgbModal} from '@ng-bootstrap/ng-bootstrap'; +import {DialogComponent} from '@eg/share/dialog/dialog.component'; + + +/** + * Dialog container for patron penalty/message application + * + * + * + */ + +@Component({ + selector: 'eg-patron-penalty-dialog', + templateUrl: 'penalty-dialog.component.html' +}) + +export class PatronPenaltyDialogComponent + extends DialogComponent implements OnInit { + + @Input() patronId: number; + @Input() penaltyNote: string = ''; + + ALERT_NOTE = 20; + SILENT_NOTE = 21; + STAFF_CHR = 25; + + staffInitials: string = ''; + penaltyTypes: IdlObject[] = []; + penaltyTypeFromSelect = ''; + penaltyTypeFromButton; + patron: IdlObject; + dataLoaded = false; + requireInitials = false; + initials: string; + + constructor( + private modal: NgbModal, + private org: OrgService, + private auth: AuthService, + private pcrud: PcrudService) { + super(modal); + } + + ngOnInit() { + this.onOpen$.subscribe(_ => + this.init().subscribe(_ => this.dataLoaded = true)); + } + + init(): Observable { + this.dataLoaded = false; + + this.penaltyTypeFromButton = this.SILENT_NOTE; + + this.org.settings(['ui.staff.require_initials.patron_standing_penalty']) + .then(sets => this.requireInitials = + sets['ui.staff.require_initials.patron_standing_penalty']); + + const obs1 = this.pcrud.retrieve('au', this.patronId) + .pipe(tap(usr => this.patron = usr)); + + if (this.penaltyTypes.length > 0) { return obs1; } + + return obs1.pipe(switchMap(_ => { + return this.pcrud.search('csp', {id: {'>': 100}}, {}, {atomic: true}) + + .pipe(tap(ptypes => { + this.penaltyTypes = + ptypes.sort((a, b) => a.label() < b.label() ? -1 : 1); + })) + })); + } + + apply() { + this.close(); + } + + buttonClass(pType: number): string { + return this.penaltyTypeFromButton === pType ? + 'btn-primary' : 'btn-light'; + } +} + + + -- 2.11.0