LPXXX Angular Volcopy
authorBill Erickson <berickxx@gmail.com>
Thu, 18 Jun 2020 22:01:56 +0000 (18:01 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 18 Jun 2020 22:01:56 +0000 (18:01 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/staff/cat/volcopy/copy-attrs.component.html
Open-ILS/src/eg2/src/app/staff/cat/volcopy/copy-attrs.component.ts

index 9dcccf5..ca2e2e2 100644 (file)
@@ -1,5 +1,18 @@
 
 
+<!-- We ask this question a lot.  Here's a handy template -->
+<ng-template #yesNoSelect let-field="field">
+  <eg-combobox domId="{{field}}-input" 
+    [required]="true" [ngModel]="values['field']" 
+    (ngModelChange)="values[field] = $event ? $event.id : null">
+    <eg-combobox-entry entryId="t" entryLabel="Yes" i18n-entryLabel>
+    </eg-combobox-entry>
+    <eg-combobox-entry entryId="f" entryLabel="No" i18n-entryLabel>
+    </eg-combobox-entry>
+  </eg-combobox>
+</ng-template>
+
+
 <!-- Copy Templates -->
 <div class="row">
 </div>
 
     <div>
       <ng-template #circulateTemplate>
-        <select class="form-control" 
-          id="circulate-input" [(ngModel)]="values['circulate']">
-          <option value="t" i18n>Yes</option>
-          <option value="f" i18n>No</option>
-        </select>
+        <ng-container *ngTemplateOutlet="yesNoSelect;context:{field:'circulate'}">
+        </ng-container>
       </ng-template>
       <eg-batch-item-attr label="Circulate" i18n-label
         displayAs="bool"
 
     <div>
       <ng-template #holdableTemplate>
-        <select class="form-control" 
-          id="holdable-input" [(ngModel)]="values['holdable']">
-          <option value="yes" i18n>Yes</option>
-          <option value="no" i18n>No</option>
-        </select>
+        <ng-container *ngTemplateOutlet="yesNoSelect;context:{field:'holdable'}">
+        </ng-container>
       </ng-template>
       <eg-batch-item-attr label="Holdable" i18n-label
         displayAs="bool"
         editInputDomId="holdable-input"
         [editTemplate]="holdableTemplate"
         [labelCounts]="itemAttrCounts('holdable')"
-        (changesSaved)="applyCopyValue('holdable',
-          values['holdable'] === 'yes' ? 't': 'f')">
+        (changesSaved)="applyCopyValue('holdable')">
       </eg-batch-item-attr>
     </div>
 
   <!-- COLUMN 4 -->
 
   <div class="flex-1 p-1">
-
     <div class="p-1"><h4 class="font-weight-bold" i18n>Miscellaneous</h4></div>
 
+    <!-- Adding this for sites that still use alert messages (we do)
     <div>
       <ng-template #alertMessageTemplate>
         <textarea rows="3" class="form-control" id="alert-message-input"
         (changesSaved)="applyCopyValue('alert_message')">
       </eg-batch-item-attr>
     </div>
+    -->
+
+    <div class="border rounded m-1">
+      <eg-copy-alerts-dialog #copyAlertsDialog></eg-copy-alerts-dialog>
+      <div class="batch-header font-weight-bold p-2" i18n>Item Alerts</div>
+      <div class="p-1">
+        <button class="btn btn-outline-dark" (click)="openCopyAlerts()" i18n>
+          Item Alerts
+        </button>
+      </div>
+    </div>
 
     <div>
       <ng-template #depositTemplate>
-        <select class="form-control" 
-          id="deposit-input" [(ngModel)]="values['deposit']">
-          <option value="t" i18n>Yes</option>
-          <option value="f" i18n>No</option>
-        </select>
+        <ng-container *ngTemplateOutlet="yesNoSelect;context:{field:'deposit'}">
+        </ng-container>
       </ng-template>
       <eg-batch-item-attr label="Deposit" i18n-label
         displayAs="bool"
 
     <div>
       <ng-template #opacVisibleTemplate>
-        <select class="form-control"
-          id="opac-visible-input" [(ngModel)]="values['opac_visible']">
-          <option value="t" i18n>Yes</option>
-          <option value="f" i18n>No</option>
-        </select>
+        <ng-container *ngTemplateOutlet="yesNoSelect;context:{field:'opac_visible'}">
+        </ng-container>
       </ng-template>
       <eg-batch-item-attr label="OPAC Visible" i18n-label
         displayAs="bool"
-        editInputDomId="opac-visible-input"
+        editInputDomId="opac_visible-input"
         [editTemplate]="opacVisibleTemplate"
         [labelCounts]="itemAttrCounts('opac_visible')"
         (changesSaved)="applyCopyValue('opac_visible')">
 
     <div>
       <ng-template #refTemplate>
-        <select class="form-control" 
-          id="ref-input" [(ngModel)]="values['ref']">
-          <option value="t" i18n>Yes</option>
-          <option value="f" i18n>No</option>
-        </select>
+        <ng-container *ngTemplateOutlet="yesNoSelect;context:{field:'ref'}">
+        </ng-container>
       </ng-template>
       <eg-batch-item-attr label="Reference" i18n-label
         displayAs="bool"
 
     <div *ngFor="let cat of statCats; let idx = index">
       <ng-template #statCatTemplate>
-        <select class="form-control" id="stat-cat-input-{{idx}}" 
-          [(ngModel)]="statCatValues[cat.id()]">
-          <option *ngFor="let entry of cat.entries()" 
-            value="{{entry.id()}}" i18n>{{entry.value()}}</option>
-        </select>
+        <eg-combobox domId="stat-cat-input-{{idx}}"
+          (ngModelChange)="statCatValues[cat.id()] = $event ? $event.id : null"
+          [ngModel]="statCatValues[cat.id()]">
+          <eg-combobox-entry *ngFor="let entry of cat.entries()"
+            [entryId]="entry.id()" [entryLabel]="entry.value()">
+          </eg-combobox-entry>
+        </eg-combobox>
       </ng-template>
       <eg-batch-item-attr label="{{cat.name()}} ({{orgSn(cat.owner())}})" i18n-label
         editInputDomId="stat-cat-input-{{idx}}"
index b955cee..ffc40f6 100644 (file)
@@ -12,10 +12,17 @@ import {VolCopyContext} from './volcopy';
 import {VolCopyService} from './volcopy.service';
 import {FormatService} from '@eg/core/format.service';
 import {StringComponent} from '@eg/share/string/string.component';
+import {CopyAlertsDialogComponent
+    } from '@eg/staff/share/holdings/copy-alerts-dialog.component';
 
 @Component({
   selector: 'eg-copy-attrs',
-  templateUrl: 'copy-attrs.component.html'
+  templateUrl: 'copy-attrs.component.html',
+
+  // Match the header of the batch attrs component
+  styles: [`
+    .batch-header {background-color: #d9edf7;}`
+  ]
 })
 export class CopyAttrsComponent implements OnInit, AfterViewInit {
 
@@ -57,6 +64,9 @@ export class CopyAttrsComponent implements OnInit, AfterViewInit {
     @ViewChild('mintConditionNo', {static: false})
         mintConditionNo: StringComponent;
 
+    @ViewChild('copyAlertsDialog', {static: false})
+        private copyAlertsDialog: CopyAlertsDialogComponent;
+
     constructor(
         private router: Router,
         private route: ActivatedRoute,
@@ -327,6 +337,19 @@ export class CopyAttrsComponent implements OnInit, AfterViewInit {
             copy.ischanged(true);
         });
     }
+
+    openCopyAlerts() {
+        // TODO: support for new copies
+        this.copyAlertsDialog.copyIds = this.context.copyList().map(c => c.id());
+        this.copyAlertsDialog.mode = 'create';
+        this.copyAlertsDialog.open({size: 'lg'}).subscribe(
+            modified => {
+                if (modified) {
+                    console.log('notes modified');
+                }
+            }
+        );
+    }
 }