LPXXX Angular Volcopy
authorBill Erickson <berickxx@gmail.com>
Mon, 22 Jun 2020 22:04:55 +0000 (18:04 -0400)
committerBill Erickson <berickxx@gmail.com>
Mon, 22 Jun 2020 22:04:55 +0000 (18:04 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/staff/cat/volcopy/config.component.html
Open-ILS/src/eg2/src/app/staff/cat/volcopy/config.component.ts
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
Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.ts
Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.service.ts

index e32ac7c..93b264c 100644 (file)
@@ -1,3 +1,8 @@
+<div class="row d-flex">
+  <div class="flex-1"></div>
+  <button class="btn btn-outline-dark" (click)="save()" i18n>Save Defaults</button>
+</div>
+
 <h3 class="mt-3" i18n>Holdings Defaults</h3>
 
 <div class="row">
@@ -11,7 +16,7 @@
               <div class="form-check form-check-inline">
                 <input class="form-check-input" type="checkbox" 
                   id="hide-classification-column" 
-                  [(ngModel)]="volcopy.volCopyDefaults.hidden.classification">
+                  [(ngModel)]="volcopy.defaults.hidden.classification">
                 <label class="form-check-label" for="hide-classification-column" i18n>
                   Hide Call Number Classification Column
                 </label>
@@ -21,7 +26,7 @@
               <div class="form-check form-check-inline">
                 <input class="form-check-input" type="checkbox" 
                   id="hide-prefix-column" 
-                  [(ngModel)]="volcopy.volCopyDefaults.hidden.prefix">
+                  [(ngModel)]="volcopy.defaults.hidden.prefix">
                 <label class="form-check-label" for="hide-prefix-column" i18n>
                   Hide Call Number Prefix Column
                 </label>
@@ -31,7 +36,7 @@
               <div class="form-check form-check-inline">
                 <input class="form-check-input" type="checkbox" 
                   id="hide-suffix-column" 
-                  [(ngModel)]="volcopy.volCopyDefaults.hidden.suffix">
+                  [(ngModel)]="volcopy.defaults.hidden.suffix">
                 <label class="form-check-label" for="hide-suffix-column" i18n>
                   Hide Call Number Suffix Column
                 </label>
@@ -56,9 +61,9 @@
                 <div class="col-lg-8">
                   <eg-combobox
                     domId="default-classification"
-                    [selectedId]="volcopy.volCopyDefaults.values.classification || 1"
+                    [selectedId]="volcopy.defaults.values.classification || 1"
                     [smallFormControl]="true"
-                    (onChange)="volcopy.volCopyDefaults.values.classification = $entry ? $entry.id : null">
+                    (onChange)="volcopy.defaults.values.classification = $event ? $event.id : null">
                     <eg-combobox-entry *ngFor="let cls of volcopy.volClasses"
                       [entryId]="cls.id()" [entryLabel]="cls.name()">
                     </eg-combobox-entry>
@@ -74,9 +79,9 @@
                 <div class="col-lg-8">
                   <eg-combobox
                     domId="default-prefix"
-                    [selectedId]="volcopy.volCopyDefaults.values.prefix || -1"
                     [smallFormControl]="true"
-                    (onChange)="volcopy.volCopyDefaults.values.prefix = $entry ? $entry.id : null">
+                    [startId]="volcopy.defaults.values.prefix || -1"
+                    (onChange)="volcopy.defaults.values.prefix = $event ? $event.id : null">
                     <eg-combobox-entry 
                       entryLabel="<None>" i18n-entryLabel [entryId]="-1">
                     </eg-combobox-entry>
                 <div class="col-lg-8">
                   <eg-combobox
                     domId="default-suffix"
-                    [selectedId]="volcopy.volCopyDefaults.values.suffix || -1"
+                    [selectedId]="volcopy.defaults.values.suffix || -1"
                     [smallFormControl]="true"
-                    (onChange)="volcopy.volCopyDefaults.values.suffix = $entry ? $entry.id : null">
+                    (onChange)="volcopy.defaults.values.suffix = $event ? $event.id : null">
                     <eg-combobox-entry 
                       entryLabel="<None>" i18n-entryLabel [entryId]="-1">
                     </eg-combobox-entry>
           <div class="form-check form-check-inline">
             <input class="form-check-input" type="checkbox" 
               id="show-status-attr" 
-              [(ngModel)]="volcopy.volCopyDefaults.hidden.status">
+              [(ngModel)]="volcopy.defaults.hidden.status">
             <label class="form-check-label" for="show-status-attr" i18n>
               Status
             </label>
           <div class="form-check form-check-inline">
             <input class="form-check-input" type="checkbox" 
               id="show-barcode-attr" 
-              [(ngModel)]="volcopy.volCopyDefaults.hidden.barcode">
+              [(ngModel)]="volcopy.defaults.hidden.barcode">
             <label class="form-check-label" for="show-barcode-attr" i18n>
               Barcode
             </label>
           <div class="form-check form-check-inline">
             <input class="form-check-input" type="checkbox" 
               id="show-create_date-attr" 
-              [(ngModel)]="volcopy.volCopyDefaults.hidden.create_date">
+              [(ngModel)]="volcopy.defaults.hidden.create_date">
             <label class="form-check-label" for="show-create_date-attr" i18n>
               Creation Date
             </label>
           <div class="form-check form-check-inline">
             <input class="form-check-input" type="checkbox" 
               id="show-active_date-attr" 
-              [(ngModel)]="volcopy.volCopyDefaults.hidden.active_date">
+              [(ngModel)]="volcopy.defaults.hidden.active_date">
             <label class="form-check-label" for="show-active_date-attr" i18n>
               Activation Date
             </label>
           <div class="form-check form-check-inline">
             <input class="form-check-input" type="checkbox" 
               id="show-creator-attr" 
-              [(ngModel)]="volcopy.volCopyDefaults.hidden.creator">
+              [(ngModel)]="volcopy.defaults.hidden.creator">
             <label class="form-check-label" for="show-creator-attr" i18n>
               Creator
             </label>
           <div class="form-check form-check-inline">
             <input class="form-check-input" type="checkbox" 
               id="show-edit_date-attr" 
-              [(ngModel)]="volcopy.volCopyDefaults.hidden.edit_date">
+              [(ngModel)]="volcopy.defaults.hidden.edit_date">
             <label class="form-check-label" for="show-edit_date-attr" i18n>
               Last Edit Date
             </label>
           <div class="form-check form-check-inline">
             <input class="form-check-input" type="checkbox" 
               id="show-editor-attr" 
-              [(ngModel)]="volcopy.volCopyDefaults.hidden.editor">
+              [(ngModel)]="volcopy.defaults.hidden.editor">
             <label class="form-check-label" for="show-editor-attr" i18n>
               Last Editor
             </label>
           <div class="form-check form-check-inline">
             <input class="form-check-input" type="checkbox" 
               id="show-location-attr" 
-              [(ngModel)]="volcopy.volCopyDefaults.hidden.location">
+              [(ngModel)]="volcopy.defaults.hidden.location">
             <label class="form-check-label" for="show-location-attr" i18n>
               Location
             </label>
           <div class="form-check form-check-inline">
             <input class="form-check-input" type="checkbox" 
               id="show-circ_lib-attr" 
-              [(ngModel)]="volcopy.volCopyDefaults.hidden.circ_lib">
+              [(ngModel)]="volcopy.defaults.hidden.circ_lib">
             <label class="form-check-label" for="show-circ_lib-attr" i18n>
               Circulating Library
             </label>
           <div class="form-check form-check-inline">
             <input class="form-check-input" type="checkbox" 
               id="show-owning_lib-attr" 
-              [(ngModel)]="volcopy.volCopyDefaults.owning_lib">
+              [(ngModel)]="volcopy.defaults.hidden.owning_lib">
             <label class="form-check-label" for="show-owning_lib-attr" i18n>
               Owning Library
             </label>
           <div class="form-check form-check-inline">
             <input class="form-check-input" type="checkbox" 
               id="show-copy_number-attr" 
-              [(ngModel)]="volcopy.volCopyDefaults.hidden.copy_number">
+              [(ngModel)]="volcopy.defaults.hidden.copy_number">
             <label class="form-check-label" for="show-copy_number-attr" i18n>
               Copy Number 
             </label>
           <div class="form-check form-check-inline">
             <input class="form-check-input" type="checkbox" 
               id="show-circulate-attr" 
-              [(ngModel)]="volcopy.volCopyDefaults.hidden.circulate">
+              [(ngModel)]="volcopy.defaults.hidden.circulate">
             <label class="form-check-label" for="show-circulate-attr" i18n>
               Circulate
             </label>
           <div class="form-check form-check-inline">
             <input class="form-check-input" type="checkbox" 
               id="show-holdable-attr" 
-              [(ngModel)]="volcopy.volCopyDefaults.hidden.holdable">
+              [(ngModel)]="volcopy.defaults.hidden.holdable">
             <label class="form-check-label" for="show-holdable-attr" i18n>
               Holdable
             </label>
           <div class="form-check form-check-inline">
             <input class="form-check-input" type="checkbox" 
               id="show-age_protect-attr" 
-              [(ngModel)]="volcopy.volCopyDefaults.hidden.age_protect">
+              [(ngModel)]="volcopy.defaults.hidden.age_protect">
             <label class="form-check-label" for="show-age_protect-attr" i18n>
               Aged-Based Hold Protection
             </label>
           <div class="form-check form-check-inline">
             <input class="form-check-input" type="checkbox" 
               id="show-floating-attr" 
-              [(ngModel)]="volcopy.volCopyDefaults.hidden.floating">
+              [(ngModel)]="volcopy.defaults.hidden.floating">
             <label class="form-check-label" for="show-floating-attr" i18n>
               Floating
             </label>
           <div class="form-check form-check-inline">
             <input class="form-check-input" type="checkbox" 
               id="show-loan_duration-attr" 
-              [(ngModel)]="volcopy.volCopyDefaults.hidden.loan_duration">
+              [(ngModel)]="volcopy.defaults.hidden.loan_duration">
             <label class="form-check-label" for="show-loan_duration-attr" i18n>
               Loan Duration
             </label>
           <div class="form-check form-check-inline">
             <input class="form-check-input" type="checkbox" 
               id="show-fine_level-attr" 
-              [(ngModel)]="volcopy.volCopyDefaults.hidden.fine_level">
+              [(ngModel)]="volcopy.defaults.hidden.fine_level">
             <label class="form-check-label" for="show-fine_level-attr" i18n>
               Fine Level
             </label>
           <div class="form-check form-check-inline">
             <input class="form-check-input" type="checkbox" 
               id="show-circ_as_type-attr" 
-              [(ngModel)]="volcopy.volCopyDefaults.hidden.circ_as_type">
+              [(ngModel)]="volcopy.defaults.hidden.circ_as_type">
             <label class="form-check-label" for="show-circ_as_type-attr" i18n>
               Circulate As Type
             </label>
           </div>
         </li>
+        <li class="list-group-item">
+          <div class="form-check form-check-inline">
+            <input class="form-check-input" type="checkbox" 
+              id="show-circ_modifier-attr" 
+              [(ngModel)]="volcopy.defaults.hidden.circ_modifier">
+            <label class="form-check-label" for="show-circ_modifier-attr" i18n>
+              Circulation Modifier
+            </label>
+          </div>
+        </li>
       </ul>
     </div>
   </div>
 
+  <!-- COLUMN 4 -->
 
-<!--
-
-
-
-    <div>
-      <ng-template #circModifierTemplate>
-        <select class="form-control" [(ngModel)]="values['circ_modifier']">
-          <option [value]="null" i18n>&lt;Unset&gt;</option>
-          <option *ngFor="let mod of circModifiers"
-            value="{{mod.code()}}">{{mod.name()}}</option>
-        </select>
-      </ng-template>
-      <eg-batch-item-attr label="Circulion Modifier" i18n-label
-        [emptyIsUnset]="true"
-        [editTemplate]="circModifierTemplate"
-        [labelCounts]="itemAttrCounts('circ_modifier')"
-        (changesSaved)="applyCopyValue('circ_modifier')">
-      </eg-batch-item-attr>
+  <div class="flex-1 p-1">
+    <div class="card">
+      <div class="card-header" i18n>Miscellaneous</div>
+      <ul class="list-group list-group-flush">
+        <li class="list-group-item">
+          <div class="form-check form-check-inline">
+            <input class="form-check-input" type="checkbox" 
+              id="show-copy_alerts-attr" 
+              [(ngModel)]="volcopy.defaults.hidden.copy_alerts">
+            <label class="form-check-label" for="show-copy_alerts-attr" i18n>
+              Item Alerts
+            </label>
+          </div>
+        </li>
+        <li class="list-group-item">
+          <div class="form-check form-check-inline">
+            <input class="form-check-input" type="checkbox" 
+              id="show-deposit-attr" 
+              [(ngModel)]="volcopy.defaults.hidden.deposit">
+            <label class="form-check-label" for="show-deposit-attr" i18n>
+              Deposit
+            </label>
+          </div>
+        </li>
+        <li class="list-group-item">
+          <div class="form-check form-check-inline">
+            <input class="form-check-input" type="checkbox" 
+              id="show-deposit_amount-attr" 
+              [(ngModel)]="volcopy.defaults.hidden.deposit_amount">
+            <label class="form-check-label" for="show-deposit_amount-attr" i18n>
+              Deposit Amount
+            </label>
+          </div>
+        </li>
+        <li class="list-group-item">
+          <div class="form-check form-check-inline">
+            <input class="form-check-input" type="checkbox" 
+              id="show-price-attr" 
+              [(ngModel)]="volcopy.defaults.hidden.price">
+            <label class="form-check-label" for="show-price-attr" i18n>
+              Price
+            </label>
+          </div>
+        </li>
+        <li class="list-group-item">
+          <div class="form-check form-check-inline">
+            <input class="form-check-input" type="checkbox" 
+              id="show-opac_visible-attr" 
+              [(ngModel)]="volcopy.defaults.hidden.opac_visible">
+            <label class="form-check-label" for="show-opac_visible-attr" i18n>
+              OPAC Visible
+            </label>
+          </div>
+        </li>
+        <li class="list-group-item">
+          <div class="form-check form-check-inline">
+            <input class="form-check-input" type="checkbox" 
+              id="show-ref-attr" 
+              [(ngModel)]="volcopy.defaults.hidden.ref">
+            <label class="form-check-label" for="show-ref-attr" i18n>
+              Reference
+            </label>
+          </div>
+        </li>
+        <li class="list-group-item">
+          <div class="form-check form-check-inline">
+            <input class="form-check-input" type="checkbox" 
+              id="show-cost-attr" 
+              [(ngModel)]="volcopy.defaults.hidden.cost">
+            <label class="form-check-label" for="show-cost-attr" i18n>
+              Cost 
+            </label>
+          </div>
+        </li>
+        <li class="list-group-item">
+          <div class="form-check form-check-inline">
+            <input class="form-check-input" type="checkbox" 
+              id="show-mint_condition-attr" 
+              [(ngModel)]="volcopy.defaults.hidden.mint_condition">
+            <label class="form-check-label" for="show-mint_condition-attr" i18n>
+              Quality
+            </label>
+          </div>
+        </li>
+      </ul>
     </div>
-
   </div>
 
+  <!-- COLUMN 5 -->
 
   <div class="flex-1 p-1">
-    <div class="p-1"><h4 class="font-weight-bold" i18n>Miscellaneous</h4></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>Add 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>
-        <ng-container *ngTemplateOutlet="yesNoSelect;context:{field:'deposit'}">
-        </ng-container>
-      </ng-template>
-      <eg-batch-item-attr label="Deposit" i18n-label
-        displayAs="bool"
-        editInputDomId="deposit-input"
-        [editTemplate]="depositTemplate"
-        [labelCounts]="itemAttrCounts('deposit')"
-        (changesSaved)="applyCopyValue('deposit')">
-      </eg-batch-item-attr>
-    </div>
-
-    <div>
-      <ng-template #depositAmountTemplate>
-        <input type="number" class="form-control" 
-          id="deposit-amount-input" [(ngModel)]="values['deposit_amount']"/>
-      </ng-template>
-      <eg-batch-item-attr label="Deposit Amount" i18n-label
-        displayAs="currency"
-        editInputDomId="deposit-amount-input"
-        [editTemplate]="depositAmountTemplate"
-        [labelCounts]="itemAttrCounts('deposit_amount')"
-        (changesSaved)="applyCopyValue('deposit_amount')">
-      </eg-batch-item-attr>
-    </div>
-
-    <div>
-      <ng-template #priceTemplate>
-        <input type="number" class="form-control" 
-          id="price-input" [(ngModel)]="values['price']"/>
-      </ng-template>
-      <eg-batch-item-attr label="Price" i18n-label
-        displayAs="currency"
-        editInputDomId="price-input"
-        [editTemplate]="priceTemplate"
-        [labelCounts]="itemAttrCounts('price')"
-        (changesSaved)="applyCopyValue('price')">
-      </eg-batch-item-attr>
-    </div>
-
-    <div>
-      <ng-template #opacVisibleTemplate>
-        <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"
-        [editTemplate]="opacVisibleTemplate"
-        [labelCounts]="itemAttrCounts('opac_visible')"
-        (changesSaved)="applyCopyValue('opac_visible')">
-      </eg-batch-item-attr>
-    </div>
-
-    <div>
-      <ng-template #refTemplate>
-        <ng-container *ngTemplateOutlet="yesNoSelect;context:{field:'ref'}">
-        </ng-container>
-      </ng-template>
-      <eg-batch-item-attr label="Reference" i18n-label
-        displayAs="bool"
-        editInputDomId="ref-input"
-        [editTemplate]="refTemplate"
-        [labelCounts]="itemAttrCounts('ref')"
-        (changesSaved)="applyCopyValue('ref')">
-      </eg-batch-item-attr>
-    </div>
-
-    <div>
-      <ng-template #costTemplate>
-        <input type="number" class="form-control" 
-          id="cost-input" [(ngModel)]="values['cost']"/>
-      </ng-template>
-      <eg-batch-item-attr label="Acquisition Cost" i18n-label
-        displayAs="currency"
-        editInputDomId="cost-input"
-        [emptyIsUnset]="true"
-        [editTemplate]="costTemplate"
-        [labelCounts]="itemAttrCounts('cost')"
-        (changesSaved)="applyCopyValue('cost')">
-      </eg-batch-item-attr>
-    </div>
-
-    <div>
-      <eg-string #mintConditionYes i18n-text text="Good"></eg-string>
-      <eg-string #mintConditionNo i18n-text text="Damaged"></eg-string>
-
-      <ng-template #mintConditionTemplate>
-        <select class="form-control" 
-          id="mint-condition-input" [(ngModel)]="values['mint_condition']">
-          <option value="t" i18n>{{mintConditionYes.text}}</option>
-          <option value="f" i18n>{{mintConditionNo.text}}</option>
-        </select>
-      </ng-template>
-      <eg-batch-item-attr label="Quality" i18n-label
-        editInputDomId="mint-condition-input"
-        [emptyIsUnset]="true"
-        [editTemplate]="mintConditionTemplate"
-        [labelCounts]="itemAttrCounts('mint_condition')"
-        (changesSaved)="applyCopyValue('mint_condition')">
-      </eg-batch-item-attr>
+    <div class="card">
+      <div class="card-header" i18n>Statistics</div>
+      <ul class="list-group list-group-flush">
+        <li class="list-group-item">
+          <div class="form-check form-check-inline">
+            <input class="form-check-input" type="checkbox" 
+              id="show-copy_tags-attr" 
+              [(ngModel)]="volcopy.defaults.hidden.copy_tags">
+            <label class="form-check-label" for="show-copy_tags-attr" i18n>
+              Add Item Tags
+            </label>
+          </div>
+        </li>
+        <li class="list-group-item">
+          <div class="form-check form-check-inline">
+            <input class="form-check-input" type="checkbox" 
+              id="show-statcats-attr" 
+              [(ngModel)]="volcopy.defaults.hidden.statcats">
+            <label class="form-check-label" for="show-statcats-attr" i18n>
+              Statistical Categories
+            </label>
+          </div>
+        </li>
+      </ul>
     </div>
-
   </div>
+</div>
 
-  <div class="flex-1 p-1">
-    <div class="p-1"><h4 class="font-weight-bold" i18n>Statistics</h4></div>
-
-    <div *ngFor="let cat of statCats(); let idx = index">
-      <ng-template #statCatTemplate>
-        <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}}"
-        [emptyIsUnset]="true"
-        [editTemplate]="statCatTemplate"
-        [labelCounts]="statCatCounts(cat.id())"
-        (changesSaved)="statCatChanged(cat.id())">
-      </eg-batch-item-attr>
-    </div>
-    -->
-
+<div class="row d-flex">
+  <div class="flex-1"></div>
+  <button class="btn btn-outline-dark" (click)="save()" i18n>Save Defaults</button>
 </div>
 
 
