import { Component, OnInit, Input } from '@angular/core'; import { DialogService } from 'primeng/api'; import { AddConditionalJumpComponent } from '../../popups/add-conditional-jump/add-conditional-jump.component'; import { Router } from '@angular/router'; import { OverlayPanel } from 'primeng/primeng'; import { Default } from '../../../shared/core/Default.enum'; import { IQuestionKeys } from '../../../shared/core/Questionnaire/IQuestionKeys'; import { ILayoutSettings } from '../../../shared/core/Questionnaire/ILayoutSettings'; import { IQuestionnareList } from '../../../shared/core/Questionnaire/IQuestionnareList'; import { SharedBehaviorSubjectService } from '../../../shared/services/shared-behavior-subject.service'; import { QuestionnaireService } from '../../../shared/services/questionnaire.service'; @Component({ selector: 'app-create-questionnaire', templateUrl: './create-questionnaire.component.html', styleUrls: ['./create-questionnaire.component.css'] }) export class CreateQuestionnaireComponent implements OnInit { columns: { field: string; header: string; width: string }[]; questions: any = null; brands: any = null; answertype: any = null; displayDialog: boolean; answerTypeId = null; showLoading: boolean = false; typeId: any = null; settingsObject: any = []; settingArray: any = []; // Passing Question Object questionsList: any[] = []; questionKeyList: IQuestionKeys[]; obj: IQuestionKeys = null; dropdownOptionsArray: any = []; checkBoxOptionsArray: any = []; radioButtonOptionsArray: any = []; questionnaire: any = []; layoutSetting: ILayoutSettings = null; singlemultipleType: any = null; colNumbers: any[] = []; rowNumbers: any[] = []; // Multiquestion selected rows selectedColNumber: number = 0; selectedRowNumber: number = 0; displayHeaddingSettings = false; displayTextSettings = false; InsertedIQuestionnareList: IQuestionnareList[] = []; selectedAnserType: any = null; selectedAnserTypes: any = []; // Get Phase id @Input() PhaseId: number = null; columnssss: { field: string; header: string; width: string; ColNumber: number; RowNumber: number; }[]; // Show Preview showPreviewFlag = false; answerYesNo: any = null; // Multiquestion Answewr Type answerTypeP: string = null; constructor(public dialogService: DialogService, private sharedService: SharedBehaviorSubjectService, private questionnaireService: QuestionnaireService, private router: Router) { this.sharedService.settingsObjectSource.subscribe((obj: any) => { // console.log('Message: ', obj); this.typeId = obj.TypeId; this.settingsObject = obj; if (this.settingsObject.Index != null) { this.getQuestionSettings(this.settingsObject.Index); } }); this.sharedService.settingsLayoutSource.subscribe((obj: any) => { if (obj === null) { this.settingArray = []; this.rowNumbers = []; } else { this.layoutSetting = obj; } }); this.columns = [ { field: 'cName', header: 'Client Name', width: '60%' }, { field: 'cCode', header: 'Client Code', width: '10%' }, { field: 'cPlan', header: 'Recent Job Plan Due', width: '10%' }, { field: 'cEmail', header: 'Email', width: '10%' }, { field: 'cContact', header: 'Contact', width: '10%' }, ]; } ngOnInit() { // list of the organisation table columns this.questions = [{ cName: 'Jhon', cCode: '1994', cPlan: '20', cEmail: 'Test@sample.com', cContact: '(021)-123-2078', cTotalPlan: '2', cActive: '3', cComplete: '1', cArchive: '1' }, { cName: 'Jhon', cCode: '1994', cPlan: '20', cEmail: 'Test@sample.com', cContact: '(021)-123-2078', cTotalPlan: '2', cActive: '2', cComplete: '2', cArchive: '2' }]; this.brands = [ { label: 'Jhon', value: null }, { label: 'Sam', value: 'Sam' }, { label: 'Anna', value: 'Anna' }, { label: 'Betty', value: 'Betty' }, ]; this.answertype = [ { answer: 'Text' }, { answer: 'Email Address' }, { answer: 'Website Url' }, { answer: 'Phone Numbers' }, { answer: 'Number' }, ]; this.answerYesNo = [ { label: 'Select', value: null }, { label: 'Yes' }, { label: 'No' }, { label: 'N/A' }, ]; this.singlemultipleType = [ { label: 'Select', value: null }, { label: 'Radio buttons' }, { label: 'Checkboxes' }, { label: 'Dropdowns' }, ]; this.singlemultipleType = [ { label: 'Select', value: null }, { label: 'Radio buttons' }, { label: 'Checkboxes' }, { label: 'Dropdowns' }, ] } input() { // console.log('Input', this.rowNumbers); } showthemenu(columnValue) { if (columnValue === 'Questions') { } if (columnValue === 'Answer') { } } getQuestionSettings(Index) { if (this.settingsObject.Multiple === true) { this.rowNumbers[Index] = this.settingsObject; // console.log('Get settings test', this.rowNumbers); } else { this.settingArray[Index] = this.settingsObject; } } clickOnNewQuestion() { if (this.layoutSetting !== null && this.layoutSetting !== undefined) { if (this.layoutSetting.ColNumber <= 5) { if (this.colNumbers.length === 0) { for (let i = 0; i < this.layoutSetting.ColNumber; i++) { this.colNumbers.push(i); } for (let i = 0; i < this.layoutSetting.RowNumber; i++) { const obj3 = { ColNumber: -1, RowNumber: -1, }; // console.log('Type id Check', this.typeId); const headingDefaultObj = { TypeId: 1, Index: 0, Question: '', SubHeadingToggle: false, SubHeading: '', DescriptionToggle: false, Description: '', GroupQuestionToggle: false, Multiple: true, Data: obj3 }; this.rowNumbers.push(headingDefaultObj); // console.log('Row array check', this.rowNumbers); } } } } if (this.typeId === Default.Heading) { const headingDefaultObj = { TypeId: this.settingsObject.TypeId, Index: this.settingsObject.Index, Question: this.settingsObject.Question, SubHeadingToggle: this.settingsObject.SubHeadingToggle, SubHeading: this.settingsObject.SubHeading, DescriptionToggle: this.settingsObject.DescriptionToggle, Description: this.settingsObject.Description, Multiple: this.settingsObject.Multiple, GroupQuestionToggle: this.settingsObject.GroupQuestionToggle, }; this.settingArray.push(headingDefaultObj); // console.log('array', this.settingArray); } else if (this.typeId === Default.Text) { const textDefaultObj = { TypeId: this.settingsObject.TypeId, Index: this.settingsObject.Index, Question: this.settingsObject.Question, RequiredToggle: this.settingsObject.RequiredToggle, DescriptionToggle: this.settingsObject.DescriptionToggle, Description: this.settingsObject.Description, TextResponseInSingleToggle: this.settingsObject.TextResponseInSingleToggle, MaxCharactesToggle: this.settingsObject.MaxCharactesToggle, MaxCharactes: this.settingsObject.MaxCharactes, GroupBelowToggle: this.settingsObject.GroupBelowToggle }; this.settingArray.push(textDefaultObj); } else if (this.typeId === Default.EmailAddress) { const emailDefaultObj = { TypeId: this.settingsObject.TypeId, Index: this.settingsObject.Index, Question: this.settingsObject.Question, RequiredBool: this.settingsObject.RequiredBool, DescriptionToggle: this.settingsObject.DescriptionToggle, Description: this.settingsObject.Description, GroupQuestionToggle: this.settingsObject.GroupQuestionToggle }; this.settingArray.push(emailDefaultObj); } else if (this.typeId === Default.WebsiteURL) { const webUrlDefaultObj = { TypeId: this.settingsObject.TypeId, Index: this.settingsObject.Index, Question: this.settingsObject.Question, RequiredBool: this.settingsObject.RequiredBool, DescriptionToggle: this.settingsObject.DescriptionToggle, Description: this.settingsObject.Description, GroupQuestionToggle: this.settingsObject.GroupQuestionToggle }; this.settingArray.push(webUrlDefaultObj); } else if (this.typeId === Default.PhoneNumber) { const phoneNumberDefaultObj = { TypeId: this.settingsObject.TypeId, Index: this.settingsObject.Index, Question: this.settingsObject.Question, RequiredBool: this.settingsObject.RequiredBool, DescriptionToggle: this.settingsObject.DescriptionToggle, Description: this.settingsObject.Description, MaxCharactersToggle: this.settingsObject.MaxCharactersToggle, MaxCharacters: this.settingsObject.MaxCharacters, GroupQuestionToggle: this.settingsObject.GroupQuestionToggle }; this.settingArray.push(phoneNumberDefaultObj); } else if (this.typeId === Default.Numbers) { const numberDefaultObj = { TypeId: this.settingsObject.TypeId, Index: this.settingsObject.Index, Question: this.settingsObject.Question, RequiredBool: this.settingsObject.RequiredBool, DescriptionToggle: this.settingsObject.DescriptionToggle, Description: this.settingsObject.Description, MaxNumberToggle: this.settingsObject.MaxNumberToggle, MaxNumber: this.settingsObject.MaxNumber, MinNumberToggle: this.settingsObject.MinNumberToggle, MinNumber: this.settingsObject.MinNumber, GroupQuestionToggle: this.settingsObject.GroupQuestionToggle }; this.settingArray.push(numberDefaultObj); } else if (this.typeId === Default.Amount) { const amountDefaultObj = { TypeId: this.settingsObject.TypeId, Index: this.settingsObject.Index, Question: this.settingsObject.Question, RequiredBool: this.settingsObject.RequiredBool, DescriptionToggle: this.settingsObject.DescriptionToggle, Description: this.settingsObject.Description, MaxAmmountToggle: this.settingsObject.MaxAmmountToggle, MaxAmmount: this.settingsObject.MaxAmmount, MinAmmountToggle: this.settingsObject.MinAmmountToggle, MinAmmount: this.settingsObject.MinAmmount, CurrencyFormatToggle: this.settingsObject.CurrencyFormatToggle, CurrencyFormat: this.settingsObject.CurrencyFormat, GroupQuestionToggle: this.settingsObject.GroupQuestionToggle }; this.settingArray.push(amountDefaultObj); } else if (this.typeId === Default.SingleMultipleChoice) { const singleMultipleDefaultObj = { TypeId: this.settingsObject.TypeId, Index: this.settingsObject.Index, Question: this.settingsObject.Question, ChoiceType: this.settingsObject.ChoiceType, RequiredBool: this.settingsObject.RequiredBool, DescriptionToggle: this.settingsObject.DescriptionToggle, Description: this.settingsObject.Description, AlphabeticOrderToggle: this.settingsObject.AlphabeticOrderToggle, TextResInSingleToggle: this.settingsObject.TextResInSingleToggle, MpultipleSelectionToggle: this.settingsObject.MpultipleSelectionToggle, MpultipleSelection: this.settingsObject.MpultipleSelection, RangeStart: this.settingsObject.RangeStart, RangeEnd: this.settingsObject.RangeEnd, ChoiceAllignment: this.settingsObject.ChoiceAllignment, GroupQuestionToggle: this.settingsObject.GroupQuestionToggle, RadioButtonOptions: this.settingsObject.RadioButtonOptions, CheckBoxOptions: this.settingsObject.CheckBoxOptions, DropdownOptions: this.settingsObject.DropdownOptions }; this.settingArray.push(singleMultipleDefaultObj); } else if (this.typeId === Default.OpinionRatingScales) { const opinionRatingDefaultObj = { TypeId: this.settingsObject.TypeId, Index: this.settingsObject.Index, Question: this.settingsObject.Question, ScaleType: this.settingsObject.ScaleType, RequiredBool: this.settingsObject.RequiredBool, DescriptionToggle: this.settingsObject.DescriptionToggle, Description: this.settingsObject.Description, StartScaleAt: this.settingsObject.StartScaleAt, EndScaleAt: this.settingsObject.EndScaleAt, LabelLeft: this.settingsObject.LabelLeft, LabelCenter: this.settingsObject.LabelCenter, LabelRight: this.settingsObject.LabelRight, ShowNumberingToggle: this.settingsObject.ShowNumberingToggle, GroupQuestionToggle: this.settingsObject.GroupQuestionToggle }; this.settingArray.push(opinionRatingDefaultObj); } else if (this.typeId === Default.DateTime) { const dateTimeDefaultObj = { TypeId: this.settingsObject.TypeId, Index: this.settingsObject.Index, Question: this.settingsObject.Question, RequiredBool: this.settingsObject.RequiredBool, DescriptionToggle: this.settingsObject.DescriptionToggle, Description: this.settingsObject.Description, DateFormatToggle: this.settingsObject.DateFormatToggle, DateFormat: this.settingsObject.DateFormat, DateSymbols: this.settingsObject.DateSymbols, TimeFormatToggle: this.settingsObject.TimeFormatToggle, TimeFormats: this.settingsObject.TimeFormats, GroupQuestionToggle: this.settingsObject.GroupQuestionToggle }; this.settingArray.push(dateTimeDefaultObj); } else if (this.typeId === Default.YesNo) { const yesNoDefaultObj = { TypeId: this.settingsObject.TypeId, Index: this.settingsObject.Index, Question: this.settingsObject.Question, RequiredBool: this.settingsObject.RequiredBool, AddExtraOptionToggle: this.settingsObject.AddExtraOptionToggle, ExtraOpinion: this.settingsObject.ExtraOpinion, }; this.settingArray.push(yesNoDefaultObj); } else if (this.typeId === Default.FileUpload) { const fileUploadDefaultObj = { TypeId: this.settingsObject.TypeId, Index: this.settingsObject.Index, Question: this.settingsObject.Question, RequiredBool: this.settingsObject.RequiredBool, DescriptionToggle: this.settingsObject.DescriptionToggle, Description: this.settingsObject.Description, GroupQuestionToggle: this.settingsObject.GroupQuestionToggle }; this.settingArray.push(fileUploadDefaultObj); } // console.log('Settings Array', this.settingArray); this.sharedService.previewQuestions.next(this.settingArray); } clickOnQuestion(node, i) { // console.log('Index', node); node.Index = i; node.DefaultFlag = false; this.sharedService.settingsObjectSourceGet.next(node); } addToArray(ChoiceType, option, Index) { // console.log('ddd', ChoiceType, option, Index); if (ChoiceType.TypeChoiseId === 1) { // this.radioButtonOptionsArray.push(option); this.settingArray[Index].RadioButtonOptions.push(option); // console.log('ddd2', this.settingArray); } else if (ChoiceType.TypeChoiseId === 2) { // this.checkBoxOptionsArray.push(option); this.settingArray[Index].CheckBoxOptions.push(option); // tslint:disable-next-line:align } else if (ChoiceType.TypeChoiseId === 3) { const dropdownObj = { label: option, value: option }; // this.dropdownOptionsArray.push(dropdownObj); this.settingArray[Index].DropdownOptions.push(dropdownObj); } } // Heading Input InputHeading(inputHeading) { // console.log('inputHeading'); // console.log(inputHeading); } Save() { this.showLoading = true; // console.log('Save Questions'); // tslint:disable-next-line:prefer-for-of if (this.layoutSetting !== null && this.layoutSetting !== undefined) { // tslint:disable-next-line:prefer-for-of for (let index = 0; index < this.rowNumbers.length; index++) { if (this.rowNumbers[index].TypeId === 1) { this.questionKeyList = [ { QuestionKeyId: -1, QuestionAnswerTypesId: this.rowNumbers[index].TypeId, QuestionsKeyTypeId: 2, Description: 'SubHeadingToggle', KeyValue: this.rowNumbers[index].SubHeadingToggle, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.rowNumbers[index].TypeId, QuestionsKeyTypeId: 1, Description: 'SubHeading', KeyValue: this.rowNumbers[index].SubHeading, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.rowNumbers[index].TypeId, QuestionsKeyTypeId: 1, Description: 'DescriptionToggle', KeyValue: this.rowNumbers[index].DescriptionToggle, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.rowNumbers[index].TypeId, QuestionsKeyTypeId: 1, Description: 'Description', KeyValue: this.rowNumbers[index].Description, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.rowNumbers[index].TypeId, QuestionsKeyTypeId: 2, Description: 'GroupQuestionToggle', KeyValue: this.rowNumbers[index].GroupQuestionToggle, ParentId: 0 } ]; const obj = { QuestionId: -1, QuestionAnswerTypesId: this.rowNumbers[index].TypeId, PhaseId: this.PhaseId, Title: this.rowNumbers[index].Question, Description: '', QuestionKeyList: this.questionKeyList }; this.questionsList.push(obj); } else if (this.rowNumbers[index].TypeId === 2) { this.questionKeyList = [ { QuestionKeyId: -1, QuestionAnswerTypesId: this.rowNumbers[index].TypeId, QuestionsKeyTypeId: 2, Description: 'RequiredToggle', KeyValue: this.rowNumbers[index].RequiredToggle, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.rowNumbers[index].TypeId, QuestionsKeyTypeId: this.rowNumbers[index].TypeId, Description: 'DescriptionToggle', KeyValue: this.rowNumbers[index].DescriptionToggle, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.rowNumbers[index].TypeId, QuestionsKeyTypeId: 1, Description: 'Description', KeyValue: this.rowNumbers[index].Description, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.rowNumbers[index].TypeId, QuestionsKeyTypeId: 2, Description: 'TextResponseInSingleToggle', KeyValue: this.rowNumbers[index].TextResponseInSingleToggle, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.rowNumbers[index].TypeId, QuestionsKeyTypeId: 2, Description: 'MaxCharactesToggle', KeyValue: this.rowNumbers[index].MaxCharactesToggle, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.rowNumbers[index].TypeId, QuestionsKeyTypeId: 1, Description: 'MaxCharactes', KeyValue: this.rowNumbers[index].MaxCharactes, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.rowNumbers[index].TypeId, QuestionsKeyTypeId: 2, Description: 'GroupBelowToggle', KeyValue: this.rowNumbers[index].GroupBelowToggle, ParentId: 0 } ]; const obj = { QuestionId: -1, QuestionAnswerTypesId: this.rowNumbers[index].TypeId, PhaseId: this.PhaseId, Title: this.rowNumbers[index].Question, Description: '', QuestionKeyList: this.questionKeyList }; this.questionsList.push(obj); } } this.showLoading = false; } else { // tslint:disable-next-line:prefer-for-of for (let index = 0; index < this.settingArray.length; index++) { if (this.settingArray[index].TypeId === Default.Heading) { this.questionKeyList = [ { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'SubHeadingToggle', KeyValue: this.settingArray[index].SubHeadingToggle, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 1, Description: 'SubHeading', KeyValue: this.settingArray[index].SubHeading, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 1, Description: 'DescriptionToggle', KeyValue: this.settingArray[index].DescriptionToggle, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 1, Description: 'Description', KeyValue: this.settingArray[index].Description, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'GroupQuestionToggle', KeyValue: this.settingArray[index].GroupQuestionToggle, ParentId: 0 } ]; const obj = { QuestionId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, PhaseId: this.PhaseId, Title: this.settingArray[index].Question, Description: '', QuestionKeyList: this.questionKeyList }; this.questionsList.push(obj); } else if (this.settingArray[index].TypeId === Default.Text) { this.questionKeyList = [ { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'RequiredToggle', KeyValue: this.settingArray[index].RequiredToggle, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: this.settingArray[index].TypeId, Description: 'DescriptionToggle', KeyValue: this.settingArray[index].DescriptionToggle, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 1, Description: 'Description', KeyValue: this.settingArray[index].Description, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'TextResponseInSingleToggle', KeyValue: this.settingArray[index].TextResponseInSingleToggle, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'MaxCharactesToggle', KeyValue: this.settingArray[index].MaxCharactesToggle, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 1, Description: 'MaxCharactes', KeyValue: this.settingArray[index].MaxCharactes, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'GroupBelowToggle', KeyValue: this.settingArray[index].GroupBelowToggle, ParentId: 0 } ]; const obj = { QuestionId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, PhaseId: this.PhaseId, Title: this.settingArray[index].Question, Description: '', QuestionKeyList: this.questionKeyList }; this.questionsList.push(obj); } else if (this.settingArray[index].TypeId === Default.EmailAddress) { this.questionKeyList = [ { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'RequiredBool', KeyValue: this.settingArray[index].RequiredBool, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'DescriptionToggle', KeyValue: this.settingArray[index].DescriptionToggle, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 1, Description: 'Description', KeyValue: this.settingArray[index].Description, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'GroupQuestionToggle', KeyValue: this.settingArray[index].GroupQuestionToggle, ParentId: 0 } ]; const obj = { QuestionId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, PhaseId: this.PhaseId, Title: this.settingArray[index].Question, Description: '', QuestionKeyList: this.questionKeyList }; this.questionsList.push(obj); } else if (this.settingArray[index].TypeId === Default.WebsiteURL) { this.questionKeyList = [ { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'RequiredBool', KeyValue: this.settingArray[index].RequiredBool, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'DescriptionToggle', KeyValue: this.settingArray[index].DescriptionToggle, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 1, Description: 'Description', KeyValue: this.settingArray[index].Description, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'GroupQuestionToggle', KeyValue: this.settingArray[index].GroupQuestionToggle, ParentId: 0 } ]; const obj = { QuestionId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, PhaseId: this.PhaseId, Title: this.settingArray[index].Question, Description: '', QuestionKeyList: this.questionKeyList }; this.questionsList.push(obj); } else if (this.settingArray[index].TypeId === Default.PhoneNumber) { this.questionKeyList = [ { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'RequiredBool', KeyValue: this.settingArray[index].RequiredBool, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'DescriptionToggle', KeyValue: this.settingArray[index].DescriptionToggle, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 1, Description: 'Description', KeyValue: this.settingArray[index].Description, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'MaxCharactersToggle', KeyValue: this.settingArray[index].MaxCharactersToggle, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 1, Description: 'MaxCharacters', KeyValue: this.settingArray[index].MaxCharacters, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'GroupQuestionToggle', KeyValue: this.settingArray[index].GroupQuestionToggle, ParentId: 0 } ]; const obj = { QuestionId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, PhaseId: this.PhaseId, Title: this.settingArray[index].Question, Description: '', QuestionKeyList: this.questionKeyList }; this.questionsList.push(obj); } else if (this.settingArray[index].TypeId === Default.Numbers) { this.questionKeyList = [ { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'RequiredBool', KeyValue: this.settingArray[index].RequiredBool, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'DescriptionToggle', KeyValue: this.settingArray[index].DescriptionToggle, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 1, Description: 'Description', KeyValue: this.settingArray[index].Description, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'MinNumberToggle', KeyValue: this.settingArray[index].MinNumberToggle, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 1, Description: 'MinNumber', KeyValue: this.settingArray[index].MinNumber, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'MaxNumberToggle', KeyValue: this.settingArray[index].MaxNumberToggle, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 1, Description: 'MaxNumber', KeyValue: this.settingArray[index].MaxNumber, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'GroupQuestionToggle', KeyValue: this.settingArray[index].GroupQuestionToggle, ParentId: 0 } ]; const obj = { QuestionId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, PhaseId: this.PhaseId, Title: this.settingArray[index].Question, Description: '', QuestionKeyList: this.questionKeyList }; this.questionsList.push(obj); } else if (this.settingArray[index].TypeId === Default.Amount) { this.questionKeyList = [ { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'RequiredBool', KeyValue: this.settingArray[index].RequiredBool, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'DescriptionToggle', KeyValue: this.settingArray[index].DescriptionToggle, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 1, Description: 'Description', KeyValue: this.settingArray[index].Description, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'MaxAmmountToggle', KeyValue: this.settingArray[index].MaxAmmountToggle, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 1, Description: 'MaxAmmount', KeyValue: this.settingArray[index].MaxAmmount, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'MinAmmountToggle', KeyValue: this.settingArray[index].MinAmmountToggle, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 1, Description: 'MinAmmount', KeyValue: this.settingArray[index].MinAmmount, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'CurrencyFormatToggle', KeyValue: this.settingArray[index].CurrencyFormatToggle, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 1, Description: 'CurrencyFormat', KeyValue: this.settingArray[index].CurrencyFormat, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'GroupQuestionToggle', KeyValue: this.settingArray[index].GroupQuestionToggle, ParentId: 0 } ]; const obj = { QuestionId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, PhaseId: this.PhaseId, Title: this.settingArray[index].Question, Description: '', QuestionKeyList: this.questionKeyList }; this.questionsList.push(obj); } else if (this.settingArray[index].TypeId === Default.SingleMultipleChoice) { // Radio buttons let radioValues = ''; // tslint:disable-next-line: prefer-for-of for (let i = 0; i < this.settingArray[index].RadioButtonOptions.length; i++) { if (this.settingArray[index].RadioButtonOptions[i] !== null && this.settingArray[index].RadioButtonOptions[i] !== '') { radioValues += this.settingArray[index].RadioButtonOptions[i] + ','; // console.log('Check radio string', radioValues); } } // CheckBoxes let checkboxValues = ''; // tslint:disable-next-line: prefer-for-of for (let i = 0; i < this.settingArray[index].CheckBoxOptions.length; i++) { if (this.settingArray[index].CheckBoxOptions[i] !== null && this.settingArray[index].CheckBoxOptions[i] !== '') { checkboxValues += this.settingArray[index].CheckBoxOptions[i] + ','; } } // Dropdown let dropdownValues = ''; // tslint:disable-next-line: prefer-for-of for (let i = 0; i < this.settingArray[index].DropdownOptions.length; i++) { if (this.settingArray[index].DropdownOptions[i] !== null && this.settingArray[index].DropdownOptions[i] !== '') { dropdownValues += this.settingArray[index].DropdownOptions[i] + ','; } } this.questionKeyList = [ { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 3, Description: 'ChoiceType', KeyValue: this.settingArray[index].ChoiceType.TypeChoiseId, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'RequiredBool', KeyValue: this.settingArray[index].RequiredBool, ParentId: -1 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'DescriptionToggle', KeyValue: this.settingArray[index].DescriptionToggle, ParentId: -1 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 1, Description: 'Description', KeyValue: this.settingArray[index].Description, ParentId: -1 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'AlphabeticOrderToggle', KeyValue: this.settingArray[index].AlphabeticOrderToggle, ParentId: -1 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'TextResInSingleToggle', KeyValue: this.settingArray[index].TextResInSingleToggle, ParentId: -1 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 1, Description: 'MpultipleSelectionToggle', KeyValue: this.settingArray[index].MpultipleSelectionToggle, ParentId: -1 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 1, Description: 'MpultipleSelection', KeyValue: this.settingArray[index].MpultipleSelection, ParentId: -1 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 1, Description: 'RangeStart', KeyValue: this.settingArray[index].RangeStart, ParentId: -1 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 1, Description: 'RangeEnd', KeyValue: this.settingArray[index].RangeEnd, ParentId: -1 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'ChoiceAllignment', KeyValue: this.settingArray[index].ChoiceAllignment.TypeChoiceAllignmentsId, ParentId: -1 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'RadioButtonOptions', KeyValue: radioValues, ParentId: -1 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'CheckBoxOptions', KeyValue: checkboxValues, ParentId: -1 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'DropdownOptions', KeyValue: dropdownValues, ParentId: -1 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'GroupQuestionToggle', KeyValue: this.settingArray[index].GroupQuestionToggle, ParentId: -1 } ]; const obj = { QuestionId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, PhaseId: this.PhaseId, Title: this.settingArray[index].Question, Description: '', QuestionKeyList: this.questionKeyList }; this.questionsList.push(obj); } else if (this.settingArray[index].TypeId === Default.OpinionRatingScales) { this.questionKeyList = [ { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 3, Description: 'ScaleType', KeyValue: this.settingArray[index].ScaleType, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'RequiredBool', KeyValue: this.settingArray[index].RequiredBool, ParentId: -1 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'DescriptionToggle', KeyValue: this.settingArray[index].DescriptionToggle, ParentId: -1 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 1, Description: 'Description', KeyValue: this.settingArray[index].Description, ParentId: -1 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 1, Description: 'StartScaleAt', KeyValue: this.settingArray[index].StartScaleAt, ParentId: -1 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 1, Description: 'EndScaleAt', KeyValue: this.settingArray[index].EndScaleAt, ParentId: -1 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 1, Description: 'LabelLeft', KeyValue: this.settingArray[index].LabelLeft, ParentId: -1 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 1, Description: 'LabelCenter', KeyValue: this.settingArray[index].LabelCenter, ParentId: -1 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 1, Description: 'LabelRight', KeyValue: this.settingArray[index].LabelRight, ParentId: -1 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'ShowNumberingToggle', KeyValue: this.settingArray[index].ShowNumberingToggle, ParentId: -1 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'GroupQuestionToggle', KeyValue: this.settingArray[index].GroupQuestionToggle, ParentId: -1 } ]; const obj = { QuestionId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, PhaseId: this.PhaseId, Title: this.settingArray[index].Question, Description: '', QuestionKeyList: this.questionKeyList }; this.questionsList.push(obj); } else if (this.settingArray[index].TypeId === Default.DateTime) { this.questionKeyList = [ { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'RequiredBool', KeyValue: this.settingArray[index].RequiredBool, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'DescriptionToggle', KeyValue: this.settingArray[index].DescriptionToggle, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 1, Description: 'Description', KeyValue: this.settingArray[index].Description, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'DateFormatToggle', KeyValue: this.settingArray[index].DateFormatToggle, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 3, Description: 'DateFormat', KeyValue: this.settingArray[index].DateFormat, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 3, Description: 'DateSymbols', KeyValue: this.settingArray[index].DateSymbols, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'TimeFormatToggle', KeyValue: this.settingArray[index].TimeFormatToggle, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 1, Description: 'TimeFormats', KeyValue: this.settingArray[index].TimeFormats, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'GroupQuestionToggle', KeyValue: this.settingArray[index].GroupQuestionToggle, ParentId: 0 } ]; const obj = { QuestionId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, PhaseId: this.PhaseId, Title: this.settingArray[index].Question, Description: '', QuestionKeyList: this.questionKeyList }; this.questionsList.push(obj); } else if (this.settingArray[index].TypeId === Default.YesNo) { this.questionKeyList = [ { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'RequiredBool', KeyValue: this.settingArray[index].RequiredBool, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'AddExtraOptionToggle', KeyValue: this.settingArray[index].AddExtraOptionToggle, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'ExtraOpinion', KeyValue: this.settingArray[index].ExtraOpinion, ParentId: 0 } ]; const obj = { QuestionId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, PhaseId: this.PhaseId, Title: this.settingArray[index].Question, Description: '', QuestionKeyList: this.questionKeyList }; this.questionsList.push(obj); } else if (this.settingArray[index].TypeId === Default.FileUpload) { this.questionKeyList = [ { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'RequiredBool', KeyValue: this.settingArray[index].RequiredBool, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'DescriptionToggle', KeyValue: this.settingArray[index].DescriptionToggle, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 1, Description: 'Description', KeyValue: this.settingArray[index].Description, ParentId: 0 }, { QuestionKeyId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, QuestionsKeyTypeId: 2, Description: 'GroupQuestionToggle', KeyValue: this.settingArray[index].GroupQuestionToggle, ParentId: 0 } ]; const obj = { QuestionId: -1, QuestionAnswerTypesId: this.settingArray[index].TypeId, PhaseId: this.PhaseId, Title: this.settingArray[index].Question, Description: '', QuestionKeyList: this.questionKeyList }; this.questionsList.push(obj); } } this.showLoading = false; } // console.log('Create Question Response', this.questionsList); this.showLoading = true; this.questionnaireService.InsertQuestionnaire(this.questionsList).subscribe( data => { // console.log('Create Question Response', data); this.obj = null; this.questionKeyList = []; this.questionsList = []; this.settingsObject = []; this.settingArray = []; this.dropdownOptionsArray = []; this.checkBoxOptionsArray = []; this.radioButtonOptionsArray = []; this.questionnaire = []; this.colNumbers = []; this.rowNumbers = []; this.InsertedIQuestionnareList = []; this.selectedAnserTypes = []; this.showLoading = false; this.router.navigate(['/ClientHome']); } ) } setSelectValues(col, row) { this.displayHeaddingSettings = false; this.displayTextSettings = false; this.selectedColNumber = col; this.selectedRowNumber = row; } headingOnClick(event) { this.typeId = 1; const obj2 = { ColNumber: this.selectedColNumber, RowNumber: this.selectedRowNumber, }; const headingDefaultObj = { TypeId: this.typeId, Index: this.selectedRowNumber, Question: '', SubHeadingToggle: false, SubHeading: '', DescriptionToggle: false, Description: '', GroupQuestionToggle: false, Multiple: true, DefaultFlag: false, Data: obj2 }; // console.log(this.selectedColNumber); // console.log(this.selectedRowNumber); // console.log('Tset column number', headingDefaultObj); this.sharedService.settingsObjectSourceGetMultiple.next(headingDefaultObj); this.sharedService.settingsLayoutSourceGet.next({ TypeId: 1, DefaultFlag: false }); for (let index = 0; index < this.rowNumbers.length; index++) { if (index === this.selectedRowNumber) { this.rowNumbers[index] = headingDefaultObj; } } // console.log('Row test', this.rowNumbers); this.displayHeaddingSettings = true; this.displayTextSettings = false; } textOnClick(event) { this.typeId = 2; const obj2 = { ColNumber: this.selectedColNumber, RowNumber: this.selectedRowNumber, }; const textDefaultObj = { TypeId: this.typeId, Index: this.selectedRowNumber, Question: '', RequiredToggle: false, DescriptionToggle: false, Description: '', TextResponseInSingleToggle: false, MaxCharactesToggle: false, MaxCharactes: null, Multiple: true, GroupBelowToggle: false, DefaultFlag: false, Data: obj2 }; this.sharedService.settingsObjectSourceGetMultiple.next(textDefaultObj); this.sharedService.settingsLayoutSourceGet.next({ TypeId: 2, DefaultFlag: false }); for (let index = 0; index < this.rowNumbers.length; index++) { if (index === this.selectedRowNumber) { this.rowNumbers[index] = textDefaultObj; } } this.displayHeaddingSettings = false; this.displayTextSettings = true; } isDisaplyCellItems(row, col, questionTypeId) { let status = false; // tslint:disable-next-line: prefer-for-of for (let i = 0; i < this.InsertedIQuestionnareList.length; i++) { if (this.InsertedIQuestionnareList[i].ColNumber === col && this.InsertedIQuestionnareList[i].RowNumber === row && this.InsertedIQuestionnareList[i].QuestionTypeId === questionTypeId) { status = true; break; } } return status; } clickOnMultipleQuestion(node, i) { node.Index = i; this.sharedService.settingsLayoutSourceGet.next({ TypeId: node.TypeId, DefaultFlag: false }); this.sharedService.settingsObjectSourceGetMultiple.next(node); } addRowEvent() { const obj3 = { ColNumber: -1, RowNumber: -1, }; const headingDefaultObj = { TypeId: 1, Index: 0, Question: '', SubHeadingToggle: false, SubHeading: '', DescriptionToggle: false, Description: '', GroupQuestionToggle: false, Multiple: true, Data: obj3 }; this.rowNumbers.push(headingDefaultObj); } addConditionalJumpPopup(RowIndex, ColIndex) { // Open the conditional jump const ref = this.dialogService.open(AddConditionalJumpComponent, { width: '30%', data: { rowIndex: RowIndex, colIndex: ColIndex, allQuestions: this.rowNumbers, allAnswerTypes: this.selectedAnserTypes }, header: 'Add Conditional Jump' }); ref.onClose.subscribe(() => { }); } clickAnswerType(answerTypeP) { // console.log('Answer Type:',this.selectedAnserTypes); let status = false; this.answerTypeId = answerTypeP; // tslint:disable-next-line:prefer-for-of for (let i = 0; i < this.selectedAnserTypes.length; i++) { // tslint:disable-next-line:max-line-length if (this.selectedAnserTypes[i].colNumber === this.selectedColNumber && this.selectedAnserTypes[i].rowNumber === this.selectedRowNumber) { this.selectedAnserTypes[i].answerType = answerTypeP; status = true; break; } } if (status === false) { this.selectedAnserTypes.push( { colNumber: this.selectedColNumber, rowNumber: this.selectedRowNumber, answerType: answerTypeP } ); } this.answerTypeId = answerTypeP; // console.log('Answer Type:',this.selectedAnserTypes); // console.log('Answer Type:',this.answerTypeId); const obj2 = { ColNumber: this.selectedColNumber, RowNumber: this.selectedRowNumber, }; debugger; switch (answerTypeP) { case 'Text': this.typeId = 2; const TextdefaultObj = { Data: obj2 }; this.sharedService.settingsObjectSourceGetMultiple.next(TextdefaultObj); this.sharedService.settingsLayoutSourceGet.next({ TypeId: 2, DefaultFlag: false }); break; case 'EmailAddress': this.typeId = 3; const EmailAddressdefaultObj = { Data: obj2 }; this.sharedService.settingsObjectSourceGetMultiple.next(EmailAddressdefaultObj); this.sharedService.settingsLayoutSourceGet.next({ TypeId: 3, DefaultFlag: false }); break; case 'WebsiteURL': this.typeId = 4; const WebsiteURLdefaultObj = { Data: obj2 }; this.sharedService.settingsObjectSourceGetMultiple.next(WebsiteURLdefaultObj); this.sharedService.settingsLayoutSourceGet.next({ TypeId: 4, DefaultFlag: false }); break; case 'PhoneNumber': this.typeId = 5; const PhoneNumberdefaultObj = { Data: obj2 }; this.sharedService.settingsObjectSourceGetMultiple.next(PhoneNumberdefaultObj); this.sharedService.settingsLayoutSourceGet.next({ TypeId: 5, DefaultFlag: false }); break; case 'Numbers': this.typeId = 6; const NumbersdefaultObj = { Data: obj2 }; this.sharedService.settingsObjectSourceGetMultiple.next(NumbersdefaultObj); this.sharedService.settingsLayoutSourceGet.next({ TypeId: 6, DefaultFlag: false }); break; case 'Amount': this.typeId = 7; const AmountdefaultObj = { Data: obj2 }; this.sharedService.settingsObjectSourceGetMultiple.next(AmountdefaultObj); this.sharedService.settingsLayoutSourceGet.next({ TypeId: 7, DefaultFlag: false }); break; case 'SingleMultipleChoice': this.typeId = 8; const SingleMultipleChoicedefaultObj = { Data: obj2 }; this.sharedService.settingsObjectSourceGetMultiple.next(SingleMultipleChoicedefaultObj); this.sharedService.settingsLayoutSourceGet.next({ TypeId: 8, DefaultFlag: false }); break; case 'OpinionRatingScales': this.typeId = 9; const OpinionRatingScalesfaultObj = { Data: obj2 }; this.sharedService.settingsObjectSourceGetMultiple.next(OpinionRatingScalesfaultObj); this.sharedService.settingsLayoutSourceGet.next({ TypeId: 9, DefaultFlag: false }); break; case 'DateTime': this.typeId = 10; const DateTimedefaultObj = { Data: obj2 }; this.sharedService.settingsObjectSourceGetMultiple.next(DateTimedefaultObj); this.sharedService.settingsLayoutSourceGet.next({ TypeId: 10, DefaultFlag: false }); break; case 'YesNo': this.typeId = 11; const YesNodefaultObj = { Data: obj2 }; this.sharedService.settingsObjectSourceGetMultiple.next(YesNodefaultObj); this.sharedService.settingsLayoutSourceGet.next({ TypeId: 11, DefaultFlag: false }); break; case 'FileUpload': this.typeId = 12; const FileUploaddefaultObj = { Data: obj2 }; this.sharedService.settingsObjectSourceGetMultiple.next(FileUploaddefaultObj); this.sharedService.settingsLayoutSourceGet.next({ TypeId: 12, DefaultFlag: false }); break; default: break; } } deleteQuestionRow(index) { this.rowNumbers.splice(index, 1); } duplicateQuestionRow(row) { let rowObject; // tslint:disable-next-line:max-line-length // = this.rowNumbers.find(order => { order['Data']['RowNumber'] === row['Data']['RowNumber'] && order['Data']['ColNumber'] === row['Data']['ColNumber'] }); // tslint:disable-next-line: prefer-for-of for (let i = 0; i < this.rowNumbers.length; i++) { if (this.rowNumbers[i].Data.RowNumber === row.Data.RowNumber && this.rowNumbers[i].Data.ColNumber === row.Data.ColNumber) { rowObject = this.rowNumbers[i]; break; } } rowObject.Data.RowNumber = this.rowNumbers.length; this.rowNumbers.push(rowObject); } // Show Preview ShowPreview() { this.showPreviewFlag = !this.showPreviewFlag; } }