LP#1942220: teach the acq MARC import component new tricks
authorGalen Charlton <gmc@equinoxOLI.org>
Wed, 8 Dec 2021 22:40:07 +0000 (17:40 -0500)
committerGalen Charlton <gmc@equinoxOLI.org>
Wed, 8 Dec 2021 22:40:07 +0000 (17:40 -0500)
Specifically, how to acted in a mode that gathers record
import parameters to drive PO and LI asset creation

Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
Open-ILS/src/eg2/src/app/staff/acq/picklist/upload.component.html
Open-ILS/src/eg2/src/app/staff/acq/picklist/upload.component.ts

index d2f4c15..ce76ccd 100644 (file)
@@ -1,7 +1,7 @@
-<eg-staff-banner bannerText="Load MARC Order Records" i18n-bannerText>
+<eg-staff-banner bannerText="Load MARC Order Records" i18n-bannerText *ngIf="mode !== 'getImportParams'">
 </eg-staff-banner>
 
-<div class="row">
+<div class="row" *ngIf="mode !== 'getImportParams'">
   <div class="ml-auto mr-3"><a i18n href="/eg/staff/acq/legacy/picklist/upload">Legacy Upload Interface</a></div>
 </div>
 
@@ -13,7 +13,8 @@
 <div class="common-form striped-odd form-validated ml-3 mr-3">
   <div class="row">
     <div class="col-lg-3">
-      <label for="template-select" i18n>Apply/Create Form Template</label>
+      <label for="template-select" i18n *ngIf="mode !== 'getImportParams'">Apply/Create Form Template</label>
+      <label for="template-select" i18n *ngIf="mode === 'getImportParams'">Apply Form Template</label>
     </div>
     <div class="col-lg-3">
       <eg-combobox #formTemplateSelector
@@ -25,7 +26,7 @@
         [entries]="formatTemplateEntries()">
       </eg-combobox>
     </div>
-    <div class="col-lg-6">
+    <div class="col-lg-6" *ngIf="mode !== 'getImportParams'">
       <button class="btn btn-success"
         [disabled]="!selectedTemplate"
         (click)="saveTemplate()" i18n>Save As New Template</button>
@@ -38,6 +39,7 @@
     </div>
   </div>
 
+  <ng-container *ngIf="mode !== 'getImportParams'">
   <h2>Purchase Order</h2>
   <div class="row">
     <div class="col-lg-3">
       </eg-combobox>
     </div>
   </div>
+  </ng-container> <!-- purchase order section -->
 
-
-  <h2>Upload Settings</h2>
+  <h2 *ngIf="mode !== 'getImportParams'">Upload Settings</h2>
 
   <div class="row">
     <div class="col-lg-3">
       <input type="number" step="0.1" id="min-quality-ratio" 
         class="form-control" [(ngModel)]="minQualityRatio">
     </div>
+    <ng-container *ngIf="mode !== 'getImportParams'">
     <div class="col-lg-3">
       <label for="load-items" i18n>Load Items for Imported Records</label>
     </div>
         id="load-items"
         [(ngModel)]="loadItems">
     </div>
+    </ng-container>
   </div>
 
-  <h2>This Upload</h2>
+  <h2 *ngIf="mode !== 'getImportParams'">This Upload</h2>
   <div class="row">
     <div class="col-lg-3">
       <label for="queue-select" i18n>Select or Create a Queue</label>
       </eg-combobox>
     </div>
   </div>
-  <div class="row" *ngIf="!importSelection()">
+  <div class="row" *ngIf="!importSelection() && mode !== 'getImportParams'">
     <div class="col-lg-3">
       <label for="upload-file" i18n>File to Upload:</label>
     </div>
       </button>
     </div>
   </div>
-  <div class="row">
+  <div class="row" *ngIf="mode !== 'getImportParams'">
     <div class="col-lg-6 offset-lg-3">
       <button class="btn btn-success btn-lg btn-block font-weight-bold"
         [disabled]="isUploading || !hasNeededData()" 
         (click)="upload()" i18n>Upload</button>
     </div>
   </div>
+  <div class="row" *ngIf="mode === 'getImportParams'">
+    <div class="col-lg-6 offset-lg-3">
+      <button class="btn btn-success btn-lg btn-block font-weight-bold"
+        [disabled]="customActionProcessing || !hasNeededData()" 
+        (click)="performCustomAction()" i18n>Load Bibs and Items</button>
+    </div>
+  </div>
   <div class="row" [hidden]="!showProgress || uploadComplete">
     <div class="col-lg-3">
       <label i18n>Upload File to Server</label>
index 22ae79d..47b990c 100644 (file)
@@ -58,10 +58,21 @@ const ORG_SETTINGS = [
 
 
 @Component({
+  selector: 'eg-acq-upload',
   templateUrl: './upload.component.html'
 })
 export class UploadComponent implements OnInit, AfterViewInit, OnDestroy {
 
+    // mode can be one of
+    //  upload:          actually upload and process a MARC order file
+    //  getImportParams: gather import parameters to use when creating
+    //                   assets for a purchase order; the invoker
+    //                   would do the actual asset creation
+    @Input() mode = 'upload';
+
+    @Input() customAction: (args: any) => void;
+    customActionProcessing = false;
+
     settings: Object = {};
     recordType: string;
     selectedQueue: ComboboxEntry;
@@ -333,6 +344,9 @@ export class UploadComponent implements OnInit, AfterViewInit, OnDestroy {
     }
 
     hasNeededData(): boolean {
+        if (this.mode === 'getImportParams') {
+            return this.selectedQueue ? true : false;
+        }
         return this.selectedQueue &&
         Boolean(this.selectedFile) &&
         Boolean(this.selectedFiscalYear) &&
@@ -371,6 +385,35 @@ export class UploadComponent implements OnInit, AfterViewInit, OnDestroy {
         );
     }
 
+    performCustomAction() {
+
+        const vandelayOptions = {
+            import_no_match: this.importNonMatching,
+            auto_overlay_exact: this.mergeOnExact,
+            auto_overlay_best_match: this.mergeOnBestMatch,
+            auto_overlay_1match: this.mergeOnSingleMatch,
+            merge_profile: this.selectedMergeProfile,
+            fall_through_merge_profile: this.selectedFallThruMergeProfile,
+            match_quality_ratio: this.minQualityRatio,
+            bib_source: this.selectedBibSource,
+            create_assets: this.loadItems,
+            queue_name: this.selectedQueue.label
+        };
+
+        const args = {
+            provider: this.selectedProvider,
+            ordering_agency: this.orderingAgency,
+            create_po: this.createPurchaseOrder,
+            activate_po: this.activatePurchaseOrder,
+            fiscal_year: this.selectedFiscalYear,
+            picklist: this.activeSelectionListId,
+            vandelay: vandelayOptions
+        };
+
+        this.customActionProcessing = true;
+        this.customAction(args);
+    }
+
     resetProgressBars() {
         this.uploadProgress.update({value: 0, max: 1});
     }