index f7fe312..5716f9e 100644 (file)
@@ -40,7 +40,7 @@ export class VolCopyConfigComponent implements OnInit, AfterViewInit {
     ) { }
 
     ngOnInit() {
-        console.log('DEFAULTS', this.volcopy.volCopyDefaults);
+        console.log('DEFAULTS', this.volcopy.defaults);
     }
 
     ngAfterViewInit() {
index d5016f9..7d1c579 100644 (file)
       </eg-batch-item-attr>
     </div>
 
-    <div *ngIf="displayAttr('owning_lib', true)">
+    <div *ngIf="displayAttr('owning_lib')">
       <ng-template #owningLibTemplate>
         <eg-org-select 
           domId="owning-lib-input"
     </div>
     -->
 
-    <div class="border rounded m-1" *ngIf="displayAttr('copy_notes', true)">
+    <div class="border rounded m-1" *ngIf="displayAttr('copy_notes')">
       <eg-copy-alerts-dialog #copyAlertsDialog></eg-copy-alerts-dialog>
       <div class="batch-header font-weight-bold p-2" i18n>Add Item Alerts</div>
       <div class="p-1">
   <div class="flex-1 p-1">
     <div class="p-1"><h4 class="font-weight-bold" i18n>Statistics</h4></div>
 
-    <ng-container *ngIf="displayAttr('statcats', true)">
+    <div class="border rounded m-1" *ngIf="displayAttr('copy_tags')">
+      <!--
+      <eg-copy-tags-dialog #copyTagsDialog></eg-copy-tags-dialog>
+      -->
+      <div class="batch-header font-weight-bold p-2" i18n>Add Item Tags</div>
+      <div class="p-1">
+        <button class="btn btn-outline-dark" (click)="openCopyAlerts()" i18n>
+          Item Tags
+        </button>
+      </div>
+    </div>
+
+    <ng-container *ngIf="displayAttr('statcats')">
       <div *ngFor="let cat of statCats(); let idx = index">
         <ng-template #statCatTemplate>
           <eg-combobox domId="stat-cat-input-{{idx}}"
index 427f93c..a8ec40b 100644 (file)
@@ -313,7 +313,7 @@ export class CopyAttrsComponent implements OnInit, AfterViewInit {
     }
 
     displayAttr(field: string): boolean {
-        return this.volcopy.volCopyDefaults.hidden[field] !== true;
+        return this.volcopy.defaults.hidden[field] !== true;
     }
 }
 
