From 551dbc10e57feecca7c172e19ab35e2525206819 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A6=BE=E5=87=A0=E6=B5=B7?= Date: Thu, 2 Jul 2020 23:09:39 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=9A=E7=94=A8=E5=8F=AF=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E7=BB=84=E4=BB=B6-=E6=98=BE=E7=A4=BA=E6=96=87=E6=9C=AC?= =?UTF-8?q?=EF=BC=8C=E6=95=B0=E6=8D=AE=E6=8F=90=E4=BA=A4=E5=9B=9E=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../editable-tag/editable-tag.component.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/app/view/admin/components/editable-tag/editable-tag.component.ts b/src/app/view/admin/components/editable-tag/editable-tag.component.ts index 7971c35..489ab1d 100644 --- a/src/app/view/admin/components/editable-tag/editable-tag.component.ts +++ b/src/app/view/admin/components/editable-tag/editable-tag.component.ts @@ -6,7 +6,7 @@ import {Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild} f - + {{text}} @@ -38,10 +37,12 @@ export class EditableTagComponent implements OnInit { inputValue = ''; @ViewChild('inputElement', {static: false}) inputElement?: ElementRef; - @Output() valueChange = new EventEmitter(); + @Output() valueChange = new EventEmitter<{ value: string, originalValue: string, changed: boolean }>(); @Input() color: string; @Input() showEditIcon: boolean; @Input() showBorder: boolean; + @Input() text: string; + private doubleClickInfo = { date: null, }; @@ -56,6 +57,7 @@ export class EditableTagComponent implements OnInit { } showInput(doubleClick: boolean): void { + this.inputValue = this.text; if (doubleClick) { if (!this.doubleClickInfo.date) { this.doubleClickInfo.date = new Date().getTime(); @@ -77,7 +79,12 @@ export class EditableTagComponent implements OnInit { } handleInputConfirm(): void { - this.valueChange.emit(this.inputValue) + this.valueChange.emit({ + value: this.inputValue, + originalValue: this.text, + changed: this.inputValue !== this.text + }) + this.text = this.inputValue; this.inputValue = ''; this.inputVisible = false; }