</div>
<div class="mt-4 mb-4">
+ <h4>Add Patron Penalty</h4>
+ <eg-patron-penalty-dialog #penaltyDialog patronId="1"></eg-patron-penalty-dialog>
+ <button class="btn btn-outline-dark" (click)="openPenalty()" i18n>
+ Open Penalty Dialog
+ </button>
+</div>
+
+<div class="mt-4 mb-4">
<h4>Grid Stock Selector Display and Filtering</h4>
<eg-grid #eventsGrid idlClass="atevdef"
[dataSource]="eventsDataSource"
@ViewChild('bresvEditor', { static: true })
private bresvEditor: FmRecordEditorComponent;
+ @ViewChild('penaltyDialog', {static: false}) penaltyDialog;
+
// @ViewChild('helloStr') private helloStr: StringComponent;
printContext: 'default'
});
}
+
+ openPenalty() {
+ this.penaltyDialog.open()
+ .subscribe(val => console.log('penalty value', val));
+ }
}
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: [
FmRecordEditorModule,
OrgFamilySelectModule,
SandboxRoutingModule,
- ReactiveFormsModule
+ ReactiveFormsModule,
+ PatronModule
],
providers: [
SampleDataService
});
});
}
+
+ /*
+ markItemMissingPieces(copyId: number): Promise<any> {
+ }
+ */
}
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,
exports: [
PatronSearchComponent,
PatronSearchDialogComponent,
- ProfileSelectComponent
+ ProfileSelectComponent,
+ PatronPenaltyDialogComponent
],
providers: [
PatronService
--- /dev/null
+<ng-template #dialogContent>
+ <div class="modal-header bg-info">
+ <h4 class="modal-title">
+ <span i18n>Apply Standing Penalty / Message</span>
+ </h4>
+ <button type="button" class="close"
+ i18n-aria-label aria-label="Close" (click)="close()">
+ <span aria-hidden="true">×</span>
+ </button>
+ </div>
+ <div class="modal-body">
+ <div class="row d-flex p-3" *ngIf="dataLoaded">
+ <span i18n>
+ Apply penalty to patron <b>{{patron.family_name()}}, {{patron.first_given_name()}}</b>
+ </span>
+ </div>
+ <div class="row d-flex p-3">
+ <div>
+ <button class="btn mr-1 {{buttonClass(SILENT_NOTE)}}"
+ (click)="penaltyTypeFromButton=SILENT_NOTE" i18n>Note</button>
+ <button class="btn mr-1 {{buttonClass(ALERT_NOTE)}}"
+ (click)="penaltyTypeFromButton=ALERT_NOTE" i18n >Alert</button>
+ <button class="btn mr-1 {{buttonClass(STAFF_CHR)}}"
+ (click)="penaltyTypeFromButton=STAFF_CHR" i18n>Block</button>
+ </div>
+ <div class="flex-1"></div>
+ <div>
+ <select class="form-control"
+ [(ngModel)]="penaltyTypeFromSelect">
+ <option value='' i18n>Penalty Type...</option>
+ <option value="pen.id()" *ngFor="let pen of penaltyTypes">
+ {{pen.label()}}
+ </option>
+ </select>
+ </div>
+ </div>
+ <div class="row">
+ <div class="col-lg-12">
+ <textarea class="form-control" [(ngModel)]="noteText"></textarea>
+ </div>
+ </div>
+ </div>
+ <div class="modal-footer flex">
+ <div *ngIf="requireInitials">
+ <input type="text" class="form-control" size="3" [(ngModel)]="initials"/>
+ </div>
+ <div class="flex-1"></div>
+ <!-- initials.. disable -->
+ <button type="button" class="btn btn-success"
+ [disabled]="!penaltyType" (click)="apply()" i18n>OK</button>
+ <button type="button" class="btn btn-warning"
+ (click)="close()" i18n>Cancel</button>
+ </div>
+</ng-template>
+
--- /dev/null
+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
+ *
+ * <eg-patron-penalty-dialog [patronId]="myPatronId">
+ * </eg-patron-penalty-dialog>
+ */
+
+@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<any> {
+ 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';
+ }
+}
+
+
+