import { Component, OnInit, Output, EventEmitter } from '@angular/core';

@Component({
  selector: 'ucap-inline-edit-input',
  templateUrl: './inline-edit-input.component.html',
  styleUrls: ['./inline-edit-input.component.scss']
})
export class InlineEditInputComponent implements OnInit {
  @Output()
  edit = new EventEmitter<Event>();
  @Output()
  cancel = new EventEmitter<Event>();
  @Output()
  apply = new EventEmitter<Event>();

  get editMode() {
    return this._editMode;
  }
  set editMode(editMode: boolean) {
    this._editMode = editMode;
  }
  // tslint:disable-next-line: variable-name
  _editMode = false;

  constructor() {}

  ngOnInit() {}

  onClickEdit(event: Event) {
    this.editMode = true;
    this.edit.emit(event);
  }

  onClickCancel(event: Event) {
    this.editMode = false;
    this.cancel.emit(event);
  }

  onClickApply(event: Event) {
    this.editMode = false;
    this.apply.emit(event);
  }
}
