LPXXX Angular Volcopy
authorBill Erickson <berickxx@gmail.com>
Tue, 9 Jun 2020 18:55:03 +0000 (14:55 -0400)
committerBill Erickson <berickxx@gmail.com>
Tue, 9 Jun 2020 18:55:03 +0000 (14:55 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.html
Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.ts
Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.component.html
Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.ts

index a606b5d..b1406ad 100644 (file)
@@ -4,6 +4,7 @@
   dialogTitle="Delete Call Number?"
   dialogBody="Delete {{deleteVolCount}} Call Number(s) and {{deleteCopyCount}} Associated Item(s)?">
 </eg-confirm-dialog>
+
 <eg-confirm-dialog 
   #confirmDelCopy
   i18n-dialogTitle i18n-dialogBody
@@ -15,7 +16,7 @@
   <div class="p-1" [ngStyle]="{flex: flexAt(1)}"> </div>
   <div class="p-1" [ngStyle]="{flex: flexAt(2)}"> </div>
   <div class="p-1" [ngStyle]="{flex: flexAt(3)}">
-    <label class="font-weight-bold" i18n>Classification</label>
+    <div><label class="font-weight-bold" i18n>Classification</label></div>
     <div>
       <eg-combobox [smallFormControl]="true" [(ngModel)]="batchVolClass">
         <eg-combobox-entry *ngFor="let cls of volClasses"
@@ -25,7 +26,7 @@
     </div>
   </div>
   <div class="p-1" [ngStyle]="{flex: flexAt(4)}">
-    <label class="font-weight-bold" i18n>Prefix</label>
+    <div><label class="font-weight-bold" i18n>Prefix</label></div>
     <div>
       <eg-combobox [smallFormControl]="true" [(ngModel)]="batchVolPrefix">
         <eg-combobox-entry *ngFor="let pfx of volPrefixes"
@@ -35,7 +36,7 @@
     </div>
   </div>
   <div class="p-1" [ngStyle]="{flex: flexAt(5)}">
-    <label class="font-weight-bold" i18n>Call Number Label</label>
+    <div><label class="font-weight-bold" i18n>Call Number Label</label></div>
     <div>
       <eg-combobox [smallFormControl]="true" [(ngModel)]="batchVolLabel">
         <eg-combobox-entry *ngFor="let label of recordVolLabels" [entryId]="label">
@@ -44,7 +45,7 @@
     </div>
   </div>
   <div class="p-1" [ngStyle]="{flex: flexAt(6)}">
-    <label class="font-weight-bold" i18n>Suffix</label>
+    <div><label class="font-weight-bold" i18n>Suffix</label></div>
     <div>
       <eg-combobox [smallFormControl]="true" [(ngModel)]="batchVolSuffix">
         <eg-combobox-entry *ngFor="let sfx of volSuffixes"
@@ -54,7 +55,7 @@
     </div>
   </div>
   <div class="p-1" [ngStyle]="{flex: flexAt(7)}">
-    <label class="font-weight-bold" i18n>Batch</label>
+    <div><label class="font-weight-bold" i18n>Batch</label></div>
     <div>
       <button class="btn btn-sm btn-outline-dark label-with-material-icon"
         (click)="batchVolApply()">
@@ -64,7 +65,7 @@
     </div>
   </div>
   <div class="p-1" [ngStyle]="{flex: flexAt(8)}">
-    <label class="font-weight-bold" i18n>Generate Barcodes</label>
+    <div><label class="font-weight-bold" i18n>Generate Barcodes</label></div>
     <button class="btn btn-sm btn-outline-dark label-with-material-icon"
       (click)="generateBarcodes()">
       <span i18n>Generate</span>
@@ -72,7 +73,7 @@
     </button>
   </div>
   <div class="p-1" [ngStyle]="{flex: flexSpan(9, 10)}">
-    <label class="font-weight-bold" i18n>Checkdigit</label>
+    <div><label class="font-weight-bold" i18n>Checkdigit</label></div>
     <div class="form-check form-check-inline">
       <input class="form-check-input" type="checkbox" 
         id="use-checkdigit" [(ngModel)]="useCheckdigit">
           <ng-container *ngIf="copyIdx == 0">
             <span>{{orgNode.target.shortname()}}</span>
             <button class="clear-button" (click)="deleteVol(volNode)"
-              title="Delete Call Number" i18n-title>
+              title="Delete Call Number {{volNode.target.label()}}" i18n-title>
               <span class="material-icons">clear</span>
             </button>
           </ng-container>
 
           <div class="d-flex">
             <button class="clear-button" (click)="deleteCopy(copyNode)"
-              title="Delete Item" i18n-title>
+              title="Delete Item {{copyNode.target.barcode()}}" i18n-title>
               <span class="material-icons">clear</span>
             </button>
 
             <input type="text" class="form-control form-control-sm"
               id="barcode-input-{{copyNode.target.id()}}"
-              spellcheck="false"
-              [required]="true"
+              spellcheck="false" [required]="true"
               [ngClass]="{'text-danger': copyNode.target._dupe_barcode}"
-              (ngModelChange)="barcodeChanged(copyNode.target, $event)"
+              (change)="barcodeChanged(copyNode.target, $event.target.value)"  
+              (ngModelChange)="copyNode.target.barcode($event)"
               (keyup.enter)="selectNextBarcode(copyNode.target.id())"
               (keyup.shift.enter)="selectNextBarcode(copyNode.target.id(), true)"
               (focus)="$event.target.select()"
               [ngModel]="copyNode.target.barcode()"
               (ngModelChange)="applyCopyValue(copyNode.target, 'barcode', $event)"/>
-            <div *ngIf="copyNode.target._dupe_barcode"
-              class="alert alert-danger font-italic p-1" i18n>
-              Duplicate Barcode</div>
+          </div>
+          <div *ngIf="copyNode.target._dupe_barcode"
+            class="alert alert-danger font-italic p-1" i18n>
+            Duplicate Barcode
           </div>
         </div>
         <div class="p-1" [ngStyle]="{flex: flexAt(9)}">
index f25da3c..4566fc2 100644 (file)
@@ -317,7 +317,6 @@ export class VolEditComponent implements OnInit {
     batchVolApply() {
         this.context.volNodes().forEach(volNode => {
             const vol = volNode.target;
-            console.log('batch vol class', this.batchVolClass.id);
             if (this.batchVolClass) {
                 this.applyVolValue(vol, 'label_class', this.batchVolClass.id);
             }
@@ -431,6 +430,13 @@ export class VolEditComponent implements OnInit {
     }
 
     deleteCopy(copyNode: HoldingsTreeNode) {
+
+        if (copyNode.target.isnew()) {
+            // Confirmation not required when deleting brand new copies.
+            this.deleteOneCopy(copyNode);
+            return;
+        }
+
         this.deleteCopyCount = 1;
         this.confirmDelCopy.open().toPromise().then(confirmed => {
             if (confirmed) { this.deleteOneCopy(copyNode); }
@@ -472,6 +478,13 @@ export class VolEditComponent implements OnInit {
 
 
     deleteVol(volNode: HoldingsTreeNode) {
+
+        if (volNode.target.isnew()) {
+            // Confirmation not required when deleting brand new vols.
+            this.deleteOneVol(volNode);
+            return;
+        }
+
         this.deleteVolCount = 1;
         this.deleteCopyCount = volNode.children.length;
 
index 274eb68..1c62cca 100644 (file)
     <eg-vol-edit [context]="context"></eg-vol-edit>
   </div>
 
+
+  <div class="row m-2 p-2 border border-info">
+    <div class="col-lg-12 d-flex">
+      <div class="flex-1"> </div>
+      <button class="btn btn-outline-dark" 
+        [disabled]="!context.dataIsSaveable()" (click)="save()" i18n>Save</button>
+      <button class="btn btn-outline-dark ml-2" 
+        [disabled]="!context.dataIsSaveable()"
+        (click)="save(true)" i18n>Save &amp; Exit</button>
+    </div>
+  </div>
+
 </ng-container>
+
index 6a515d8..716fac7 100644 (file)
@@ -115,7 +115,6 @@ export class VolCopyContext {
         return node;
     }
 
-
     sortHoldings() {
 
         this.orgNodes().forEach(orgNode => {
@@ -137,4 +136,11 @@ export class VolCopyContext {
             o1.target.shortname() < o2.target.shortname() ? -1 : 1);
     }
 
+    dataIsSaveable(): boolean {
+        const dupeBc = this.copyList().filter(c => c._dupe_barcode).length;
+
+        if (dupeBc) { return false; }
+
+        return true;
+    }
 }