import { AfterViewChecked, Component, ElementRef, EventEmitter, Injector, Output, ViewChild } from '@angular/core'; import { AppConsts } from '@shared/AppConsts'; import { AppComponentBase } from '@shared/common/app-component-base'; import { TagTypeServiceProxy, CreateTagInput, TagServiceProxy, TagTypeListDto, ShippingPackageListDto, OrderServiceProxy, ShippingPackageServiceProxy, CreateOrderPackageInput, OrderListDto, OrderPackageServiceProxy, IncidentTypesServiceProxy, CreateOrEditIncidentTypeDto, IncidentStatusServiceProxy, CreateOrUpdateIncidentStatusInput} from '@shared/service-proxies/service-proxies'; import { ModalDirective } from 'ngx-bootstrap'; import * as _ from 'lodash'; import { finalize } from 'rxjs/operators'; import { OrderList } from 'primeng/primeng'; @Component({ selector: 'createUpdateIncidentStatusModal', templateUrl: './create-update-incidentstatus.component.html' }) export class CreateUpdateIncidentStatusComponent extends AppComponentBase { @ViewChild('createOrEditModal', {static: false}) modal: ModalDirective; @Output() modalSave: EventEmitter = new EventEmitter(); active = false; saving = false; code: string; name: string; sort: number; id: number; color: string; createUpdate: CreateOrUpdateIncidentStatusInput = new CreateOrUpdateIncidentStatusInput();; constructor( injector: Injector, private _incidentStatusService: IncidentStatusServiceProxy, ) { super(injector); } show(id?): void { this.active = true; this.id = id; if(id != null){ this._incidentStatusService.getIncidentStatus(id, undefined).subscribe(result=>{ this.code = result.code; this.name = result.name; this.color = result.color; }) } this.modal.show(); } save(): void { this.saving = true; this.createUpdate.id = this.id; this.createUpdate.code = this.code; this.createUpdate.name = this.name; this.createUpdate.color = this.color; this._incidentStatusService.createOrUpdateIncidentStatus(this.createUpdate) .pipe(finalize(() => { this.saving = false; })) .subscribe(() => { this.notify.info(this.l('SavedSuccessfully')); this.name = null; this.code = null; this.close(); this.modalSave.emit(null); }); } close(): void { this.active = false; this.modal.hide(); } }