import { Component, EventEmitter, ElementRef, Injector, Output, ViewChild, ViewContainerRef } from '@angular/core'; import { AppComponentBase } from '@shared/common/app-component-base'; import { IncidentServiceProxy, CreateIncidentInput } from '@shared/service-proxies/service-proxies'; import { GeocodeServiceProxy, CreateGeocodeInput } from '@shared/service-proxies/service-proxies'; import * as _ from 'lodash'; import { ModalDirective } from 'ngx-bootstrap'; import { finalize } from 'rxjs/operators'; import { AppConsts } from '@shared/AppConsts'; import { appModuleAnimation } from '@shared/animations/routerTransition'; import {FormBuilder, FormGroup, Validators} from "@angular/forms"; import * as moment from 'moment'; @Component({ selector: 'incidentNotesModal', templateUrl: './incident-notes-modal.component.html' }) export class IncidentNotesModalComponent extends AppComponentBase { @ViewChild('createModal', {static: false}) modal: ModalDirective; @Output() modalSave: EventEmitter = new EventEmitter(); note: any; notes: any[] = []; incidentInput: { id: number; geocodeId: number; content: string; incidentDate: string; }; incidentDate: Date; incidentTime: any; active: boolean = false; saving: boolean = false; incident: CreateIncidentInput = new CreateIncidentInput(); constructor( injector: Injector, private _incidentService: IncidentServiceProxy, private viewContainerRef: ViewContainerRef ) { super(injector); } show() { this.note = null; this.active = true; this.init(); this.modal.show(); } onShown(): void { //document.getElementById('valueInput').focus(); } init(): void { } save(): void { this.notes.push(this.note); this.getParentComponent().notes.push(this.notes); console.log(this.notes); //this.saving = true; this.close(); //this.modalSave.emit(null); } getParentComponent() { return this.viewContainerRef[ '_data' ].componentView.component.viewContainerRef[ '_view' ].component } close(): void { this.active = false; this.modal.hide(); } }