index 747b4bf..b6948a4 100644 (file)
@@ -491,7 +491,7 @@ export class VolEditComponent implements OnInit {
     }
 
     displayColumn(field: string): boolean {
-        return this.volcopy.volCopyDefaults.hidden[field] !== true;
+        return this.volcopy.defaults.hidden[field] !== true;
     }
 }
 
index 118c393..d9ce8a0 100644 (file)
@@ -25,7 +25,8 @@ export class VolCopyService {
 
     autoId = -1;
 
-    volCopyDefaults: VolCopyDefaults = null;
+    defaults: VolCopyDefaults = null;
+    defaultLocation: IdlObject;
     copyStatuses: {[id: number]: IdlObject} = null;
 
     // Track this here so it can survive route changes.
@@ -171,17 +172,23 @@ export class VolCopyService {
     }
 
     fetchDefaults(): Promise<any> {
-        if (this.volCopyDefaults) { return Promise.resolve(); }
+        if (this.defaults) { return Promise.resolve(); }
 
-        return this.serverStore.getItem('cat.volcopy.defaults').then(
+        return this.serverStore.getItem('eg.cat.volcopy.defaults').then(
             (defaults: VolCopyDefaults) => {
-                this.volCopyDefaults = defaults || {values: {}, hidden: {}};
+                this.defaults = defaults || {values: {}, hidden: {}};
             }
+
         ).then(_ => {
 
-            // Default to location ID 1 (Stacks)
-            return this.pcrud.retrieve('acpl', 1).toPromise()
-            .then(loc => this.volCopyDefaults.values.location = loc);
+            // Use the first non-deleted copy location within org unit
+            // range as the default.  Typically "Stacks".
+
+            const myOrgs = this.org.fullPath(this.auth.user().ws_ou(), true);
+            return this.pcrud.search('acpl',
+                {deleted: 'f', owning_lib: myOrgs},
+                {order_by: {acpl: 'id'}, limit: 1}
+            ).toPromise().then(loc => this.defaultLocation = loc);
         });
     }
 
@@ -207,7 +214,7 @@ export class VolCopyService {
         return this.net.request(
             'open-ils.cat',
             'open-ils.cat.biblio.record.marc_cn.retrieve',
-            id, this.volCopyDefaults.values.classification || null
+            id, this.defaults.values.classification || null
         ).toPromise().then(res => {
             return Object.values(res)
                 .map(blob => Object.values(blob)[0]).sort();
@@ -223,8 +230,8 @@ export class VolCopyService {
         vol.record(recordId);
         vol.label(null);
         vol.owning_lib(Number(orgId));
-        vol.prefix(this.volCopyDefaults.values.prefix || -1);
-        vol.suffix(this.volCopyDefaults.values.suffix || -1);
+        vol.prefix(this.defaults.values.prefix || -1);
+        vol.suffix(this.defaults.values.suffix || -1);
 
         return vol;
     }
@@ -242,7 +249,7 @@ export class VolCopyService {
         copy.deposit_amount(0);
         copy.fine_level(2);     // Normal
         copy.loan_duration(2);  // Normal
-        copy.location(this.volCopyDefaults.values.location);  // Stacks / fleshed
+        copy.location(this.defaultLocation);  // Stacks / fleshed
         copy.circulate('t');
         copy.holdable('t');
         copy.opac_visible('t');
@@ -275,12 +282,12 @@ export class VolCopyService {
 
         let promise = Promise.resolve(); // Serialization
 
-        if (this.volCopyDefaults.values.classification) {
+        if (this.defaults.values.classification) {
             // Workstation default classification overrides the
             // classification that might be used at the owning lib.
 
             vols.forEach(vol =>
-                vol.label_class(this.volCopyDefaults.values.classification));
+                vol.label_class(this.defaults.values.classification));
 
             return promise;
 
@@ -399,20 +406,20 @@ export class VolCopyService {
 
         // Scrub unnecessary content before storing.
 
-        Object.keys(this.volCopyDefaults.values).forEach(field => {
-            if (this.volCopyDefaults.values[field] === null) {
-                delete this.volCopyDefaults.values[field];
+        Object.keys(this.defaults.values).forEach(field => {
+            if (this.defaults.values[field] === null) {
+                delete this.defaults.values[field];
             }
         });
 
-        Object.keys(this.volCopyDefaults.hidden).forEach(field => {
-            if (this.volCopyDefaults.hidden[field] !== true) {
-                delete this.volCopyDefaults.hidden[field];
+        Object.keys(this.defaults.hidden).forEach(field => {
+            if (this.defaults.hidden[field] !== true) {
+                delete this.defaults.hidden[field];
             }
         });
 
         return this.serverStore.setItem(
-            'cat.volcopy.defaults', this.volCopyDefaults);
+            'eg.cat.volcopy.defaults', this.defaults);
     }
 }