tweak Create and Clone Selection List dialogs
authorJason Etheridge <jason@EquinoxInitiative.org>
Tue, 19 Nov 2019 05:36:30 +0000 (00:36 -0500)
committerGalen Charlton <gmc@equinoxinitiative.org>
Thu, 16 Jan 2020 21:38:28 +0000 (16:38 -0500)
Auto-focus and clear the input widgets, and default the clone widget to
"Copy of <selected list>"

Open-ILS/src/eg2/src/app/staff/acq/search/picklist-clone-dialog.component.ts
Open-ILS/src/eg2/src/app/staff/acq/search/picklist-create-dialog.component.ts
Open-ILS/src/eg2/src/app/staff/acq/search/picklist-results.component.ts

index 63996dc..27aef6c 100644 (file)
@@ -1,4 +1,4 @@
-import {Component, Input, ViewChild, TemplateRef, OnInit} from '@angular/core';
+import {Component, Input, ViewChild, TemplateRef, OnInit, Renderer2} from '@angular/core';
 import {Observable, from, empty, throwError} from 'rxjs';
 import {DialogComponent} from '@eg/share/dialog/dialog.component';
 import {AlertDialogComponent} from '@eg/share/dialog/alert.component';
@@ -25,6 +25,7 @@ export class PicklistCloneDialogComponent
   @ViewChild('fail', { static: true }) private fail: AlertDialogComponent;
 
   constructor(
+    private renderer: Renderer2,
     private idl: IdlService,
     private evt: EventService,
     private net: NetService,
@@ -39,6 +40,8 @@ export class PicklistCloneDialogComponent
 
   update() {
     this.leadListName = this.grid.context.getSelectedRows()[0].name();
+    this.renderer.selectRootElement('#create-picklist-name').focus();
+    this.selectionListName = 'Copy of ' + this.leadListName;
   }
 
   cloneList() {
index 2325aae..97aee85 100644 (file)
@@ -1,4 +1,4 @@
-import {Component, Input, ViewChild, TemplateRef, OnInit} from '@angular/core';
+import {Component, Input, ViewChild, TemplateRef, OnInit, Renderer2} from '@angular/core';
 import {Observable, from, empty, throwError} from 'rxjs';
 import {DialogComponent} from '@eg/share/dialog/dialog.component';
 import {AlertDialogComponent} from '@eg/share/dialog/alert.component';
@@ -22,6 +22,7 @@ export class PicklistCreateDialogComponent
   @ViewChild('fail', { static: true }) private fail: AlertDialogComponent;
 
   constructor(
+    private renderer: Renderer2,
     private idl: IdlService,
     private evt: EventService,
     private net: NetService,
@@ -35,6 +36,11 @@ export class PicklistCreateDialogComponent
     this.selectionListName = '';
   }
 
+  update() {
+    this.selectionListName = '';
+    this.renderer.selectRootElement('#create-picklist-name').focus();
+  }
+
   createList() {
     const picklist = this.idl.create('acqpl');
     picklist.owner(this.auth.user().id())
index a373e1f..059772c 100644 (file)
@@ -76,6 +76,7 @@ export class PicklistResultsComponent implements OnInit {
                 this.picklistResultsGrid.reload(); // FIXME - spec calls for inserted grid row and not refresh
             }
         );
+        this.picklistCreateDialog.update(); // clear and focus the textbox
     }
 
     openCloneDialog(rows: IdlObject[]) {