﻿import { Component, ViewChild, Injector, Output, EventEmitter, OnInit } from '@angular/core';
{{Import_Modal_Directive_Here}}
import { {{Entity_Name_Plural_Here}}ServiceProxy, Get{{Entity_Name_Here}}ForViewDto, {{Entity_Name_Here}}Dto {{Enum_Import_After_V060600_Here}}{{Enum_Import_Before_V060600_Here}}} from '@shared/service-proxies/service-proxies';
import { AppComponentBase } from '@shared/common/app-component-base';
import { ActivatedRoute } from '@angular/router';
import { appModuleAnimation } from '@shared/animations/routerTransition';

@Component({
    selector: 'view{{Entity_Name_Here}}',
    templateUrl: './view-{{entity_Name_Here}}.component.html',
    animations: [appModuleAnimation()]
})
export class View{{Entity_Name_Here}}Component extends AppComponentBase implements OnInit {

    active = false;
    saving = false;

    item: Get{{Entity_Name_Here}}ForViewDto;
{{enum_Def_After_V060600_Here}}{{enum_Def_Before_V060600_Here}}

    constructor(
        injector: Injector,
        private _activatedRoute: ActivatedRoute,
         private _{{entity_Name_Plural_Here}}ServiceProxy: {{Entity_Name_Plural_Here}}ServiceProxy
    ) {
        super(injector);
        this.item = new Get{{Entity_Name_Here}}ForViewDto();
        this.item.{{entity_Name_Here}} = new {{Entity_Name_Here}}Dto();        
    }

    ngOnInit(): void {
        this.show(this._activatedRoute.snapshot.queryParams['id']);
    }

    show({{entity_Name_Here}}Id: {{Primary_Key_Type_Here}}): void {
      this._{{entity_Name_Plural_Here}}ServiceProxy.get{{Entity_Name_Here}}ForView({{entity_Name_Here}}Id).subscribe(result => {      
                 this.item = result;
                this.active = true;
            });       
    }
}
