LP1842763 Vandelay allow targeted import w/o action
authorBill Erickson <berickxx@gmail.com>
Mon, 14 Oct 2019 15:04:17 +0000 (11:04 -0400)
committerBill Erickson <berickxx@gmail.com>
Wed, 12 May 2021 14:27:44 +0000 (10:27 -0400)
Allow the user to process selected queued records, which may or may not
have an overlay target selected, without requiring an import action be
selected.  In the case of records with overlay targets, the import
action (overlay selected target) is implicit, so there's no need to
select an action.

Additionally, when an import selection has been defined, change the
action button from "Upload" to "Import", since we're past the upload
stage at this point.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/staff/cat/vandelay/import.component.html
Open-ILS/src/eg2/src/app/staff/cat/vandelay/import.component.ts

index 2882bc5..93f237a 100644 (file)
     <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>
+        (click)="upload()">
+        <ng-container *ngIf="importSelection()" i18n>Import</ng-container>
+        <ng-container *ngIf="!importSelection()" i18n>Upload</ng-container>
+      </button>
     </div>
   </div>
   <!-- hide instead of *ngIf so ViewChild can find the progress bars -->
index 08f795d..549254e 100644 (file)
@@ -323,7 +323,8 @@ export class ImportComponent implements OnInit, AfterViewInit, OnDestroy {
     // Required form data varies depending on context.
     hasNeededData(): boolean {
         if (this.vandelay.importSelection) {
-            return this.importActionSelected();
+            // No additional form data required
+            return true;
         } else {
             return this.selectedQueue &&
                 Boolean(this.recordType) && Boolean(this.selectedFile);
@@ -502,16 +503,25 @@ export class ImportComponent implements OnInit, AfterViewInit, OnDestroy {
 
     importRecords(): Promise<any> {
 
-        if (!this.importActionSelected()) {
-            return Promise.resolve();
-        }
-
         const selection = this.vandelay.importSelection;
 
-        if (selection && !selection.importQueue) {
-            return this.importRecordQueue(selection.recordIds);
-        } else {
+        if (selection) {
+            // Additional import actions are optional
+
+            if (selection.importQueue) {
+                return this.importRecordQueue();
+
+            } else {
+                // Import selected records only
+                return this.importRecordQueue(selection.recordIds);
+            }
+
+        } else if (this.importActionSelected()) {
+            // Importing a new queue requires at least one import action.
+
             return this.importRecordQueue();
+        } else {
+            return Promise.resolve();
         }
     }