/**
 * Made by mkcomponent.sh
 * * Change to Fileheader info *
*/

import { Component, OnInit, OnChanges, Inject, Input, Output, EventEmitter } from '@angular/core'


@Component({
    moduleId: module.id+ '',
    selector: 'shared-inputEditor',
    templateUrl: './template/t--inputEditor.pug',
    styleUrls: ['sty.inputEditor.scss']
})

export class InputEditorComponent {

    // ---- Variables ---- \\
    @Input('attribute') attribute: string
    isEditable: boolean = false

    @Output() output: EventEmitter<any> = new EventEmitter();

    constructor( ) { }


    // ---- Lifecycle hooks ---- \\
    ngOnInit() {

    }

    // ---- Functions ---- \\
    edit() {
        this.isEditable = true
    }

    cancel() {
        this.isEditable = false
    }

    accept(event) {

        this.attribute = event.value
        this.output.emit(event.value)
        this.isEditable = false
    }
}