LP#1951307: Contextual confirm dialog button text
authorStephanie Leary <stephanie.leary@equinoxOLI.org>
Thu, 22 Sep 2022 18:40:45 +0000 (13:40 -0500)
committerStephanie Leary <stephanie.leary@equinoxOLI.org>
Thu, 22 Sep 2022 18:40:45 +0000 (13:40 -0500)
This patch 1) changes the confirm dialog buttons to "Yes" and "No" for
event cloning as requested, but more generally 2) allows the confirm
dialog to accept input strings specifying the text for these buttons,
with "Confirm" and "Cancel" as the defaults. You can now choose the
wording that makes the most sense in the context of the dialog.

See <eg-confirm-dialog> in triggers.component.html for usage.

To test:
-------
[1] Apply the patch and open the Local Admin Notifications/Action
    Triggers screen:
    eg2/en-US/staff/admin/local/action_trigger/event_definition
[2] Right-click a row and choose "Clone Selected."
[3] Verify that the choices are "Yes" and "No" instead of "Confirm" and
    "Cancel."
[4] Navigate to another screen that includes a confirm dialog, e.g.
    eg2/en-US/staff/reporter/simple, right click a report and select
    "Clone Report," to verify that "Confirm" and "Cancel" have not
    changed in other instances.

Open-ILS/src/eg2/src/app/share/dialog/confirm.component.html
Open-ILS/src/eg2/src/app/share/dialog/confirm.component.ts
Open-ILS/src/eg2/src/app/staff/admin/local/triggers/triggers.component.html

index 05cf562..4a17040 100644 (file)
   </div>
   <div class="modal-footer">
     <button type="button" class="btn btn-success" 
-      (click)="close(true)" i18n>Confirm</button>
+      (click)="close(true)" i18n>{{_confirmTrue}}</button>
     <button type="button" class="btn btn-warning" 
-      (click)="close(false)" i18n>Cancel</button>
+      (click)="close(false)" i18n>{{_confirmFalse}}</button>
   </div>
 </ng-template>
+
+<eg-string #defaultDialogConfirmTrue i18n-text text="Confirm"></eg-string>
+<eg-string #defaultDialogConfirmFalse i18n-text text="Cancel"></eg-string>
\ No newline at end of file
index f195f32..1e83440 100644 (file)
@@ -1,5 +1,6 @@
-import {Component, Input, ViewChild, TemplateRef} from '@angular/core';
+import {Component, Input, ViewChild, TemplateRef, AfterViewInit} from '@angular/core';
 import {DialogComponent} from '@eg/share/dialog/dialog.component';
+import {StringComponent} from '@eg/share/string/string.component';
 
 @Component({
   selector: 'eg-confirm-dialog',
@@ -9,10 +10,35 @@ import {DialogComponent} from '@eg/share/dialog/dialog.component';
 /**
  * Confirmation dialog that asks a yes/no question.
  */
-export class ConfirmDialogComponent extends DialogComponent {
+export class ConfirmDialogComponent extends DialogComponent implements AfterViewInit {
     // What question are we asking?
     @Input() public dialogBody: string;
+    @Input() public dialogConfirmTrue: string;
+    @Input() public dialogConfirmFalse: string;
     @Input() public dialogBodyTemplate: TemplateRef<any>;
-}
 
+    _confirmTrue = '';
+    _confirmFalse = '';
 
+    @ViewChild('defaultDialogConfirmTrue', {static: false}) defaultDialogConfirmTrue: StringComponent;
+    @ViewChild('defaultDialogConfirmFalse', {static: false}) defaultDialogConfirmFalse: StringComponent;
+
+    // Get confirm/cancel strings from the component HTML
+    ngAfterViewInit() {
+      if ( this.dialogConfirmTrue && this.dialogConfirmTrue.length ) {
+        this._confirmTrue = this.dialogConfirmTrue;
+      }
+      else {
+        this.defaultDialogConfirmTrue.current().then(str => this._confirmTrue = str);
+      }
+
+      if ( this.dialogConfirmFalse && this.dialogConfirmFalse.length ) {
+        this._confirmFalse = this.dialogConfirmFalse;
+      }
+      else {
+        this.defaultDialogConfirmFalse.current().then(str => this._confirmFalse = str);
+      }
+
+     
+    }
+  }
\ No newline at end of file
index 07e7901..35a430d 100644 (file)
 <div [ngbNavOutlet]="triggerNav" class="mt-2"></div>
 
 <eg-confirm-dialog #confirmDialog
-  i18n-dialogTitle i18n-dialogBody
+  i18n-dialogTitle i18n-dialogBody i18n-dialogConfirmTrue i18n-dialogConfirmFalse
   dialogTitle="Alert"
-  dialogBody="Clone event definition environment as well?">
+  dialogBody="Clone event definition environment as well?"
+  dialogConfirmTrue = "Yes"
+  dialogConfirmFalse = "No">
 </eg-confirm-dialog>
 
 <eg-string #createSuccessString i18n-text text="New entry Added"></eg-string>