LPXXX Missing pieces angular port WIP
authorBill Erickson <berickxx@gmail.com>
Mon, 2 Mar 2020 19:17:55 +0000 (14:17 -0500)
committerBill Erickson <berickxx@gmail.com>
Mon, 2 Mar 2020 19:17:55 +0000 (14:17 -0500)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.html
Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.ts
Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.module.ts
Open-ILS/src/eg2/src/app/staff/share/holdings/holdings.service.ts
Open-ILS/src/eg2/src/app/staff/share/patron/patron.module.ts
Open-ILS/src/eg2/src/app/staff/share/patron/penalty-dialog.component.html [new file with mode: 0644]
Open-ILS/src/eg2/src/app/staff/share/patron/penalty-dialog.component.ts [new file with mode: 0644]

index 3b9609b..1f8db17 100644 (file)
 </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"
index c44a7f7..5a915ad 100644 (file)
@@ -52,6 +52,8 @@ export class SandboxComponent implements OnInit {
     @ViewChild('bresvEditor', { static: true })
     private bresvEditor: FmRecordEditorComponent;
 
+    @ViewChild('penaltyDialog', {static: false}) penaltyDialog;
+
 
     // @ViewChild('helloStr') private helloStr: StringComponent;
 
@@ -472,5 +474,10 @@ export class SandboxComponent implements OnInit {
             printContext: 'default'
         });
     }
+
+    openPenalty() {
+        this.penaltyDialog.open()
+        .subscribe(val => console.log('penalty value', val));
+    }
 }
 
index a33deb8..7864052 100644 (file)
@@ -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
index 5c91a68..3df5ce9 100644 (file)
@@ -57,5 +57,10 @@ export class HoldingsService {
             });
         });
     }
+
+    /*
+    markItemMissingPieces(copyId: number): Promise<any> {
+    }
+    */
 }
 
index ac6e9b3..9987c64 100644 (file)
@@ -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 (file)
index 0000000..40db306
--- /dev/null
@@ -0,0 +1,55 @@
+<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">&times;</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>
+
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 (file)
index 0000000..209bff0
--- /dev/null
@@ -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
+ *
+ * <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';
+    }
+}
+
+
+