LP1904036 More validation border repairs
authorBill Erickson <berickxx@gmail.com>
Wed, 24 Mar 2021 21:33:27 +0000 (17:33 -0400)
committerGalen Charlton <gmc@equinoxOLI.org>
Fri, 28 Oct 2022 00:13:28 +0000 (20:13 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Jane Sandberg <js7389@princeton.edu>
Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
Open-ILS/src/eg2/src/app/staff/circ/patron/barcodes.component.html [new file with mode: 0644]
Open-ILS/src/eg2/src/app/staff/circ/patron/barcodes.component.ts [new file with mode: 0644]

diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/barcodes.component.html b/Open-ILS/src/eg2/src/app/staff/circ/patron/barcodes.component.html
new file mode 100644 (file)
index 0000000..aa0cf1e
--- /dev/null
@@ -0,0 +1,39 @@
+<eg-string #successMsg text="Successfully Added Group" i18n-text></eg-string>
+<eg-string #errorMsg text="Failed To Add Group" i18n-text></eg-string>
+
+<ng-template #dialogContent>
+  <div class="modal-header bg-info">
+    <h4 class="modal-title" i18n>Patron Barcodes</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">
+      <div class="col-lg-4 font-weight-bold" i18n>Barcode</div>
+      <div class="col-lg-4 font-weight-bold" i18n>Active</div>
+      <div class="col-lg-4 font-weight-bold" i18n>Primary</div>
+    </div>
+    <div class="row mt-2 pt-2" *ngFor="let card of patron.cards()">
+      <div class="col-lg-4" i18n>
+        {{card.barcode()}}
+      </div>
+      <div class="col-lg-4" i18n>
+        <input type="checkbox" 
+          (ngModelChange)="activeChange(card, $event)"
+          class="form-check-input ml-0" [ngModel]="card.active() == 't'">
+      </div>
+      <div class="col-lg-4" i18n>
+        <input type="radio" name="primary-card" [value]="card.id()"
+          class="form-check-input ml-0" [(ngModel)]="primaryCard">
+      </div>
+    </div>
+  </div>
+  <div class="modal-footer">
+    <button type="button" class="btn btn-success"
+      (click)="applyChanges()" i18n>Apply Changes</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/circ/patron/barcodes.component.ts b/Open-ILS/src/eg2/src/app/staff/circ/patron/barcodes.component.ts
new file mode 100644 (file)
index 0000000..b252284
--- /dev/null
@@ -0,0 +1,73 @@
+import {Component, OnInit, Input, ViewChild} from '@angular/core';
+import {Observable, empty} from 'rxjs';
+import {switchMap, tap} from 'rxjs/operators';
+import {IdlObject, IdlService} from '@eg/core/idl.service';
+import {NetService} from '@eg/core/net.service';
+import {EventService} from '@eg/core/event.service';
+import {ToastService} from '@eg/share/toast/toast.service';
+import {PcrudService} from '@eg/core/pcrud.service';
+import {AuthService} from '@eg/core/auth.service';
+import {OrgService} from '@eg/core/org.service';
+import {DialogComponent} from '@eg/share/dialog/dialog.component';
+import {NgbModal, NgbModalOptions} from '@ng-bootstrap/ng-bootstrap';
+import {StringComponent} from '@eg/share/string/string.component';
+import {PatronContextService} from './patron.service';
+
+/* Add/Remove Secondary Groups */
+
+@Component({
+  selector: 'eg-patron-barcodes',
+  templateUrl: 'barcodes.component.html'
+})
+
+export class PatronBarcodesDialogComponent
+    extends DialogComponent implements OnInit {
+
+    @Input() patron: IdlObject;
+    primaryCard: number;
+
+    constructor(
+        private modal: NgbModal,
+        private toast: ToastService,
+        private net: NetService,
+        private idl: IdlService,
+        private evt: EventService,
+        private pcrud: PcrudService,
+        private org: OrgService,
+        private auth: AuthService,
+        private context: PatronContextService
+    ) { super(modal); }
+
+    ngOnInit() {
+    }
+
+    /* todo check perms
+    'UPDATE_PATRON_ACTIVE_CARD',
+    'UPDATE_PATRON_PRIMARY_CARD'
+    */
+
+    open(ops: NgbModalOptions): Observable<any> {
+        this.patron.cards().some(card => {
+            if (card.id() === this.patron.card().id()) {
+                this.primaryCard = card.id();
+                return true;
+            }
+        });
+        return super.open(ops);
+    }
+
+    applyChanges() {
+        if (this.primaryCard !== this.patron.card().id()) {
+            const card = this.patron.cards()
+                .filter(c => c.id() === this.primaryCard)[0];
+            this.patron.card(card);
+        }
+        this.close(true);
+    }
+
+    activeChange(card: IdlObject, active: boolean) {
+        card.ischanged(true);
+        card.active(active ? 't' : 'f');
+    }
+}
+