import { Component, OnInit, ViewChild } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { CreateQuestionnaireComponent } from './create-questionnaire/create-questionnaire.component'; import { Message } from 'primeng/api'; import { QuestionnaireService } from '../../shared/services/questionnaire.service'; @Component({ selector: 'app-create-incometax-questionnaire', templateUrl: './create-incometax-questionnaire.component.html', styleUrls: ['./create-incometax-questionnaire.component.css'], providers: [QuestionnaireService] }) export class CreateIncometaxQuestionnaireComponent implements OnInit { // Child Component @ViewChild(CreateQuestionnaireComponent) CreateQuestionnaireComponent: CreateQuestionnaireComponent; // Phase Name phaseName: string; // Job plan Id jobPlanId: number; // Phase settings Id phaseSettingsId: number; // Phase id PhaseId: number; previewArray: any = []; // No data Message noDataMessage: Message[] = []; // No data flag nodataFlag = false; // button disble disableButton = false; // Read only flag readOnlyFlag = false; constructor(private questionnaireService: QuestionnaireService, private route: ActivatedRoute) { } ngOnInit() { this.disableButton = false; // No record message this.noDataMessage = []; this.noDataMessage.push({ severity: 'warn', summary: 'You must enter phase name ?', detail: '' }); // get URL parameters this.route.params.subscribe(params => { this.jobPlanId = params.jobPlanId; }); // Phase Settings Id // Need to remove Hardcode Value this.phaseSettingsId = 1; } // Insert phase name InsertPhaseName() { this.questionnaireService.InsertPhaseName(this.phaseSettingsId, this.jobPlanId, this.phaseName) .subscribe( data => { if (data != null) { this.PhaseId = data; this.disableButton = true; this.readOnlyFlag = true; } else { console.log('Saving Fail'); } } ); } // Save Questionnaire saveQuestionnaire() { if (this.phaseName !== '' && this.phaseName !== undefined) { // Insert Questions this.CreateQuestionnaireComponent.Save(); this.nodataFlag = false; } else { this.nodataFlag = true; } } openNav() { // document.getElementById('mySidenav').style.width = '100%'; this.CreateQuestionnaireComponent.ShowPreview(); } closeNav() { document.getElementById('mySidenav').style.width = '0'; } // Clear message ClearMessage() { this.nodataFlag = false; } }