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; }