CAT-211 Vandelay Label Improvements
authorKyle Huckins <khuckins@catalyte.io>
Tue, 9 Apr 2019 21:27:58 +0000 (21:27 +0000)
committerBill Erickson <berickxx@gmail.com>
Mon, 15 Apr 2019 18:14:01 +0000 (18:14 +0000)
- Cause "Save as New Template" to display as "Modify Template" when an
existing template is selected.
- Cause "Upload" to display as "Import" when importing from the queue.

Signed-off-by: Kyle Huckins <khuckins@catalyte.io>
 Changes to be committed:
modified:   Open-ILS/src/eg2/src/app/staff/cat/vandelay/import.component.html
modified:   Open-ILS/src/eg2/src/app/staff/cat/vandelay/import.component.ts

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 c7f8c17..ed03288 100644 (file)
       </eg-combobox>
     </div>
     <div class="col-lg-6">
-      <button class="btn btn-success"
+      <button class="btn btn-success" *ngIf="!templateInputMatch"
         [disabled]="!selectedTemplate"
         (click)="saveTemplate()" i18n>Save As New Template</button>
+      <button class="btn btn-success" *ngIf="templateInputMatch"
+        [disabled]="!selectedTemplate"
+        (click)="saveTemplate()" i18n>Modify Template</button>
       <button class="btn btn-outline-primary ml-3"
         [disabled]="!selectedTemplate"
         (click)="markTemplateDefault()" i18n>Mark Template as Default</button>
     </div>
   </div>
   <div class="row">
-    <div class="col-lg-6 offset-lg-3">
+    <div class="col-lg-6 offset-lg-3" *ngIf="!importSelection()">
       <button class="btn btn-success btn-lg btn-block font-weight-bold"
         [disabled]="isUploading || !hasNeededData()" 
         (click)="upload()" i18n>Upload</button>
     </div>
+    <div class="col-lg-6 offset-lg-3" *ngIf="importSelection()">
+      <button class="btn btn-success btn-lg btn-block font-weight-bold"
+        [disabled]="isUploading || !hasNeededData()" 
+        (click)="upload()" i18n>Import</button>
+    </div>
   </div>
   <!-- hide instead of *ngIf so ViewChild can find the progress bars -->
   <div class="row" [hidden]="!showProgress || importSelection()">
index 15b5640..87a2d7f 100644 (file)
@@ -103,6 +103,7 @@ export class ImportComponent implements OnInit, AfterViewInit, OnDestroy {
     selectedTemplate: string;
     formTemplates: {[name: string]: any};
     newTemplateName: string;
+    templateInputMatch: boolean;
 
     @ViewChild('fileSelector') private fileSelector;
     @ViewChild('uploadProgress')
@@ -589,6 +590,7 @@ export class ImportComponent implements OnInit, AfterViewInit, OnDestroy {
         console.debug('Saving import profile', template);
 
         this.formTemplates[this.selectedTemplate] = template;
+        this.templateInputMatch = true;
         return this.store.setItem(TEMPLATE_SETTING_NAME, this.formTemplates);
     }
 
@@ -613,13 +615,14 @@ export class ImportComponent implements OnInit, AfterViewInit, OnDestroy {
         this.selectedTemplate = entry.label; // label == name
 
         if (entry.freetext) {
+            this.templateInputMatch = false;
             // User is entering a new template name.
             // Nothing to apply.
             return;
         }
 
         // User selected an existing template, apply it to the form.
-
+        this.templateInputMatch = true;
         const template = this.formTemplates[entry.id];
 
         // Copy the template values into "this"