import { Component, Injector, OnInit, Output, EventEmitter, ViewChild } from '@angular/core'; import { AppComponentBase } from '@shared/common/app-component-base'; import { appModuleAnimation } from '@shared/animations/routerTransition'; import { AppLocalizationService } from '@app/shared/common/localization/app-localization.service'; import { ModalDirective } from 'ngx-bootstrap'; import { TextToSpeechSettingsServiceProxy, CreateOrUpdateTextToSpeechSettingInputDto, GetTextToSpeechSettingListItemDto } from '@shared/service-proxies/service-proxies'; @Component({ selector: 'add-mobile-app-texttospeech-setting-modal', templateUrl: './add-mobile-app-texttospeech-setting-modal.component.html', animations: [appModuleAnimation()] }) export class AddMobileAppTextToSpeechSettingModalComponent extends AppComponentBase implements OnInit { @Output() showLoaderEvent = new EventEmitter(); @Output() modalSaveEvent = new EventEmitter(); @ViewChild('modalDirective', { static: false }) modalDirective: ModalDirective; dialogTitle: string = ""; code: string; description: string; content: string; constructor( injector: Injector, private _textToSpeechSettingsServiceProxy: TextToSpeechSettingsServiceProxy, private _localizationService: AppLocalizationService ) { super(injector); } ngOnInit(): void { } show(record?: GetTextToSpeechSettingListItemDto): void { this.dialogTitle = this._localizationService.l('CreateTextToSpeechSetting'); if (record) { this.dialogTitle = this._localizationService.l('UpdateTextToSpeechSetting'); this.code = record.code; this.description = record.description; this.content = record.content; } this.modalDirective.show(); } close(): void { this.code = null; this.description = null; this.content = null; this.modalDirective.hide(); } save(): void { var data = new CreateOrUpdateTextToSpeechSettingInputDto(); data.code = this.code; data.description = this.description; data.content = this.content; this.showLoaderEvent.emit(true); this._textToSpeechSettingsServiceProxy.createOrUpdate(data) .subscribe(result => { this.showLoaderEvent.emit(false); this.modalSaveEvent.emit(null); this.close(); }); } }