| /******************************************************************************** |
| * Copyright (c) 2020 Contributors to the Eclipse Foundation |
| * |
| * See the NOTICE file(s) distributed with this work for additional |
| * information regarding copyright ownership. |
| * |
| * This program and the accompanying materials are made available under the |
| * terms of the Eclipse Public License 2.0 which is available at |
| * http://www.eclipse.org/legal/epl-2.0 |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| ********************************************************************************/ |
| |
| import {ChangeDetectorRef, Component, ElementRef, EventEmitter, Input, Output, ViewChild} from "@angular/core"; |
| |
| @Component({ |
| selector: "app-text-replacement", |
| templateUrl: "./text-replacement.component.html", |
| styleUrls: ["./text-replacement.component.scss"] |
| }) |
| export class TextReplacementComponent { |
| |
| @Input() |
| public appEditable = false; |
| |
| @Input() |
| public appType: string; |
| |
| @Input() |
| public appValue: string; |
| |
| @Input() |
| public appPlaceholder: string; |
| |
| @Input() |
| public appOptions: string[] = []; |
| |
| @ViewChild("inputElement") inputElement: ElementRef; |
| |
| @ViewChild("dateElement") dateElement: ElementRef; |
| |
| @ViewChild("selectElement") selectElement: ElementRef; |
| |
| @Output() |
| public appValueChange = new EventEmitter<string>(); |
| |
| public constructor(private changeDetectorRef: ChangeDetectorRef) { |
| } |
| |
| public async onClick() { |
| this.appEditable = true; |
| this.changeDetectorRef.detectChanges(); |
| switch (this.appType) { |
| case "input": |
| this.inputElement.nativeElement.focus(); |
| break; |
| } |
| } |
| |
| public onFocusOut() { |
| this.appEditable = false; |
| } |
| |
| public inputValue(value: string) { |
| this.appValueChange.emit(value); |
| } |
| } |