From f3adea12e9de2b1505f4a2cf52968dd3b1692cac Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 17 Jun 2020 16:35:58 -0400 Subject: [PATCH] VOLCOPY Item attr batch component Signed-off-by: Bill Erickson --- .../staff/share/holdings/batch-item-attr.component.html | 3 ++- .../staff/share/holdings/batch-item-attr.component.ts | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/share/holdings/batch-item-attr.component.html b/Open-ILS/src/eg2/src/app/staff/share/holdings/batch-item-attr.component.html index 8597d91332..e8f00a2dc0 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/holdings/batch-item-attr.component.html +++ b/Open-ILS/src/eg2/src/app/staff/share/holdings/batch-item-attr.component.html @@ -4,7 +4,8 @@ {{label}} *
+ [ngClass]="{'has-changes': hasChanged}" (keyup.enter)="toggleEditMode()" + (click)="toggleEditMode()">
diff --git a/Open-ILS/src/eg2/src/app/staff/share/holdings/batch-item-attr.component.ts b/Open-ILS/src/eg2/src/app/staff/share/holdings/batch-item-attr.component.ts index fe10d345b9..408ebf9284 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/holdings/batch-item-attr.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/holdings/batch-item-attr.component.ts @@ -1,4 +1,4 @@ -import {Component, OnInit, Input, Output, ViewChild, Renderer2, TemplateRef, +import {Component, OnInit, Input, Output, ViewChild, TemplateRef, EventEmitter} from '@angular/core'; import {StringComponent} from '@eg/share/string/string.component'; @@ -30,6 +30,8 @@ export class BatchItemAttrComponent { // interact with the template in any way. @Input() editTemplate: TemplateRef; + @Input() editInputDomId = ''; + // In some cases, we can map display labels to something more // human friendly. @Input() displayAs: 'bool' | 'currency' = null; @@ -62,8 +64,17 @@ export class BatchItemAttrComponent { } toggleEditMode() { - if (!this.readOnly) { - this.editing = !this.editing; + if (this.readOnly) { return; } + + this.editing = !this.editing; + + // Avoid using selectRootElement to focus. + // https://stackoverflow.com/a/36059595 + if (this.editing && this.editInputDomId) { + setTimeout(() => { + const node = document.getElementById(this.editInputDomId); + if (node) { node.focus(); } + }); } } } -- 2.11.0