@glowgreen/gg-questionnaire-v2 0.0.70 → 0.0.72

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"glowgreen-gg-questionnaire-v2.js","sources":["ng://@glowgreen/gg-questionnaire-v2/lib/enums/question-type.enum.ts","ng://@glowgreen/gg-questionnaire-v2/lib/enums/condition-type.enum.ts","ng://@glowgreen/gg-questionnaire-v2/lib/enums/condition-relationship.enum.ts","ng://@glowgreen/gg-questionnaire-v2/lib/services/filter.service.ts","ng://@glowgreen/gg-questionnaire-v2/lib/enums/validation-type.enum.ts","ng://@glowgreen/gg-questionnaire-v2/lib/services/form-constructor.service.ts","ng://@glowgreen/gg-questionnaire-v2/lib/services/questionnaire.service.ts","ng://@glowgreen/gg-questionnaire-v2/lib/gg-questionnaire-v2.module.ts","ng://@glowgreen/gg-questionnaire-v2/lib/enums/input-type.enum.ts","ng://@glowgreen/gg-questionnaire-v2/lib/enums/repeater-question-type.enum.ts"],"sourcesContent":["export enum QuestionType {\n Input = 'input',\n Select = 'select',\n Textarea = 'textarea',\n Repeater = 'repeater',\n Checklist = 'checklist',\n Attachment = 'attachment',\n Upload = 'upload',\n Signature = 'signature',\n Slider = 'slider',\n Info = 'info',\n}\n","export enum ConditionType {\n EqualTo = 'equalTo',\n NotEqualTo = 'notEqualTo',\n LessThan = 'lessThan',\n GreaterThan = 'greaterThan',\n Includes = 'includes',\n Excludes = 'excludes'\n}\n","export enum ConditionRelationship {\n Every = 'every',\n Any = 'any',\n}\n","import { Injectable } from '@angular/core';\nimport { Section } from '../interfaces/section';\nimport { FormGroup, FormArray } from '@angular/forms';\nimport { Condition } from '../interfaces/condition';\nimport { ConditionGroup } from '../interfaces/condition-group';\nimport { ConditionType } from '../enums/condition-type.enum';\nimport { ConditionRelationship } from '../enums/condition-relationship.enum';\nimport * as _ from 'lodash';\nimport { Question } from '../interfaces/question';\nimport { RepeaterQuestion } from '../interfaces/repeater-question';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class FilterService {\n\n constructor() { }\n\n /**\n * Filters an array of sections based on their condition groups.\n * @param sections The array of sections to filter.\n * @param currentQuestionnaireForm The current form data, can be null/undefined.\n * @returns An array of filtered sections with their filtered questions.\n * @author Will Poulson\n */\n public filterSections(sections: Array<Section>, currentQuestionnaireForm: FormGroup | null, additionalData?: Object): Array<Section> {\n const filteredSections = [];\n for (const section of sections) {\n if (!this.meetsConditionGroups(section.conditionGroups, currentQuestionnaireForm, additionalData)) {\n continue;\n }\n\n const filteredQuestions = [];\n for (const question of section.questions) {\n if (!this.meetsConditionGroups(question.conditionGroups, currentQuestionnaireForm, additionalData)) {\n continue;\n }\n\n // If it's a repeater we need to do a lot of extra filtering due to per item conditions.\n if (question.type === 'repeater') {\n const items = currentQuestionnaireForm.get([section.name, question.name]) as FormArray;\n\n if (items && items.controls) {\n for (const repeaterItem of items.controls) {\n const filteredRepeaterItemQuestions: Array<RepeaterQuestion> = [];\n\n for (const repeaterQuestion of question.repeaterQuestions) {\n\n const meetsConditions = this.meetsConditionGroups(\n repeaterQuestion.conditionGroups,\n currentQuestionnaireForm,\n additionalData,\n repeaterItem as FormGroup\n );\n\n if (meetsConditions) {\n const cloneQuestion = _.clone(repeaterQuestion);\n\n cloneQuestion.selectOptions = this.getFetchOptionsForQuestion(\n repeaterQuestion,\n additionalData,\n currentQuestionnaireForm,\n repeaterItem as FormGroup\n );\n\n filteredRepeaterItemQuestions.push(cloneQuestion);\n }\n }\n\n const index = items.controls.indexOf(repeaterItem);\n\n if (!question.filteredRepeaterQuestions) {\n question.filteredRepeaterQuestions = [];\n }\n\n question.filteredRepeaterQuestions[index] = filteredRepeaterItemQuestions;\n }\n }\n\n }\n\n question.selectOptions = this.getFetchOptionsForQuestion(question, additionalData, currentQuestionnaireForm);\n\n filteredQuestions.push(question);\n }\n\n if (filteredQuestions.length === 0) {\n continue;\n }\n\n section.questions = filteredQuestions;\n filteredSections.push(section);\n }\n\n return filteredSections;\n }\n\n private getFetchOptionsForQuestion(\n question: Question | RepeaterQuestion,\n additionalData,\n currentQuestionnaireForm,\n repeaterItem?: FormGroup\n ) {\n\n if (!question.fetchPath) {\n return question.selectOptions;\n }\n\n let options = additionalData[question.fetchPath];\n if (question.fetchSelectors && question.fetchSelectors.length > 0) {\n const values = this.getValuesForArray(question.fetchSelectors, currentQuestionnaireForm, additionalData, repeaterItem);\n options = _.get(additionalData[question.fetchPath], values);\n }\n\n options = this.getFinalFetchArray(options);\n\n if (!question.selectOptions) {\n question.selectOptions = [];\n }\n\n return question.selectOptions.concat(options);\n }\n\n private getFinalFetchArray(items: any): Array<Object> {\n if (!items) {\n return null;\n }\n if (!Array.isArray(items)) {\n items = _.keys(items);\n }\n if (items.length <= 0) {\n return null;\n }\n const convertedArray: Array<Object> = [];\n for (const item of items) {\n if (item) {\n if (item instanceof Object && item.value && item.label) {\n convertedArray.push(item);\n } else {\n convertedArray.push({label: this.uppercase(item), value: item});\n }\n }\n }\n return convertedArray;\n }\n\n private uppercase(item: any) {\n return item.charAt(0).toUpperCase() + item.slice(1);\n }\n\n\n /**\n * Checks if each condition groups conditions have been met.\n * @param conditionGroups The array of condition groups.\n * @param currentQuestionnaireForm The current form data, can be null/undefined.\n * @returns A boolean stating if the condition groups conditions has been met.\n * @author Will Poulson\n */\n private meetsConditionGroups(\n conditionGroups: Array<ConditionGroup>,\n currentQuestionnaireForm: FormGroup | null,\n additionalData?: Object,\n repeaterItem?: FormGroup\n ): boolean {\n if (!conditionGroups || conditionGroups.length === 0) {\n return true;\n }\n return conditionGroups.every((x) => {\n return this.meetsConditionGroup(x, currentQuestionnaireForm, additionalData, repeaterItem) === true;\n });\n }\n\n /**\n * Checks if a condition groups conditions have been met.\n * @param conditionGroup The condition group to check.\n * @param currentQuestionnaireForm The current form data, can be null/undefined.\n * @returns A boolean stating if the condition group conditions has been met.\n * @author Will Poulson\n */\n private meetsConditionGroup(\n conditionGroup: ConditionGroup,\n currentQuestionnaireForm: FormGroup | null,\n additionalData?: Object,\n repeaterItem?: FormGroup\n ): boolean {\n if (!conditionGroup.conditions || conditionGroup.conditions.length === 0) {\n return true;\n }\n\n const results = [];\n\n for (const condition of conditionGroup.conditions) {\n results.push(this.meetsCondition(condition, currentQuestionnaireForm, additionalData, repeaterItem));\n }\n\n switch (conditionGroup.relationship) {\n case ConditionRelationship.Every:\n return results.every((x) => {\n return x === true;\n });\n case ConditionRelationship.Any:\n return !!results.find((x) => {\n return x === true;\n });\n default:\n return true;\n }\n }\n\n /**\n * Checks if a condition has been met.\n * @param condition The condition to check.\n * @param currentQuestionnaireForm The current form data, can be null/undefined.\n * @returns A boolean stating if the condition group conditions has been met.\n * @author Will Poulson\n */\n private meetsCondition(\n condition: Condition,\n currentQuestionnaireForm: FormGroup,\n additionalData?: Object,\n repeaterItem?: FormGroup\n ): boolean {\n const v1s: Array<any> = this.getValuesForArray(condition.v1s, currentQuestionnaireForm, additionalData, repeaterItem);\n const v2s: Array<any> = this.getValuesForArray(condition.v2s, currentQuestionnaireForm, additionalData, repeaterItem);\n\n let result = false;\n\n switch (condition.type) {\n case ConditionType.Excludes:\n result = v1s.filter((v1) => {\n return v2s.indexOf(v1) > -1;\n }).length === 0;\n break;\n case ConditionType.Includes:\n result = v1s.filter((v1) => {\n return v2s.indexOf(v1) > -1;\n }).length !== 0;\n break;\n default:\n for (let v2 of v2s) {\n for (let v1 of v1s) {\n switch (condition.type) {\n case ConditionType.EqualTo:\n v1 = this.getStringForValue(v1);\n v2 = this.getStringForValue(v2);\n if (v1 === v2) { result = true; }\n break;\n case ConditionType.NotEqualTo:\n v1 = this.getStringForValue(v1);\n v2 = this.getStringForValue(v2);\n if (v1 !== v2) { result = true; }\n break;\n case ConditionType.GreaterThan:\n v1 = parseFloat(v1);\n v2 = parseFloat(v2);\n if (v1 >= v2) { result = true; }\n break;\n case ConditionType.LessThan:\n v1 = parseFloat(v1);\n v2 = parseFloat(v2);\n if (v1 <= v2) { result = true; }\n break;\n }\n }\n }\n }\n\n return result;\n }\n\n private getStringForValue(value) {\n switch (value) {\n case null:\n return 'null';\n default:\n return value.toString();\n }\n }\n\n /**\n * Gets the current values for an array of strings.\n * @param paths The array of strings to check.\n * @param currentQuestionnaireForm The current form data, can be null/undefined.\n * @returns An array of strings/values\n * @author Will Poulson\n */\n private getValuesForArray(\n paths: Array<string>,\n currentQuestionnaireForm: FormGroup,\n additionalData?: Object,\n repeaterItem?: FormGroup\n ): Array<any> {\n if (currentQuestionnaireForm) {\n const values = [];\n for (const path of paths) {\n const value = this.getValueForString(path, currentQuestionnaireForm, additionalData, repeaterItem);\n values.push(value);\n }\n return values;\n } else {\n return paths;\n }\n }\n\n /**\n * Gets a current value for a string.\n * @param path The string value to check.\n * @param currentQuestionnaireForm The current form data, can be null/undefined.\n * @returns A string/value.\n * @author Will Poulson\n */\n private getValueForString(\n path: string,\n currentQuestionnaireForm: FormGroup,\n additionalData?: Object,\n repeaterItem?: FormGroup\n ) {\n if (currentQuestionnaireForm) {\n if (!additionalData) {\n additionalData = {};\n }\n\n let control = currentQuestionnaireForm.get(path.toString());\n\n if (!control && repeaterItem) {\n control = repeaterItem.get(path);\n }\n\n const value = control ? control.value : this.convertStringToValue(path);\n return _.get(additionalData, path, value);\n } else {\n return this.convertStringToValue(path);\n }\n }\n\n /**\n * Converts a string to a value.\n * Eg. true/false.\n * @param path The string value to check for conversion;\n * @returns Either a string or the converted value.\n * @author Will Poulson\n */\n private convertStringToValue(path: string) {\n switch (path) {\n case 'true':\n return true;\n case 'false':\n return false;\n case 'null':\n return null;\n default:\n return path;\n }\n }\n}\n","export enum ValidationType {\n Required = 'required',\n Boolean = 'boolean',\n Number = 'number',\n String = 'string',\n Email = 'email',\n Telephone = 'telephone',\n}\n","import { Injectable } from '@angular/core';\nimport { FormBuilder, FormGroup, FormControl, AbstractControl, ValidatorFn, Validators, FormArray } from '@angular/forms';\nimport { Section } from '../interfaces/section';\nimport { Question } from '../interfaces/question';\nimport { Questionnaire } from '../interfaces/questionnaire';\nimport { QuestionType } from '../enums/question-type.enum';\nimport { FilterService } from './filter.service';\nimport { Validator } from '../interfaces/validator';\nimport { ValidationType } from '../enums/validation-type.enum';\nimport * as _ from 'lodash';\nimport { RepeaterQuestion } from '../interfaces/repeater-question';\nimport { ChecklistItem } from '../interfaces/checklist-item';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class FormConstructorService {\n\n constructor(\n private fb: FormBuilder,\n private filterService: FilterService\n ) { }\n\n /**\n * Constructs a form group based on the questionnaire data.\n * This form group has been filtered down based on the conditions of the sections and questions.\n * @param questionnaire The questionnaire data to build the form group on.\n * @returns A filted form group.\n * @author Will Poulson\n */\n public generateFormsForQuestionnaire(\n questionnaire: Questionnaire,\n currentQuestionnaire: Questionnaire,\n currentQuestionnaireForm: FormGroup,\n additionalData?: Object,\n skipFilter?: boolean\n ): {sections: Array<Section>; forms: FormGroup} {\n const sections = skipFilter ?\n questionnaire.sections :\n this.filterService.filterSections(questionnaire.sections, currentQuestionnaireForm, additionalData);\n\n const noChange = currentQuestionnaireForm && (sections === currentQuestionnaire.sections);\n\n if (noChange && !skipFilter) {\n return null;\n }\n\n const questionnaireForms = this.generateFormsForSections(sections, currentQuestionnaireForm);\n return {sections: sections, forms: questionnaireForms};\n }\n\n private generateFormsForSections(sections: Array<Section>, currentQuestionnaireForm: FormGroup) {\n const questionnaireForms: FormGroup = this.fb.group({});\n for (const section of sections) {\n const sectionForms = this.generateFormsForSection(section, currentQuestionnaireForm);\n questionnaireForms.addControl(section.name, sectionForms);\n }\n return questionnaireForms;\n }\n\n /**\n * Constructs a form group based on the section data.\n * This form group has been filtered down based on the conditions of the questions.\n * @param section The section data to build the form group on.\n * @returns A filtered form group.\n * @author Will Poulson\n */\n private generateFormsForSection(section: Section, currentQuestionnaireForm: FormGroup): FormGroup {\n const sectionForms: FormGroup = this.fb.group({});\n for (const question of section.questions) {\n if (question.type === QuestionType.Info) {\n continue;\n }\n\n const questionControl = this.generateControlForQuestion(question, section, currentQuestionnaireForm);\n sectionForms.addControl(question.name, questionControl);\n }\n return sectionForms;\n }\n\n /**\n * Constructs an astract form control based on the question data.\n * @param question The question data to build the abstract control on.\n * @returns An abstract control.\n * @author Will Poulson\n */\n private generateControlForQuestion(question: Question, section: Section, currentQuestionnaireForm: FormGroup): AbstractControl {\n const convertedValidators = this.convertValidators(question.validators);\n const defaultValue = question.defaultValue ? question.defaultValue : null;\n switch (question.type) {\n case QuestionType.Repeater:\n const newArray = this.fb.array([], convertedValidators);\n const currentArray = currentQuestionnaireForm ? (currentQuestionnaireForm.get([section.name, question.name]) as FormArray) : false;\n\n if (currentArray) {\n console.log('Has current array');\n const controlsSnapshot = _.clone(currentArray.controls);\n for (const item of controlsSnapshot) {\n\n console.log('Got item', item);\n\n const index = currentArray.controls.indexOf(item);\n const group = this.generateFormsForRepeater(question, index);\n\n console.log('Filtered to', group);\n\n // Gross comparison below. Could be optimised however it's here to avoid inf loop.\n const currentItemStrinify = JSON.stringify(Object.keys(item.controls));\n const newItemStringify = JSON.stringify(Object.keys(group.controls));\n\n if (currentItemStrinify !== newItemStringify) {\n group.patchValue(item.value);\n currentArray.setControl(index, group);\n }\n }\n }\n\n return currentArray ? currentArray : newArray;\n case QuestionType.Checklist:\n return this.generateGroupForChecklist(question, convertedValidators);\n case QuestionType.Slider:\n return this.fb.control(defaultValue, { validators: convertedValidators }); // Remove update on blur for sliders.\n default:\n return this.fb.control(defaultValue, { validators: convertedValidators, updateOn: 'blur' });\n }\n }\n\n /**\n * Generates the form group for a checklist question.\n * @param question The question. Must be of type checklist or else null is returned.\n * @returns A form group.\n * @author Will Poulson\n */\n private generateGroupForChecklist(question: Question, convertedValidators) {\n if (question.type !== QuestionType.Checklist || question.checklistItems.length === 0) {\n return null;\n }\n\n const checklistForms: FormGroup = this.fb.group({});\n for (const checklistItem of question.checklistItems) {\n const checklistItemControl = this.fb.control(null, convertedValidators);\n checklistForms.addControl(checklistItem.name, checklistItemControl);\n }\n return checklistForms;\n }\n\n\n /**\n * Generates the form template for a repeater question.\n * @param question The question. Must be of type repeater or else null is returned.\n * @returns A form group.\n * @author Will Poulson\n */\n public generateFormsForRepeater(question: Question, index?: any): FormGroup {\n if (question.type !== QuestionType.Repeater || question.repeaterQuestions.length === 0) {\n console.log('Question isnt a repeater or has no questions, returning null');\n return null;\n }\n\n let repeaterQuestions = question.repeaterQuestions;\n\n if (question.filteredRepeaterQuestions && question.filteredRepeaterQuestions[index]) {\n repeaterQuestions = question.filteredRepeaterQuestions[index];\n }\n\n console.log('Index passed', index);\n console.log('All filtered questions', question.filteredRepeaterQuestions);\n console.log('Got the following repeater questions', repeaterQuestions.map(x => x.name));\n\n const repeaterForms: FormGroup = this.fb.group({});\n for (const repeaterQuestion of repeaterQuestions) {\n const repeaterQuestionControl = this.generateControlForRepeaterQuestion(repeaterQuestion);\n repeaterForms.addControl(repeaterQuestion.name, repeaterQuestionControl);\n }\n return repeaterForms;\n }\n\n /**\n * Generates a control for a repeaters question.\n * @param repeaterQuestion A repeater question.\n * @returns An abstract control.\n * @author Will Poulson\n */\n private generateControlForRepeaterQuestion(repeaterQuestion: RepeaterQuestion): AbstractControl {\n const convertedValidators = this.convertValidators(repeaterQuestion.validators);\n return this.fb.control(null, { validators: convertedValidators, updateOn: 'blur' });\n }\n\n /**\n * Converts an array of validators into form validators.\n * @param validators The uncoverted array of validators.\n * @returns A convered array of form validators.\n * @author Will Poulson\n */\n private convertValidators(validators: Array<Validator>): Array<ValidatorFn> {\n if (!validators || validators.length === 0) {\n return [];\n }\n const convertedValidators: Array<ValidatorFn> = [];\n for (const validator of validators) {\n const convertedValidator = this.convertValidator(validator);\n if (convertedValidator) {\n convertedValidators.push(convertedValidator);\n }\n }\n return convertedValidators;\n }\n\n /**\n * Converts a single validator into a form validator.\n * @param validator The unconverted validator.\n * @returns A converted form validator.\n * @author Will Poulson\n */\n private convertValidator(validator: Validator): ValidatorFn | null {\n switch (validator.type) {\n case ValidationType.Required:\n return Validators.required;\n default:\n return null;\n }\n }\n\n /**\n * Constructs the forms for repeaters from saved state.\n * @param savedState The saved state to load.\n * @param sections The sections already generated by the form constructor.\n */\n public constructRepeaterFromsFromState(savedState: any, sections: Array<Section>, currentQuestionnaireForm: FormGroup) {\n for (const section of sections) {\n for (const question of section.questions) {\n if (question.type !== QuestionType.Repeater) {\n continue;\n }\n\n const repeaterArray = savedState[section.name][question.name];\n if (!repeaterArray || repeaterArray.length === 0) {\n continue;\n }\n\n const repeaterFormArray = currentQuestionnaireForm.get([section.name, question.name]) as FormArray;\n\n if (repeaterFormArray.controls.length === repeaterArray.length) {\n continue;\n }\n\n // For each item that used to be there push a new empty template there to be populated.\n for (const repeaterItem of repeaterArray) {\n const index = repeaterArray.indexOf(repeaterItem);\n const repeaterItemTemplate = this.generateFormsForRepeater(question, index);\n repeaterFormArray.push(repeaterItemTemplate);\n }\n }\n }\n }\n}\n","import { Injectable, Inject, EventEmitter } from '@angular/core';\nimport { FormConstructorService } from './form-constructor.service';\nimport { Questionnaire } from '../interfaces/questionnaire';\nimport { FormGroup, AbstractControl, FormArray, FormBuilder } from '@angular/forms';\nimport { Section } from '../interfaces/section';\nimport { Question } from '../interfaces/question';\nimport { Subscription } from 'rxjs';\nimport * as _ from 'lodash';\nimport { QuestionnaireOptions } from '../interfaces/questionnaire-options';\nimport { QuestionType } from '../enums/question-type.enum';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class QuestionnaireService {\n public dataChangedEvent: EventEmitter<any> = new EventEmitter<any>();\n public sectionFinishedEvent: EventEmitter<any> = new EventEmitter<any>();\n\n private originalQuestionnaire: Questionnaire;\n\n private currentQuestionnaire: Questionnaire;\n private currentQuestionnaireForm: FormGroup;\n\n private currentSectionName: string;\n private currentQuestionName: string;\n\n private questionnaireValueChangeSubscription: Subscription;\n private questionValueChangeSubscription: Subscription;\n\n public additionalData: Object;\n\n private skippable = true;\n\n constructor(\n private formConstuctor: FormConstructorService,\n @Inject('options') private options: QuestionnaireOptions\n ) { }\n\n /**\n * Loads a questionnaire from data.\n * @param questionnaire The questionnaire data to load, often parsed JSON from the editor.\n * @param savedState The saved state of the questionnaire, often from localstorage.\n * @returns null\n * @author Will Poulson\n */\n public loadQuestionnaire(questionnaire: Questionnaire, savedState?: Object, additionalData?: Object) {\n this.originalQuestionnaire = _.cloneDeep(questionnaire);\n this.currentQuestionnaire = _.cloneDeep(questionnaire);\n\n this.additionalData = additionalData;\n\n if (savedState && Object.keys(savedState).length > 0) {\n const newData = this.formConstuctor.generateFormsForQuestionnaire(\n _.cloneDeep(this.originalQuestionnaire),\n _.cloneDeep(this.currentQuestionnaire),\n this.currentQuestionnaireForm,\n this.additionalData,\n true\n );\n\n if (newData) {\n this.formConstuctor.constructRepeaterFromsFromState(savedState, newData.sections, newData.forms);\n this.currentQuestionnaireForm = newData.forms;\n this.currentQuestionnaireForm.patchValue(savedState);\n }\n\n }\n\n this.updateQuestionnaire(savedState);\n\n\n\n if (this.options.skipToFirstSection) {\n this.currentSectionName = Object.keys(this.currentQuestionnaireForm.controls)[0];\n }\n\n if (this.options.skipToFirstQuestion) {\n this.currentQuestionName = Object.keys(this.currentSection.formGroup.controls)[0];\n }\n\n }\n\n /**\n * Updates the current questionnaire, used when a value is updated to check conditions.\n * @param savedState The saved state of the questionnaire, often from localstorage.\n * @returns null\n * @author Will Poulson\n */\n public updateQuestionnaire(savedState?: Object) {\n const oldLength = this.currentQuestionnaire.sections.map(x => x.questions.length).reduce((a, b) => a + b, 0);\n\n const newData = this.formConstuctor.generateFormsForQuestionnaire(\n _.cloneDeep(this.originalQuestionnaire),\n _.cloneDeep(this.currentQuestionnaire),\n this.currentQuestionnaireForm,\n this.additionalData\n );\n\n if (newData) {\n this.currentQuestionnaireForm = newData.forms;\n this.currentQuestionnaire.sections = newData.sections;\n }\n\n if (savedState && Object.keys(savedState).length > 0) {\n this.currentQuestionnaireForm.patchValue(savedState);\n }\n\n if (this.questionnaireValueChangeSubscription) {\n this.questionnaireValueChangeSubscription.unsubscribe();\n }\n\n if (this.questionValueChangeSubscription) {\n this.questionValueChangeSubscription.unsubscribe();\n }\n\n this.questionnaireValueChangeSubscription = this.currentQuestionnaireForm.valueChanges.subscribe(() => {\n this.dataChangedEvent.emit();\n this.updateQuestionnaire(this.currentQuestionnaireForm.getRawValue());\n });\n\n if (this.currentQuestion && this.currentQuestion.formControl) {\n this.questionValueChangeSubscription = this.currentQuestion.formControl.valueChanges.subscribe(() => {\n this.clearFields(this.currentQuestion.data.clearfields);\n });\n }\n\n const newLength = this.currentQuestionnaire.sections.map(x => x.questions.length).reduce((a, b) => a + b, 0);\n\n if (oldLength !== newLength) {\n for (const section of this.currentQuestionnaire.sections) {\n for (const question of section.questions) {\n const control = this.currentQuestionnaireForm.get([section.name, question.name]);\n if (control && control.value === null && question.defaultValue) {\n control.setValue(question.defaultValue);\n }\n }\n }\n }\n }\n\n public updateAdditionalData(payload: any) {\n this.additionalData = Object.assign(this.additionalData, payload);\n this.updateQuestionnaire(this.currentQuestionnaireForm.getRawValue());\n }\n\n public clearAdditionalData() {\n this.additionalData = {};\n this.updateQuestionnaire(this.currentQuestionnaireForm.getRawValue());\n }\n\n public get isValid() {\n return this.currentQuestionnaireForm.valid;\n }\n\n public get isFirstQuestion(): boolean {\n if (!this.currentSection || !this.currentQuestion) {\n return false;\n }\n const currentIndex = this.currentSection.data.questions.indexOf(this.currentQuestion.data);\n return currentIndex === 0;\n }\n\n public get isLastQuestion(): boolean {\n if (!this.currentSection || !this.currentQuestion) {\n return false;\n }\n const currentIndex = this.currentSection.data.questions.indexOf(this.currentQuestion.data);\n const maxIndex = this.currentSection.data.questions.length - 1;\n return currentIndex === maxIndex;\n }\n\n public get isFirstSection(): boolean {\n if (!this.currentSection) {\n return false;\n }\n\n const currentIndex = this.currentQuestionnaire.sections.indexOf(this.currentSection.data);\n return currentIndex === 0;\n }\n\n public get isLastSection(): boolean {\n if (!this.currentSection) {\n return false;\n }\n\n const currentIndex = this.currentQuestionnaire.sections.indexOf(this.currentSection.data);\n const maxIndex = this.currentQuestionnaire.sections.length - 1;\n return currentIndex === maxIndex;\n }\n\n public sectionValid(name: string) {\n return this.currentQuestionnaireForm.get(name).valid;\n }\n\n /**\n * Clears all the fields parsed\n * @param clearfields An array of strings, paths to clear.\n * @author Will Poulson\n */\n private clearFields(clearfields: Array<string>) {\n if (!clearfields || clearfields.length === 0) {\n return;\n }\n\n for (const clearfield of clearfields) {\n const control = this.currentQuestionnaireForm.get(clearfield);\n\n if (control) {\n control.reset(undefined);\n }\n }\n }\n\n /**\n * Unloads the current questionnaire.\n * Useful when exiting a questionnaire page or completing a questionnaire.\n * @author Will Poulson\n */\n public unloadQuestionnaire() {\n this.originalQuestionnaire = undefined;\n this.currentQuestionnaireForm = undefined;\n this.currentQuestionnaire = undefined;\n this.currentSectionName = undefined;\n this.currentQuestionName = undefined;\n this.additionalData = undefined;\n }\n\n /**\n * Gets the current selected section.\n * @returns An object containing the section data and the related form group.\n * @author Will Poulson\n */\n public get currentSection(): { data: Section; formGroup: FormGroup; } | null {\n if (!this.currentSectionName) {\n return null;\n }\n\n const data = this.currentQuestionnaire.sections.find((x) => {\n return x.name === this.currentSectionName;\n });\n\n if (!data) {\n return null;\n }\n\n return {\n data: data,\n formGroup: this.currentQuestionnaireForm.get(data.name) as FormGroup\n };\n }\n\n /**\n * Gets all the avaialble sections.\n * @returns An array of all avaialble sections.\n * @author Will Poulson\n */\n public get availableSections(): Array<Section> {\n if (!this.currentQuestionnaire || !this.currentQuestionnaire.sections) {\n return [];\n }\n return this.currentQuestionnaire.sections;\n }\n\n /**\n * Gets the current data for the entire questionnaire.\n * @returns An object of data.\n * @author Will Poulson\n */\n public get currentData() {\n return this.currentQuestionnaireForm ? this.currentQuestionnaireForm.getRawValue() : {};\n }\n\n\n /**\n * Gets the current selected question.\n * @returns An object containing the question data and the related form control.\n * @author Will Poulson\n */\n public get currentQuestion(): { data: Question; formControl: AbstractControl | null; } | null {\n if (!this.currentQuestionName) {\n return null;\n }\n\n const data = this.currentSection.data.questions.find((x) => {\n return x.name === this.currentQuestionName;\n });\n\n if (!data) {\n return null;\n }\n\n const formControl = this.currentSection.formGroup.get(data.name) as AbstractControl;\n\n return {\n data: data,\n formControl: formControl\n };\n }\n\n /**\n * Navigates to the next question.\n * If there is no question to navigate to it will reject with a out of bounds exception.\n * If allowSkipRequiredField is false then it will reject if the current question is invalid.\n * If emitSectionFinishEvent is true then it will emit an event if it's navigating past the length of questions.\n * @returns A promise which will resolve when the question has been navigated to.\n * @author Will Poulson\n */\n public nextQuestion() {\n return new Promise((resolve, reject) => {\n if (!this.options.allowSkipRequiredField) {\n if (this.currentQuestion.formControl && !this.currentQuestion.formControl.valid) {\n return reject('Current question is invalid');\n }\n }\n\n this.getCurrentQuestionIndex().then((currentIndex) => {\n const lastQuestionIndex = this.currentSection.data.questions.length - 1;\n const isLastQuestion = lastQuestionIndex === currentIndex;\n\n if (isLastQuestion) {\n this.sectionFinishedEvent.emit();\n return resolve();\n }\n\n const newIndex = currentIndex + 1;\n\n this.navigateToQuestion(newIndex).then(() => {\n return resolve();\n }).catch((error) => {\n return reject(error);\n });\n }).catch((error) => {\n return reject(error);\n });\n });\n }\n\n /**\n * Navigates to the previous question.\n * If there is no question to navigate to it will reject with a out of bounds exception.\n * If allowNavigateBackwards is false then it will reject.\n * @returns A promise which will resolve when the question has been navigated to.\n * @author Will Poulson\n */\n public prevQuestion() {\n return new Promise((resolve, reject) => {\n if (!this.options.allowNavigateBackwards) {\n return reject('This questionnaire does not allow for backwards navigation');\n }\n\n this.getCurrentQuestionIndex().then((currentIndex) => {\n const newIndex = currentIndex - 1;\n\n this.navigateToQuestion(newIndex).then(() => {\n return resolve();\n }).catch((error) => {\n return reject(error);\n });\n }).catch((error) => {\n return reject(error);\n });\n });\n }\n\n /**\n * Gets the current questions index.\n * @returns A promise which resolves a number.\n * @author Will Poulson\n */\n private getCurrentQuestionIndex(): Promise<number> {\n return new Promise((resolve, reject) => {\n const currentIndex = this.currentSection.data.questions.indexOf(this.currentQuestion.data);\n\n if (currentIndex === -1) {\n return reject('Could not find current question');\n }\n\n return resolve(currentIndex);\n });\n }\n\n /**\n * Checks a question is in bounds then navigates to it.\n * @param index The index to navigate to.\n * @returns A promise which will resolve when the question has been navigated to.\n * @author Will Poulson\n */\n public navigateToQuestion(index: number) {\n return new Promise((resolve, reject) => {\n if (this.currentSection.data.questions.length - 1 < index || index < 0) {\n return reject('Out of bounds exception');\n }\n\n this.currentQuestionName = this.currentSection.data.questions[index].name;\n return resolve();\n });\n }\n\n /**\n * Navigates to the next section.\n * @returns A promise which will resolve when the section has been navigated to.\n * @author Will Poulson\n */\n public nextSection() {\n return new Promise((resolve, reject) => {\n this.getCurrentSectionIndex().then((currentIndex) => {\n const newIndex = currentIndex + 1;\n this.navigateToSection(newIndex).then(() => {\n return resolve();\n }).catch((error) => {\n return reject(error);\n });\n }).catch((error) => {\n return reject(error);\n });\n });\n }\n\n /**\n * Navigates to the previous section.\n * @returns A promise which will resolve when the section has been navigated to.\n * @author Will Poulson\n */\n public prevSection() {\n return new Promise((resolve, reject) => {\n this.getCurrentSectionIndex().then((currentIndex) => {\n const newIndex = currentIndex - 1;\n this.navigateToSection(newIndex).then(() => {\n return resolve();\n }).catch((error) => {\n return reject(error);\n });\n }).catch((error) => {\n return reject(error);\n });\n });\n }\n\n /**\n * Gets the current section index.\n * @returns A promise which resolves a number.\n * @author Will Poulson\n */\n private getCurrentSectionIndex(): Promise<number> {\n return new Promise((resolve, reject) => {\n const currentIndex = this.currentQuestionnaire.sections.indexOf(this.currentSection.data);\n\n if (currentIndex === -1) {\n return reject('Could not find current section');\n }\n\n return resolve(currentIndex);\n });\n }\n\n /**\n * Checks a section is in bounds then navigates to it.\n * @param index The index to navigate to.\n * @returns A promise which will resolve when the section has been navigated to.\n * @author Will Poulson\n */\n public navigateToSection(index: number) {\n return new Promise((resolve, reject) => {\n if (this.currentQuestionnaire.sections.length - 1 < index || index < 0) {\n return reject('Out of bounds exception');\n }\n\n this.currentSectionName = this.currentQuestionnaire.sections[index].name;\n return resolve();\n });\n }\n\n /**\n * Answers the current question with the parsed value.\n * @param answer The value to answer the question with.\n * @author Will Poulson\n */\n public answerCurrentQuestion(answer: any, sendToNextQuestion?: boolean) {\n if (!sendToNextQuestion) {\n this.currentQuestion.formControl.setValue(answer);\n return;\n }\n\n if (this.skippable) { // Timeout to prevent skipping glitch.\n this.skippable = false;\n setTimeout(() => {\n this.currentQuestion.formControl.setValue(answer);\n this.nextQuestion().then(() => {\n this.skippable = true;\n });\n }, 150);\n }\n }\n\n /**\n * Adds a repeater item to the current question.\n * Current question must be of type Repeater.\n * @returns A promise which resolves when the repeater item has been added.\n * @author Will Poulson\n */\n public addRepeaterItem() {\n return new Promise((resolve, reject) => {\n if (this.currentQuestion.data.type !== QuestionType.Repeater) {\n return reject(`Current question isn't a repeater`);\n }\n \n const repeaterForm = this.formConstuctor.generateFormsForRepeater(this.currentQuestion.data);\n\n if (!repeaterForm) {\n return reject(`Repeater template failed to generate. May be due to the repeater having no items in the editor.`);\n }\n\n\n if (!(this.currentQuestion.formControl instanceof FormArray)) {\n return reject(`The current questions control isn't of type FormArray`);\n }\n\n this.currentQuestion.formControl.push(repeaterForm);\n return resolve();\n });\n }\n\n /**\n * Removes a repeater item on the current question.\n * Current question must be of type Repeater.\n * @param index The index at which to remove.\n * @returns A promise which resolves when the repeater item has been removed.\n * @author Will Poulson\n */\n public removeRepeaterItem(index: number) {\n return new Promise((resolve, reject) => {\n if (this.currentQuestion.data.type !== QuestionType.Repeater) {\n return reject(`Current question isn't a repeater`);\n }\n\n if (!(this.currentQuestion.formControl instanceof FormArray)) {\n return reject(`The current questions control isn't of type FormArray`);\n }\n\n this.currentQuestion.formControl.removeAt(index);\n return resolve();\n });\n }\n\n /**\n * Returns the display text for a given repeater item\n * @param index The index at which to get the label for.\n * @returns A string which is the display text.\n * @author Will Poulson\n */\n public getRepeaterItemLabel(index: number): string {\n if (!this.currentQuestion.formControl || !(this.currentQuestion.formControl instanceof FormArray)) {\n return '';\n }\n\n const repeaterItem = this.currentQuestion.formControl.controls[index];\n\n if (!repeaterItem) {\n return '';\n }\n\n const template = this.currentQuestion.data.repeaterDisplayName;\n const splitTemplate = template.split(' ');\n\n const displayArray = [];\n for (const templateItem of splitTemplate) {\n if (templateItem.match(/\\[.*?\\]/)) {\n const path = templateItem.replace(/[\\[\\]']+/g, '');\n const item = repeaterItem.get(path);\n const value = (item && item.value ? item.value : '?');\n displayArray.push(value);\n } else {\n displayArray.push(templateItem);\n }\n }\n\n const display = displayArray.join(' ');\n return display;\n }\n}\n","import { NgModule } from '@angular/core';\nimport { FormConstructorService } from './services/form-constructor.service';\nimport { QuestionnaireService } from './services/questionnaire.service';\nimport { FilterService } from './services/filter.service';\nimport { FormsModule, ReactiveFormsModule } from '@angular/forms';\nimport { QuestionnaireOptions } from './interfaces/questionnaire-options';\nimport { ModuleWithProviders } from '@angular/compiler/src/core';\n\n@NgModule({\n declarations: [],\n providers: [\n FormConstructorService,\n FilterService\n ],\n imports: [\n FormsModule,\n ReactiveFormsModule\n ],\n})\nexport class GgQuestionnaireV2Module {\n public static forRoot(options: QuestionnaireOptions): ModuleWithProviders {\n return {\n ngModule: GgQuestionnaireV2Module,\n providers: [\n QuestionnaireService,\n {\n provide: 'options',\n useValue: options\n }\n ]\n };\n }\n}\n","export enum InputType {\n Text = 'text',\n Number = 'number',\n Email = 'email',\n Telephone = 'tel',\n Password = 'password',\n Color = 'color',\n Date = 'date',\n DateTimeLocal = 'datetime-local',\n Time = 'time',\n Month = 'month',\n Week = 'week',\n}\n","export enum RepeaterQuestionType {\n Input = 'input',\n Select = 'select',\n Upload = 'upload',\n}\n"],"names":["_.clone","_.get","_.keys","_.cloneDeep"],"mappings":";;;;;;;;;;IACI,OAAQ,OAAO;IACf,QAAS,QAAQ;IACjB,UAAW,UAAU;IACrB,UAAW,UAAU;IACrB,WAAY,WAAW;IACvB,YAAa,YAAY;IACzB,QAAS,QAAQ;IACjB,WAAY,W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BACpB;aACJ;SACJ,CAAC;KACH;;;YAvBF,QAAQ,SAAC;gBACR,YAAY,EAAE,EAAE;gBAChB,SAAS,EAAE;oBACT,sBAAsB;oBACtB,aAAa;iBACd;gBACD,OAAO,EAAE;oBACP,WAAW;oBACX,mBAAmB;iBACpB;aACF;;;;;;;;;ICjBG,MAAO,MAAM;IACb,QAAS,QAAQ;IACjB,OAAQ,OAAO;IACf,WAAY,KAAK;IACjB,UAAW,UAAU;IACrB,OAAQ,OAAO;IACf,MAAO,MAAM;IACb,eAAgB,gBAAgB;IAChC,MAAO,MAAM;IACb,OAAQ,OAAO;IACf,MAAO,MAAM;;;;;;;;;ICVb,OAAQ,OAAO;IACf,QAAS,QAAQ;IACjB,QAAS,QAAQ;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"glowgreen-gg-questionnaire-v2.js","sources":["ng://@glowgreen/gg-questionnaire-v2/lib/enums/question-type.enum.ts","ng://@glowgreen/gg-questionnaire-v2/lib/enums/condition-type.enum.ts","ng://@glowgreen/gg-questionnaire-v2/lib/enums/condition-relationship.enum.ts","ng://@glowgreen/gg-questionnaire-v2/lib/services/filter.service.ts","ng://@glowgreen/gg-questionnaire-v2/lib/enums/validation-type.enum.ts","ng://@glowgreen/gg-questionnaire-v2/lib/services/form-constructor.service.ts","ng://@glowgreen/gg-questionnaire-v2/lib/services/questionnaire.service.ts","ng://@glowgreen/gg-questionnaire-v2/lib/gg-questionnaire-v2.module.ts","ng://@glowgreen/gg-questionnaire-v2/lib/enums/input-type.enum.ts","ng://@glowgreen/gg-questionnaire-v2/lib/enums/repeater-question-type.enum.ts"],"sourcesContent":["export enum QuestionType {\n Input = 'input',\n Select = 'select',\n Textarea = 'textarea',\n Repeater = 'repeater',\n Checklist = 'checklist',\n Attachment = 'attachment',\n Upload = 'upload',\n Signature = 'signature',\n Slider = 'slider',\n Info = 'info',\n}\n","export enum ConditionType {\n EqualTo = 'equalTo',\n NotEqualTo = 'notEqualTo',\n LessThan = 'lessThan',\n GreaterThan = 'greaterThan',\n Includes = 'includes',\n Excludes = 'excludes'\n}\n","export enum ConditionRelationship {\n Every = 'every',\n Any = 'any',\n}\n","import { Injectable } from '@angular/core';\nimport { Section } from '../interfaces/section';\nimport { FormGroup, FormArray } from '@angular/forms';\nimport { Condition } from '../interfaces/condition';\nimport { ConditionGroup } from '../interfaces/condition-group';\nimport { ConditionType } from '../enums/condition-type.enum';\nimport { ConditionRelationship } from '../enums/condition-relationship.enum';\nimport * as _ from 'lodash';\nimport { Question } from '../interfaces/question';\nimport { RepeaterQuestion } from '../interfaces/repeater-question';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class FilterService {\n\n constructor() { }\n\n /**\n * Filters an array of sections based on their condition groups.\n * @param sections The array of sections to filter.\n * @param currentQuestionnaireForm The current form data, can be null/undefined.\n * @returns An array of filtered sections with their filtered questions.\n * @author Will Poulson\n */\n public filterSections(sections: Array<Section>, currentQuestionnaireForm: FormGroup | null, additionalData?: Object): Array<Section> {\n const filteredSections = [];\n for (const section of sections) {\n if (!this.meetsConditionGroups(section.conditionGroups, currentQuestionnaireForm, additionalData)) {\n continue;\n }\n\n const filteredQuestions = [];\n for (const question of section.questions) {\n if (!this.meetsConditionGroups(question.conditionGroups, currentQuestionnaireForm, additionalData)) {\n continue;\n }\n\n // If it's a repeater we need to do a lot of extra filtering due to per item conditions.\n if (question.type === 'repeater') {\n const items = currentQuestionnaireForm.get([section.name, question.name]) as FormArray;\n\n if (items && items.controls) {\n for (const repeaterItem of items.controls) {\n const filteredRepeaterItemQuestions: Array<RepeaterQuestion> = [];\n\n for (const repeaterQuestion of question.repeaterQuestions) {\n\n const meetsConditions = this.meetsConditionGroups(\n repeaterQuestion.conditionGroups,\n currentQuestionnaireForm,\n additionalData,\n repeaterItem as FormGroup\n );\n\n if (meetsConditions) {\n const cloneQuestion = _.clone(repeaterQuestion);\n\n cloneQuestion.selectOptions = this.getFetchOptionsForQuestion(\n repeaterQuestion,\n additionalData,\n currentQuestionnaireForm,\n repeaterItem as FormGroup\n );\n\n filteredRepeaterItemQuestions.push(cloneQuestion);\n }\n }\n\n const index = items.controls.indexOf(repeaterItem);\n\n if (!question.filteredRepeaterQuestions) {\n question.filteredRepeaterQuestions = [];\n }\n\n question.filteredRepeaterQuestions[index] = filteredRepeaterItemQuestions;\n }\n }\n\n }\n\n question.selectOptions = this.getFetchOptionsForQuestion(question, additionalData, currentQuestionnaireForm);\n\n filteredQuestions.push(question);\n }\n\n if (filteredQuestions.length === 0) {\n continue;\n }\n\n section.questions = filteredQuestions;\n filteredSections.push(section);\n }\n\n return filteredSections;\n }\n\n private getFetchOptionsForQuestion(\n question: Question | RepeaterQuestion,\n additionalData,\n currentQuestionnaireForm,\n repeaterItem?: FormGroup\n ) {\n\n if (!question.fetchPath) {\n return question.selectOptions;\n }\n\n let options = additionalData[question.fetchPath];\n if (question.fetchSelectors && question.fetchSelectors.length > 0) {\n const values = this.getValuesForArray(question.fetchSelectors, currentQuestionnaireForm, additionalData, repeaterItem);\n options = _.get(additionalData[question.fetchPath], values);\n }\n\n options = this.getFinalFetchArray(options);\n\n if (!question.selectOptions) {\n question.selectOptions = [];\n }\n\n return question.selectOptions.concat(options);\n }\n\n private getFinalFetchArray(items: any): Array<Object> {\n if (!items) {\n return null;\n }\n if (!Array.isArray(items)) {\n items = _.keys(items);\n }\n if (items.length <= 0) {\n return null;\n }\n const convertedArray: Array<Object> = [];\n for (const item of items) {\n if (item) {\n if (item instanceof Object && item.value && item.label) {\n convertedArray.push(item);\n } else {\n convertedArray.push({label: this.uppercase(item), value: item});\n }\n }\n }\n return convertedArray;\n }\n\n private uppercase(item: any) {\n return item.charAt(0).toUpperCase() + item.slice(1);\n }\n\n\n /**\n * Checks if each condition groups conditions have been met.\n * @param conditionGroups The array of condition groups.\n * @param currentQuestionnaireForm The current form data, can be null/undefined.\n * @returns A boolean stating if the condition groups conditions has been met.\n * @author Will Poulson\n */\n private meetsConditionGroups(\n conditionGroups: Array<ConditionGroup>,\n currentQuestionnaireForm: FormGroup | null,\n additionalData?: Object,\n repeaterItem?: FormGroup\n ): boolean {\n if (!conditionGroups || conditionGroups.length === 0) {\n return true;\n }\n return conditionGroups.every((x) => {\n return this.meetsConditionGroup(x, currentQuestionnaireForm, additionalData, repeaterItem) === true;\n });\n }\n\n /**\n * Checks if a condition groups conditions have been met.\n * @param conditionGroup The condition group to check.\n * @param currentQuestionnaireForm The current form data, can be null/undefined.\n * @returns A boolean stating if the condition group conditions has been met.\n * @author Will Poulson\n */\n private meetsConditionGroup(\n conditionGroup: ConditionGroup,\n currentQuestionnaireForm: FormGroup | null,\n additionalData?: Object,\n repeaterItem?: FormGroup\n ): boolean {\n if (!conditionGroup.conditions || conditionGroup.conditions.length === 0) {\n return true;\n }\n\n const results = [];\n\n for (const condition of conditionGroup.conditions) {\n results.push(this.meetsCondition(condition, currentQuestionnaireForm, additionalData, repeaterItem));\n }\n\n switch (conditionGroup.relationship) {\n case ConditionRelationship.Every:\n return results.every((x) => {\n return x === true;\n });\n case ConditionRelationship.Any:\n return !!results.find((x) => {\n return x === true;\n });\n default:\n return true;\n }\n }\n\n /**\n * Checks if a condition has been met.\n * @param condition The condition to check.\n * @param currentQuestionnaireForm The current form data, can be null/undefined.\n * @returns A boolean stating if the condition group conditions has been met.\n * @author Will Poulson\n */\n private meetsCondition(\n condition: Condition,\n currentQuestionnaireForm: FormGroup,\n additionalData?: Object,\n repeaterItem?: FormGroup\n ): boolean {\n const v1s: Array<any> = this.getValuesForArray(condition.v1s, currentQuestionnaireForm, additionalData, repeaterItem);\n const v2s: Array<any> = this.getValuesForArray(condition.v2s, currentQuestionnaireForm, additionalData, repeaterItem);\n\n let result = false;\n\n switch (condition.type) {\n case ConditionType.Excludes:\n result = v1s.filter((v1) => {\n return v2s.indexOf(v1) > -1;\n }).length === 0;\n break;\n case ConditionType.Includes:\n result = v1s.filter((v1) => {\n return v2s.indexOf(v1) > -1;\n }).length !== 0;\n break;\n default:\n for (let v2 of v2s) {\n for (let v1 of v1s) {\n switch (condition.type) {\n case ConditionType.EqualTo:\n v1 = this.getStringForValue(v1);\n v2 = this.getStringForValue(v2);\n if (v1 === v2) { result = true; }\n break;\n case ConditionType.NotEqualTo:\n v1 = this.getStringForValue(v1);\n v2 = this.getStringForValue(v2);\n if (v1 !== v2) { result = true; }\n break;\n case ConditionType.GreaterThan:\n v1 = parseFloat(v1);\n v2 = parseFloat(v2);\n if (v1 >= v2) { result = true; }\n break;\n case ConditionType.LessThan:\n v1 = parseFloat(v1);\n v2 = parseFloat(v2);\n if (v1 <= v2) { result = true; }\n break;\n }\n }\n }\n }\n\n return result;\n }\n\n private getStringForValue(value) {\n switch (value) {\n case null:\n return 'null';\n default:\n return value.toString();\n }\n }\n\n /**\n * Gets the current values for an array of strings.\n * @param paths The array of strings to check.\n * @param currentQuestionnaireForm The current form data, can be null/undefined.\n * @returns An array of strings/values\n * @author Will Poulson\n */\n private getValuesForArray(\n paths: Array<string>,\n currentQuestionnaireForm: FormGroup,\n additionalData?: Object,\n repeaterItem?: FormGroup\n ): Array<any> {\n if (currentQuestionnaireForm) {\n const values = [];\n for (const path of paths) {\n const value = this.getValueForString(path, currentQuestionnaireForm, additionalData, repeaterItem);\n values.push(value);\n }\n return values;\n } else {\n return paths;\n }\n }\n\n /**\n * Gets a current value for a string.\n * @param path The string value to check.\n * @param currentQuestionnaireForm The current form data, can be null/undefined.\n * @returns A string/value.\n * @author Will Poulson\n */\n private getValueForString(\n path: string,\n currentQuestionnaireForm: FormGroup,\n additionalData?: Object,\n repeaterItem?: FormGroup\n ) {\n if (currentQuestionnaireForm) {\n if (!additionalData) {\n additionalData = {};\n }\n\n let control = currentQuestionnaireForm.get(path.toString());\n\n if (!control && repeaterItem) {\n control = repeaterItem.get(path);\n }\n\n const value = control ? control.value : this.convertStringToValue(path);\n return _.get(additionalData, path, value);\n } else {\n return this.convertStringToValue(path);\n }\n }\n\n /**\n * Converts a string to a value.\n * Eg. true/false.\n * @param path The string value to check for conversion;\n * @returns Either a string or the converted value.\n * @author Will Poulson\n */\n private convertStringToValue(path: string) {\n switch (path) {\n case 'true':\n return true;\n case 'false':\n return false;\n case 'null':\n return null;\n default:\n return path;\n }\n }\n}\n","export enum ValidationType {\n Required = 'required',\n Boolean = 'boolean',\n Number = 'number',\n String = 'string',\n Email = 'email',\n Telephone = 'telephone',\n}\n","import { Injectable } from '@angular/core';\nimport { FormBuilder, FormGroup, FormControl, AbstractControl, ValidatorFn, Validators, FormArray } from '@angular/forms';\nimport { Section } from '../interfaces/section';\nimport { Question } from '../interfaces/question';\nimport { Questionnaire } from '../interfaces/questionnaire';\nimport { QuestionType } from '../enums/question-type.enum';\nimport { FilterService } from './filter.service';\nimport { Validator } from '../interfaces/validator';\nimport { ValidationType } from '../enums/validation-type.enum';\nimport * as _ from 'lodash';\nimport { RepeaterQuestion } from '../interfaces/repeater-question';\nimport { ChecklistItem } from '../interfaces/checklist-item';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class FormConstructorService {\n\n constructor(\n private fb: FormBuilder,\n private filterService: FilterService\n ) { }\n\n /**\n * Constructs a form group based on the questionnaire data.\n * This form group has been filtered down based on the conditions of the sections and questions.\n * @param questionnaire The questionnaire data to build the form group on.\n * @returns A filted form group.\n * @author Will Poulson\n */\n public generateFormsForQuestionnaire(\n questionnaire: Questionnaire,\n currentQuestionnaire: Questionnaire,\n currentQuestionnaireForm: FormGroup,\n additionalData?: Object,\n skipFilter?: boolean\n ): {sections: Array<Section>; forms: FormGroup} {\n const sections = skipFilter ?\n questionnaire.sections :\n this.filterService.filterSections(questionnaire.sections, currentQuestionnaireForm, additionalData);\n\n const noChange = currentQuestionnaireForm && (sections === currentQuestionnaire.sections);\n\n if (noChange && !skipFilter) {\n return null;\n }\n\n const questionnaireForms = this.generateFormsForSections(sections, currentQuestionnaireForm);\n return {sections: sections, forms: questionnaireForms};\n }\n\n private generateFormsForSections(sections: Array<Section>, currentQuestionnaireForm: FormGroup) {\n const questionnaireForms: FormGroup = this.fb.group({});\n for (const section of sections) {\n const sectionForms = this.generateFormsForSection(section, currentQuestionnaireForm);\n questionnaireForms.addControl(section.name, sectionForms);\n }\n return questionnaireForms;\n }\n\n /**\n * Constructs a form group based on the section data.\n * This form group has been filtered down based on the conditions of the questions.\n * @param section The section data to build the form group on.\n * @returns A filtered form group.\n * @author Will Poulson\n */\n private generateFormsForSection(section: Section, currentQuestionnaireForm: FormGroup): FormGroup {\n const sectionForms: FormGroup = this.fb.group({});\n for (const question of section.questions) {\n if (question.type === QuestionType.Info) {\n continue;\n }\n\n const questionControl = this.generateControlForQuestion(question, section, currentQuestionnaireForm);\n sectionForms.addControl(question.name, questionControl);\n }\n return sectionForms;\n }\n\n /**\n * Constructs an astract form control based on the question data.\n * @param question The question data to build the abstract control on.\n * @returns An abstract control.\n * @author Will Poulson\n */\n private generateControlForQuestion(question: Question, section: Section, currentQuestionnaireForm: FormGroup): AbstractControl {\n const convertedValidators = this.convertValidators(question.validators);\n const defaultValue = question.defaultValue ? question.defaultValue : null;\n switch (question.type) {\n case QuestionType.Repeater:\n const newArray = this.fb.array([], convertedValidators);\n const currentArray = currentQuestionnaireForm ? (currentQuestionnaireForm.get([section.name, question.name]) as FormArray) : false;\n\n if (currentArray && question.filteredRepeaterQuestions) {\n for (const control of currentArray.controls) {\n\n const index = currentArray.controls.indexOf(control);\n \n if (!index) {\n continue;\n }\n\n const filteredQuestions = question.filteredRepeaterQuestions[index];\n\n if (!filteredQuestions) {\n continue;\n }\n\n const filteredQuestionNames = filteredQuestions.map(x => x.name);\n const filteredOutQuestions = question.repeaterQuestions.filter(x => !filteredQuestionNames.includes(x.name))\n\n console.log('Triggering filtering for item', index);\n\n for (const filteredOutQuestion of filteredOutQuestions) {\n const childControl = control.get(filteredOutQuestion.name);\n childControl.setValidators([]);\n childControl.updateValueAndValidity({onlySelf: true, emitEvent: false});\n }\n\n for (const filteredQuestion of filteredQuestions) {\n const childControl = control.get(filteredQuestion.name);\n const convertedValidators = this.convertValidators(filteredQuestion.validators);\n childControl.setValidators(convertedValidators);\n childControl.updateValueAndValidity({onlySelf: true, emitEvent: false});\n }\n }\n }\n\n return currentArray ? currentArray : newArray;\n case QuestionType.Checklist:\n return this.generateGroupForChecklist(question, convertedValidators);\n case QuestionType.Slider:\n return this.fb.control(defaultValue, { validators: convertedValidators }); // Remove update on blur for sliders.\n default:\n return this.fb.control(defaultValue, { validators: convertedValidators, updateOn: 'blur' });\n }\n }\n\n /**\n * Generates the form group for a checklist question.\n * @param question The question. Must be of type checklist or else null is returned.\n * @returns A form group.\n * @author Will Poulson\n */\n private generateGroupForChecklist(question: Question, convertedValidators) {\n if (question.type !== QuestionType.Checklist || question.checklistItems.length === 0) {\n return null;\n }\n\n const checklistForms: FormGroup = this.fb.group({});\n for (const checklistItem of question.checklistItems) {\n const checklistItemControl = this.fb.control(null, convertedValidators);\n checklistForms.addControl(checklistItem.name, checklistItemControl);\n }\n return checklistForms;\n }\n\n\n /**\n * Generates the form template for a repeater question.\n * @param question The question. Must be of type repeater or else null is returned.\n * @returns A form group.\n * @author Will Poulson\n */\n public generateFormsForRepeater(question: Question, index?: any): FormGroup {\n if (question.type !== QuestionType.Repeater || question.repeaterQuestions.length === 0) {\n console.log('Question isnt a repeater or has no questions, returning null');\n return null;\n }\n\n const repeaterForms: FormGroup = this.fb.group({});\n\n for (const repeaterQuestion of question.repeaterQuestions) {\n const repeaterQuestionControl = this.generateControlForRepeaterQuestion(repeaterQuestion);\n repeaterForms.addControl(repeaterQuestion.name, repeaterQuestionControl);\n }\n\n return repeaterForms;\n }\n\n /**\n * Generates a control for a repeaters question.\n * @param repeaterQuestion A repeater question.\n * @returns An abstract control.\n * @author Will Poulson\n */\n private generateControlForRepeaterQuestion(repeaterQuestion: RepeaterQuestion): AbstractControl {\n const convertedValidators = this.convertValidators(repeaterQuestion.validators);\n return this.fb.control(null, { validators: convertedValidators, updateOn: 'blur' });\n }\n\n /**\n * Converts an array of validators into form validators.\n * @param validators The uncoverted array of validators.\n * @returns A convered array of form validators.\n * @author Will Poulson\n */\n private convertValidators(validators: Array<Validator>): Array<ValidatorFn> {\n if (!validators || validators.length === 0) {\n return [];\n }\n const convertedValidators: Array<ValidatorFn> = [];\n for (const validator of validators) {\n const convertedValidator = this.convertValidator(validator);\n if (convertedValidator) {\n convertedValidators.push(convertedValidator);\n }\n }\n return convertedValidators;\n }\n\n /**\n * Converts a single validator into a form validator.\n * @param validator The unconverted validator.\n * @returns A converted form validator.\n * @author Will Poulson\n */\n private convertValidator(validator: Validator): ValidatorFn | null {\n switch (validator.type) {\n case ValidationType.Required:\n return Validators.required;\n default:\n return null;\n }\n }\n\n /**\n * Constructs the forms for repeaters from saved state.\n * @param savedState The saved state to load.\n * @param sections The sections already generated by the form constructor.\n */\n public constructRepeaterFromsFromState(savedState: any, sections: Array<Section>, currentQuestionnaireForm: FormGroup) {\n for (const section of sections) {\n for (const question of section.questions) {\n if (question.type !== QuestionType.Repeater) {\n continue;\n }\n\n const repeaterArray = savedState[section.name][question.name];\n if (!repeaterArray || repeaterArray.length === 0) {\n continue;\n }\n\n const repeaterFormArray = currentQuestionnaireForm.get([section.name, question.name]) as FormArray;\n\n if (repeaterFormArray.controls.length === repeaterArray.length) {\n continue;\n }\n\n // For each item that used to be there push a new empty template there to be populated.\n for (const repeaterItem of repeaterArray) {\n const index = repeaterArray.indexOf(repeaterItem);\n const repeaterItemTemplate = this.generateFormsForRepeater(question, index);\n repeaterFormArray.push(repeaterItemTemplate);\n }\n }\n }\n }\n}\n","import { Injectable, Inject, EventEmitter } from '@angular/core';\nimport { FormConstructorService } from './form-constructor.service';\nimport { Questionnaire } from '../interfaces/questionnaire';\nimport { FormGroup, AbstractControl, FormArray, FormBuilder } from '@angular/forms';\nimport { Section } from '../interfaces/section';\nimport { Question } from '../interfaces/question';\nimport { Subscription } from 'rxjs';\nimport * as _ from 'lodash';\nimport { QuestionnaireOptions } from '../interfaces/questionnaire-options';\nimport { QuestionType } from '../enums/question-type.enum';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class QuestionnaireService {\n public dataChangedEvent: EventEmitter<any> = new EventEmitter<any>();\n public sectionFinishedEvent: EventEmitter<any> = new EventEmitter<any>();\n\n private originalQuestionnaire: Questionnaire;\n\n private currentQuestionnaire: Questionnaire;\n private currentQuestionnaireForm: FormGroup;\n\n private currentSectionName: string;\n private currentQuestionName: string;\n\n private questionnaireValueChangeSubscription: Subscription;\n private questionValueChangeSubscription: Subscription;\n\n public additionalData: Object;\n\n private skippable = true;\n\n constructor(\n private formConstuctor: FormConstructorService,\n @Inject('options') private options: QuestionnaireOptions\n ) { }\n\n /**\n * Loads a questionnaire from data.\n * @param questionnaire The questionnaire data to load, often parsed JSON from the editor.\n * @param savedState The saved state of the questionnaire, often from localstorage.\n * @returns null\n * @author Will Poulson\n */\n public loadQuestionnaire(questionnaire: Questionnaire, savedState?: Object, additionalData?: Object) {\n this.originalQuestionnaire = _.cloneDeep(questionnaire);\n this.currentQuestionnaire = _.cloneDeep(questionnaire);\n\n this.additionalData = additionalData;\n\n if (savedState && Object.keys(savedState).length > 0) {\n const newData = this.formConstuctor.generateFormsForQuestionnaire(\n _.cloneDeep(this.originalQuestionnaire),\n _.cloneDeep(this.currentQuestionnaire),\n this.currentQuestionnaireForm,\n this.additionalData,\n true\n );\n\n if (newData) {\n this.formConstuctor.constructRepeaterFromsFromState(savedState, newData.sections, newData.forms);\n this.currentQuestionnaireForm = newData.forms;\n this.currentQuestionnaireForm.patchValue(savedState);\n }\n\n }\n\n this.updateQuestionnaire(savedState);\n\n\n\n if (this.options.skipToFirstSection) {\n this.currentSectionName = Object.keys(this.currentQuestionnaireForm.controls)[0];\n }\n\n if (this.options.skipToFirstQuestion) {\n this.currentQuestionName = Object.keys(this.currentSection.formGroup.controls)[0];\n }\n\n }\n\n /**\n * Updates the current questionnaire, used when a value is updated to check conditions.\n * @param savedState The saved state of the questionnaire, often from localstorage.\n * @returns null\n * @author Will Poulson\n */\n public updateQuestionnaire(savedState?: Object) {\n const oldLength = this.currentQuestionnaire.sections.map(x => x.questions.length).reduce((a, b) => a + b, 0);\n\n const newData = this.formConstuctor.generateFormsForQuestionnaire(\n _.cloneDeep(this.originalQuestionnaire),\n _.cloneDeep(this.currentQuestionnaire),\n this.currentQuestionnaireForm,\n this.additionalData\n );\n\n if (newData) {\n this.currentQuestionnaireForm = newData.forms;\n this.currentQuestionnaire.sections = newData.sections;\n }\n\n if (savedState && Object.keys(savedState).length > 0) {\n this.currentQuestionnaireForm.patchValue(savedState);\n }\n\n if (this.questionnaireValueChangeSubscription) {\n this.questionnaireValueChangeSubscription.unsubscribe();\n }\n\n if (this.questionValueChangeSubscription) {\n this.questionValueChangeSubscription.unsubscribe();\n }\n\n this.questionnaireValueChangeSubscription = this.currentQuestionnaireForm.valueChanges.subscribe(() => {\n this.dataChangedEvent.emit();\n this.updateQuestionnaire(this.currentQuestionnaireForm.getRawValue());\n });\n\n if (this.currentQuestion && this.currentQuestion.formControl) {\n this.questionValueChangeSubscription = this.currentQuestion.formControl.valueChanges.subscribe(() => {\n this.clearFields(this.currentQuestion.data.clearfields);\n });\n }\n\n const newLength = this.currentQuestionnaire.sections.map(x => x.questions.length).reduce((a, b) => a + b, 0);\n\n if (oldLength !== newLength) {\n for (const section of this.currentQuestionnaire.sections) {\n for (const question of section.questions) {\n const control = this.currentQuestionnaireForm.get([section.name, question.name]);\n if (control && control.value === null && question.defaultValue) {\n control.setValue(question.defaultValue);\n }\n }\n }\n }\n }\n\n public updateAdditionalData(payload: any) {\n this.additionalData = Object.assign(this.additionalData, payload);\n this.updateQuestionnaire(this.currentQuestionnaireForm.getRawValue());\n }\n\n public clearAdditionalData() {\n this.additionalData = {};\n this.updateQuestionnaire(this.currentQuestionnaireForm.getRawValue());\n }\n\n public get isValid() {\n return this.currentQuestionnaireForm.valid;\n }\n\n public get isFirstQuestion(): boolean {\n if (!this.currentSection || !this.currentQuestion) {\n return false;\n }\n const currentIndex = this.currentSection.data.questions.indexOf(this.currentQuestion.data);\n return currentIndex === 0;\n }\n\n public get isLastQuestion(): boolean {\n if (!this.currentSection || !this.currentQuestion) {\n return false;\n }\n const currentIndex = this.currentSection.data.questions.indexOf(this.currentQuestion.data);\n const maxIndex = this.currentSection.data.questions.length - 1;\n return currentIndex === maxIndex;\n }\n\n public get isFirstSection(): boolean {\n if (!this.currentSection) {\n return false;\n }\n\n const currentIndex = this.currentQuestionnaire.sections.indexOf(this.currentSection.data);\n return currentIndex === 0;\n }\n\n public get isLastSection(): boolean {\n if (!this.currentSection) {\n return false;\n }\n\n const currentIndex = this.currentQuestionnaire.sections.indexOf(this.currentSection.data);\n const maxIndex = this.currentQuestionnaire.sections.length - 1;\n return currentIndex === maxIndex;\n }\n\n public sectionValid(name: string) {\n return this.currentQuestionnaireForm.get(name).valid;\n }\n\n /**\n * Clears all the fields parsed\n * @param clearfields An array of strings, paths to clear.\n * @author Will Poulson\n */\n private clearFields(clearfields: Array<string>) {\n if (!clearfields || clearfields.length === 0) {\n return;\n }\n\n for (const clearfield of clearfields) {\n const control = this.currentQuestionnaireForm.get(clearfield);\n\n if (control) {\n control.reset(undefined);\n }\n }\n }\n\n /**\n * Unloads the current questionnaire.\n * Useful when exiting a questionnaire page or completing a questionnaire.\n * @author Will Poulson\n */\n public unloadQuestionnaire() {\n this.originalQuestionnaire = undefined;\n this.currentQuestionnaireForm = undefined;\n this.currentQuestionnaire = undefined;\n this.currentSectionName = undefined;\n this.currentQuestionName = undefined;\n this.additionalData = undefined;\n }\n\n /**\n * Gets the current selected section.\n * @returns An object containing the section data and the related form group.\n * @author Will Poulson\n */\n public get currentSection(): { data: Section; formGroup: FormGroup; } | null {\n if (!this.currentSectionName) {\n return null;\n }\n\n const data = this.currentQuestionnaire.sections.find((x) => {\n return x.name === this.currentSectionName;\n });\n\n if (!data) {\n return null;\n }\n\n return {\n data: data,\n formGroup: this.currentQuestionnaireForm.get(data.name) as FormGroup\n };\n }\n\n /**\n * Gets all the avaialble sections.\n * @returns An array of all avaialble sections.\n * @author Will Poulson\n */\n public get availableSections(): Array<Section> {\n if (!this.currentQuestionnaire || !this.currentQuestionnaire.sections) {\n return [];\n }\n return this.currentQuestionnaire.sections;\n }\n\n /**\n * Gets the current data for the entire questionnaire.\n * @returns An object of data.\n * @author Will Poulson\n */\n public get currentData() {\n return this.currentQuestionnaireForm ? this.currentQuestionnaireForm.getRawValue() : {};\n }\n\n\n /**\n * Gets the current selected question.\n * @returns An object containing the question data and the related form control.\n * @author Will Poulson\n */\n public get currentQuestion(): { data: Question; formControl: AbstractControl | null; } | null {\n if (!this.currentQuestionName) {\n return null;\n }\n\n const data = this.currentSection.data.questions.find((x) => {\n return x.name === this.currentQuestionName;\n });\n\n if (!data) {\n return null;\n }\n\n const formControl = this.currentSection.formGroup.get(data.name) as AbstractControl;\n\n return {\n data: data,\n formControl: formControl\n };\n }\n\n /**\n * Navigates to the next question.\n * If there is no question to navigate to it will reject with a out of bounds exception.\n * If allowSkipRequiredField is false then it will reject if the current question is invalid.\n * If emitSectionFinishEvent is true then it will emit an event if it's navigating past the length of questions.\n * @returns A promise which will resolve when the question has been navigated to.\n * @author Will Poulson\n */\n public nextQuestion() {\n return new Promise((resolve, reject) => {\n if (!this.options.allowSkipRequiredField) {\n if (this.currentQuestion.formControl && !this.currentQuestion.formControl.valid) {\n return reject('Current question is invalid');\n }\n }\n\n this.getCurrentQuestionIndex().then((currentIndex) => {\n const lastQuestionIndex = this.currentSection.data.questions.length - 1;\n const isLastQuestion = lastQuestionIndex === currentIndex;\n\n if (isLastQuestion) {\n this.sectionFinishedEvent.emit();\n return resolve();\n }\n\n const newIndex = currentIndex + 1;\n\n this.navigateToQuestion(newIndex).then(() => {\n return resolve();\n }).catch((error) => {\n return reject(error);\n });\n }).catch((error) => {\n return reject(error);\n });\n });\n }\n\n /**\n * Navigates to the previous question.\n * If there is no question to navigate to it will reject with a out of bounds exception.\n * If allowNavigateBackwards is false then it will reject.\n * @returns A promise which will resolve when the question has been navigated to.\n * @author Will Poulson\n */\n public prevQuestion() {\n return new Promise((resolve, reject) => {\n if (!this.options.allowNavigateBackwards) {\n return reject('This questionnaire does not allow for backwards navigation');\n }\n\n this.getCurrentQuestionIndex().then((currentIndex) => {\n const newIndex = currentIndex - 1;\n\n this.navigateToQuestion(newIndex).then(() => {\n return resolve();\n }).catch((error) => {\n return reject(error);\n });\n }).catch((error) => {\n return reject(error);\n });\n });\n }\n\n /**\n * Gets the current questions index.\n * @returns A promise which resolves a number.\n * @author Will Poulson\n */\n private getCurrentQuestionIndex(): Promise<number> {\n return new Promise((resolve, reject) => {\n const currentIndex = this.currentSection.data.questions.indexOf(this.currentQuestion.data);\n\n if (currentIndex === -1) {\n return reject('Could not find current question');\n }\n\n return resolve(currentIndex);\n });\n }\n\n /**\n * Checks a question is in bounds then navigates to it.\n * @param index The index to navigate to.\n * @returns A promise which will resolve when the question has been navigated to.\n * @author Will Poulson\n */\n public navigateToQuestion(index: number) {\n return new Promise((resolve, reject) => {\n if (this.currentSection.data.questions.length - 1 < index || index < 0) {\n return reject('Out of bounds exception');\n }\n\n this.currentQuestionName = this.currentSection.data.questions[index].name;\n return resolve();\n });\n }\n\n /**\n * Navigates to the next section.\n * @returns A promise which will resolve when the section has been navigated to.\n * @author Will Poulson\n */\n public nextSection() {\n return new Promise((resolve, reject) => {\n this.getCurrentSectionIndex().then((currentIndex) => {\n const newIndex = currentIndex + 1;\n this.navigateToSection(newIndex).then(() => {\n return resolve();\n }).catch((error) => {\n return reject(error);\n });\n }).catch((error) => {\n return reject(error);\n });\n });\n }\n\n /**\n * Navigates to the previous section.\n * @returns A promise which will resolve when the section has been navigated to.\n * @author Will Poulson\n */\n public prevSection() {\n return new Promise((resolve, reject) => {\n this.getCurrentSectionIndex().then((currentIndex) => {\n const newIndex = currentIndex - 1;\n this.navigateToSection(newIndex).then(() => {\n return resolve();\n }).catch((error) => {\n return reject(error);\n });\n }).catch((error) => {\n return reject(error);\n });\n });\n }\n\n /**\n * Gets the current section index.\n * @returns A promise which resolves a number.\n * @author Will Poulson\n */\n private getCurrentSectionIndex(): Promise<number> {\n return new Promise((resolve, reject) => {\n const currentIndex = this.currentQuestionnaire.sections.indexOf(this.currentSection.data);\n\n if (currentIndex === -1) {\n return reject('Could not find current section');\n }\n\n return resolve(currentIndex);\n });\n }\n\n /**\n * Checks a section is in bounds then navigates to it.\n * @param index The index to navigate to.\n * @returns A promise which will resolve when the section has been navigated to.\n * @author Will Poulson\n */\n public navigateToSection(index: number) {\n return new Promise((resolve, reject) => {\n if (this.currentQuestionnaire.sections.length - 1 < index || index < 0) {\n return reject('Out of bounds exception');\n }\n\n this.currentSectionName = this.currentQuestionnaire.sections[index].name;\n return resolve();\n });\n }\n\n /**\n * Answers the current question with the parsed value.\n * @param answer The value to answer the question with.\n * @author Will Poulson\n */\n public answerCurrentQuestion(answer: any, sendToNextQuestion?: boolean) {\n if (!sendToNextQuestion) {\n this.currentQuestion.formControl.setValue(answer);\n return;\n }\n\n if (this.skippable) { // Timeout to prevent skipping glitch.\n this.skippable = false;\n setTimeout(() => {\n this.currentQuestion.formControl.setValue(answer);\n this.nextQuestion().then(() => {\n this.skippable = true;\n });\n }, 150);\n }\n }\n\n /**\n * Adds a repeater item to the current question.\n * Current question must be of type Repeater.\n * @returns A promise which resolves when the repeater item has been added.\n * @author Will Poulson\n */\n public addRepeaterItem() {\n return new Promise((resolve, reject) => {\n if (this.currentQuestion.data.type !== QuestionType.Repeater) {\n return reject(`Current question isn't a repeater`);\n }\n \n const repeaterForm = this.formConstuctor.generateFormsForRepeater(this.currentQuestion.data);\n\n if (!repeaterForm) {\n return reject(`Repeater template failed to generate. May be due to the repeater having no items in the editor.`);\n }\n\n\n if (!(this.currentQuestion.formControl instanceof FormArray)) {\n return reject(`The current questions control isn't of type FormArray`);\n }\n\n this.currentQuestion.formControl.push(repeaterForm);\n return resolve();\n });\n }\n\n /**\n * Removes a repeater item on the current question.\n * Current question must be of type Repeater.\n * @param index The index at which to remove.\n * @returns A promise which resolves when the repeater item has been removed.\n * @author Will Poulson\n */\n public removeRepeaterItem(index: number) {\n return new Promise((resolve, reject) => {\n if (this.currentQuestion.data.type !== QuestionType.Repeater) {\n return reject(`Current question isn't a repeater`);\n }\n\n if (!(this.currentQuestion.formControl instanceof FormArray)) {\n return reject(`The current questions control isn't of type FormArray`);\n }\n\n this.currentQuestion.formControl.removeAt(index);\n return resolve();\n });\n }\n\n /**\n * Returns the display text for a given repeater item\n * @param index The index at which to get the label for.\n * @returns A string which is the display text.\n * @author Will Poulson\n */\n public getRepeaterItemLabel(index: number): string {\n if (!this.currentQuestion.formControl || !(this.currentQuestion.formControl instanceof FormArray)) {\n return '';\n }\n\n const repeaterItem = this.currentQuestion.formControl.controls[index];\n\n if (!repeaterItem) {\n return '';\n }\n\n const template = this.currentQuestion.data.repeaterDisplayName;\n const splitTemplate = template.split(' ');\n\n const displayArray = [];\n for (const templateItem of splitTemplate) {\n if (templateItem.match(/\\[.*?\\]/)) {\n const path = templateItem.replace(/[\\[\\]']+/g, '');\n const item = repeaterItem.get(path);\n const value = (item && item.value ? item.value : '?');\n displayArray.push(value);\n } else {\n displayArray.push(templateItem);\n }\n }\n\n const display = displayArray.join(' ');\n return display;\n }\n}\n","import { NgModule } from '@angular/core';\nimport { FormConstructorService } from './services/form-constructor.service';\nimport { QuestionnaireService } from './services/questionnaire.service';\nimport { FilterService } from './services/filter.service';\nimport { FormsModule, ReactiveFormsModule } from '@angular/forms';\nimport { QuestionnaireOptions } from './interfaces/questionnaire-options';\nimport { ModuleWithProviders } from '@angular/compiler/src/core';\n\n@NgModule({\n declarations: [],\n providers: [\n FormConstructorService,\n FilterService\n ],\n imports: [\n FormsModule,\n ReactiveFormsModule\n ],\n})\nexport class GgQuestionnaireV2Module {\n public static forRoot(options: QuestionnaireOptions): ModuleWithProviders {\n return {\n ngModule: GgQuestionnaireV2Module,\n providers: [\n QuestionnaireService,\n {\n provide: 'options',\n useValue: options\n }\n ]\n };\n }\n}\n","export enum InputType {\n Text = 'text',\n Number = 'number',\n Email = 'email',\n Telephone = 'tel',\n Password = 'password',\n Color = 'color',\n Date = 'date',\n DateTimeLocal = 'datetime-local',\n Time = 'time',\n Month = 'month',\n Week = 'week',\n}\n","export enum RepeaterQuestionType {\n Input = 'input',\n Select = 'select',\n Upload = 'upload',\n}\n"],"names":["_.clone","_.get","_.keys","_.cloneDeep"],"mappings":";;;;;;;;;;IACI,OAAQ,OAAO;IACf,QAAS,QAAQ;IACjB,UAAW,UAAU;IACrB,UAAW,UAAU;IACrB,WAAY,WAAW;IACvB,YAAa,YAAY;IACzB,QAAS,QAAQ;IACjB,WAAY,WAAW;IACvB,QAAS,QAAQ;IACjB,MAAO,MAAM;;;;;;;;;ICTb,SAAU,SAAS;IACnB,YAAa,YAAY;IACzB,UAAW,UAAU;IACrB,aAAc,aAAa;IAC3B,UAAW,UAAU;IACrB,UAAW,UAAU;;;;;;;;;ICLrB,OAAQ,OAAO;IACf,KAAM,KAAK;;;;;;;ACFf,MAca,aAAa;IAExB,iBAAiB;;;;;;;;;IASV,cAAc,CAAC,QAAwB,EAAE,wBAA0C,EAAE,cAAuB;;cAC3G,gBAAgB,GAAG,EAAE;QAC3B,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;YAC9B,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,eAAe,EAAE,wBAAwB,EAAE,cAAc,CAAC,EAAE;gBACjG,SAAS;aACV;;kBAEK,iBAAiB,GAAG,EAAE;YAC5B,KAAK,MAAM,QAAQ,IAAI,OAAO,CAAC,SAAS,EAAE;gBACxC,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAC,eAAe,EAAE,wBAAwB,EAAE,cAAc,CAAC,EAAE;oBAClG,SAAS;iBACV;;gBAGD,IAAI,QAAQ,CAAC,IAAI,KAAK,UAAU,EAAE;;0BAC1B,KAAK,sBAAG,wBAAwB,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,EA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AE5C,kDAAmC;;;;;IACnC,mDAAoC;;;;;IAEpC,oEAA2D;;;;;IAC3D,+DAAsD;;IAEtD,8CAA8B;;;;;IAE9B,yCAAyB;;;;;IAGvB,8CAA8C;;;;;IAC9C,uCAAwD;;;;;;;ACnC5D,MAmBa,uBAAuB;;;;;IAC3B,OAAO,OAAO,CAAC,OAA6B;QACjD,OAAO;YACH,QAAQ,EAAE,uBAAuB;YACjC,SAAS,EAAE;gBACP,oBAAoB;gBACpB;oBACI,OAAO,EAAE,SAAS;oBAClB,QAAQ,EAAE,OAAO;iBACpB;aACJ;SACJ,CAAC;KACH;;;YAvBF,QAAQ,SAAC;gBACR,YAAY,EAAE,EAAE;gBAChB,SAAS,EAAE;oBACT,sBAAsB;oBACtB,aAAa;iBACd;gBACD,OAAO,EAAE;oBACP,WAAW;oBACX,mBAAmB;iBACpB;aACF;;;;;;;;;ICjBG,MAAO,MAAM;IACb,QAAS,QAAQ;IACjB,OAAQ,OAAO;IACf,WAAY,KAAK;IACjB,UAAW,UAAU;IACrB,OAAQ,OAAO;IACf,MAAO,MAAM;IACb,eAAgB,gBAAgB;IAChC,MAAO,MAAM;IACb,OAAQ,OAAO;IACf,MAAO,MAAM;;;;;;;;;ICVb,OAAQ,OAAO;IACf,QAAS,QAAQ;IACjB,QAAS,QAAQ;;;;;;;;;;;;;;;"}
@@ -823,34 +823,78 @@ var FormConstructorService = /** @class */ (function () {
823
823
  var newArray = this.fb.array([], convertedValidators);
824
824
  /** @type {?} */
825
825
  var currentArray = currentQuestionnaireForm ? ((/** @type {?} */ (currentQuestionnaireForm.get([section.name, question.name])))) : false;
826
- if (currentArray) {
827
- console.log('Has current array');
828
- /** @type {?} */
829
- var controlsSnapshot = clone(currentArray.controls);
830
- try {
831
- for (var controlsSnapshot_1 = __values(controlsSnapshot), controlsSnapshot_1_1 = controlsSnapshot_1.next(); !controlsSnapshot_1_1.done; controlsSnapshot_1_1 = controlsSnapshot_1.next()) {
832
- var item = controlsSnapshot_1_1.value;
833
- console.log('Got item', item);
834
- /** @type {?} */
835
- var index = currentArray.controls.indexOf(item);
836
- /** @type {?} */
837
- var group = this.generateFormsForRepeater(question, index);
838
- console.log('Filtered to', group);
839
- // Gross comparison below. Could be optimised however it's here to avoid inf loop.
840
- /** @type {?} */
841
- var currentItemStrinify = JSON.stringify(Object.keys(item.controls));
842
- /** @type {?} */
843
- var newItemStringify = JSON.stringify(Object.keys(group.controls));
844
- if (currentItemStrinify !== newItemStringify) {
845
- group.patchValue(item.value);
846
- currentArray.setControl(index, group);
826
+ if (currentArray && question.filteredRepeaterQuestions) {
827
+ var _loop_1 = function (control) {
828
+ var e_4, _a, e_5, _b;
829
+ /** @type {?} */
830
+ var index = currentArray.controls.indexOf(control);
831
+ if (!index) {
832
+ return "continue";
833
+ }
834
+ /** @type {?} */
835
+ var filteredQuestions = question.filteredRepeaterQuestions[index];
836
+ if (!filteredQuestions) {
837
+ return "continue";
838
+ }
839
+ /** @type {?} */
840
+ var filteredQuestionNames = filteredQuestions.map((/**
841
+ * @param {?} x
842
+ * @return {?}
843
+ */
844
+ function (x) { return x.name; }));
845
+ /** @type {?} */
846
+ var filteredOutQuestions = question.repeaterQuestions.filter((/**
847
+ * @param {?} x
848
+ * @return {?}
849
+ */
850
+ function (x) { return !filteredQuestionNames.includes(x.name); }));
851
+ console.log('Triggering filtering for item', index);
852
+ try {
853
+ for (var filteredOutQuestions_1 = (e_4 = void 0, __values(filteredOutQuestions)), filteredOutQuestions_1_1 = filteredOutQuestions_1.next(); !filteredOutQuestions_1_1.done; filteredOutQuestions_1_1 = filteredOutQuestions_1.next()) {
854
+ var filteredOutQuestion = filteredOutQuestions_1_1.value;
855
+ /** @type {?} */
856
+ var childControl = control.get(filteredOutQuestion.name);
857
+ childControl.setValidators([]);
858
+ childControl.updateValueAndValidity({ onlySelf: true, emitEvent: false });
847
859
  }
848
860
  }
861
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
862
+ finally {
863
+ try {
864
+ if (filteredOutQuestions_1_1 && !filteredOutQuestions_1_1.done && (_a = filteredOutQuestions_1.return)) _a.call(filteredOutQuestions_1);
865
+ }
866
+ finally { if (e_4) throw e_4.error; }
867
+ }
868
+ try {
869
+ for (var filteredQuestions_1 = (e_5 = void 0, __values(filteredQuestions)), filteredQuestions_1_1 = filteredQuestions_1.next(); !filteredQuestions_1_1.done; filteredQuestions_1_1 = filteredQuestions_1.next()) {
870
+ var filteredQuestion = filteredQuestions_1_1.value;
871
+ /** @type {?} */
872
+ var childControl = control.get(filteredQuestion.name);
873
+ /** @type {?} */
874
+ var convertedValidators_1 = this_1.convertValidators(filteredQuestion.validators);
875
+ childControl.setValidators(convertedValidators_1);
876
+ childControl.updateValueAndValidity({ onlySelf: true, emitEvent: false });
877
+ }
878
+ }
879
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
880
+ finally {
881
+ try {
882
+ if (filteredQuestions_1_1 && !filteredQuestions_1_1.done && (_b = filteredQuestions_1.return)) _b.call(filteredQuestions_1);
883
+ }
884
+ finally { if (e_5) throw e_5.error; }
885
+ }
886
+ };
887
+ var this_1 = this;
888
+ try {
889
+ for (var _b = __values(currentArray.controls), _c = _b.next(); !_c.done; _c = _b.next()) {
890
+ var control = _c.value;
891
+ _loop_1(control);
892
+ }
849
893
  }
850
894
  catch (e_3_1) { e_3 = { error: e_3_1 }; }
851
895
  finally {
852
896
  try {
853
- if (controlsSnapshot_1_1 && !controlsSnapshot_1_1.done && (_a = controlsSnapshot_1.return)) _a.call(controlsSnapshot_1);
897
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
854
898
  }
855
899
  finally { if (e_3) throw e_3.error; }
856
900
  }
@@ -887,7 +931,7 @@ var FormConstructorService = /** @class */ (function () {
887
931
  * @return {?} A form group.
888
932
  */
889
933
  function (question, convertedValidators) {
890
- var e_4, _a;
934
+ var e_6, _a;
891
935
  if (question.type !== QuestionType.Checklist || question.checklistItems.length === 0) {
892
936
  return null;
893
937
  }
@@ -901,12 +945,12 @@ var FormConstructorService = /** @class */ (function () {
901
945
  checklistForms.addControl(checklistItem.name, checklistItemControl);
902
946
  }
903
947
  }
904
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
948
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
905
949
  finally {
906
950
  try {
907
951
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
908
952
  }
909
- finally { if (e_4) throw e_4.error; }
953
+ finally { if (e_6) throw e_6.error; }
910
954
  }
911
955
  return checklistForms;
912
956
  };
@@ -931,39 +975,27 @@ var FormConstructorService = /** @class */ (function () {
931
975
  * @return {?} A form group.
932
976
  */
933
977
  function (question, index) {
934
- var e_5, _a;
978
+ var e_7, _a;
935
979
  if (question.type !== QuestionType.Repeater || question.repeaterQuestions.length === 0) {
936
980
  console.log('Question isnt a repeater or has no questions, returning null');
937
981
  return null;
938
982
  }
939
983
  /** @type {?} */
940
- var repeaterQuestions = question.repeaterQuestions;
941
- if (question.filteredRepeaterQuestions && question.filteredRepeaterQuestions[index]) {
942
- repeaterQuestions = question.filteredRepeaterQuestions[index];
943
- }
944
- console.log('Index passed', index);
945
- console.log('All filtered questions', question.filteredRepeaterQuestions);
946
- console.log('Got the following repeater questions', repeaterQuestions.map((/**
947
- * @param {?} x
948
- * @return {?}
949
- */
950
- function (x) { return x.name; })));
951
- /** @type {?} */
952
984
  var repeaterForms = this.fb.group({});
953
985
  try {
954
- for (var repeaterQuestions_1 = __values(repeaterQuestions), repeaterQuestions_1_1 = repeaterQuestions_1.next(); !repeaterQuestions_1_1.done; repeaterQuestions_1_1 = repeaterQuestions_1.next()) {
955
- var repeaterQuestion = repeaterQuestions_1_1.value;
986
+ for (var _b = __values(question.repeaterQuestions), _c = _b.next(); !_c.done; _c = _b.next()) {
987
+ var repeaterQuestion = _c.value;
956
988
  /** @type {?} */
957
989
  var repeaterQuestionControl = this.generateControlForRepeaterQuestion(repeaterQuestion);
958
990
  repeaterForms.addControl(repeaterQuestion.name, repeaterQuestionControl);
959
991
  }
960
992
  }
961
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
993
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
962
994
  finally {
963
995
  try {
964
- if (repeaterQuestions_1_1 && !repeaterQuestions_1_1.done && (_a = repeaterQuestions_1.return)) _a.call(repeaterQuestions_1);
996
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
965
997
  }
966
- finally { if (e_5) throw e_5.error; }
998
+ finally { if (e_7) throw e_7.error; }
967
999
  }
968
1000
  return repeaterForms;
969
1001
  };
@@ -1013,7 +1045,7 @@ var FormConstructorService = /** @class */ (function () {
1013
1045
  * @return {?} A convered array of form validators.
1014
1046
  */
1015
1047
  function (validators) {
1016
- var e_6, _a;
1048
+ var e_8, _a;
1017
1049
  if (!validators || validators.length === 0) {
1018
1050
  return [];
1019
1051
  }
@@ -1029,12 +1061,12 @@ var FormConstructorService = /** @class */ (function () {
1029
1061
  }
1030
1062
  }
1031
1063
  }
1032
- catch (e_6_1) { e_6 = { error: e_6_1 }; }
1064
+ catch (e_8_1) { e_8 = { error: e_8_1 }; }
1033
1065
  finally {
1034
1066
  try {
1035
1067
  if (validators_1_1 && !validators_1_1.done && (_a = validators_1.return)) _a.call(validators_1);
1036
1068
  }
1037
- finally { if (e_6) throw e_6.error; }
1069
+ finally { if (e_8) throw e_8.error; }
1038
1070
  }
1039
1071
  return convertedValidators;
1040
1072
  };
@@ -1086,12 +1118,12 @@ var FormConstructorService = /** @class */ (function () {
1086
1118
  * @return {?}
1087
1119
  */
1088
1120
  function (savedState, sections, currentQuestionnaireForm) {
1089
- var e_7, _a, e_8, _b, e_9, _c;
1121
+ var e_9, _a, e_10, _b, e_11, _c;
1090
1122
  try {
1091
1123
  for (var sections_2 = __values(sections), sections_2_1 = sections_2.next(); !sections_2_1.done; sections_2_1 = sections_2.next()) {
1092
1124
  var section = sections_2_1.value;
1093
1125
  try {
1094
- for (var _d = (e_8 = void 0, __values(section.questions)), _e = _d.next(); !_e.done; _e = _d.next()) {
1126
+ for (var _d = (e_10 = void 0, __values(section.questions)), _e = _d.next(); !_e.done; _e = _d.next()) {
1095
1127
  var question = _e.value;
1096
1128
  if (question.type !== QuestionType.Repeater) {
1097
1129
  continue;
@@ -1108,7 +1140,7 @@ var FormConstructorService = /** @class */ (function () {
1108
1140
  }
1109
1141
  try {
1110
1142
  // For each item that used to be there push a new empty template there to be populated.
1111
- for (var repeaterArray_1 = (e_9 = void 0, __values(repeaterArray)), repeaterArray_1_1 = repeaterArray_1.next(); !repeaterArray_1_1.done; repeaterArray_1_1 = repeaterArray_1.next()) {
1143
+ for (var repeaterArray_1 = (e_11 = void 0, __values(repeaterArray)), repeaterArray_1_1 = repeaterArray_1.next(); !repeaterArray_1_1.done; repeaterArray_1_1 = repeaterArray_1.next()) {
1112
1144
  var repeaterItem = repeaterArray_1_1.value;
1113
1145
  /** @type {?} */
1114
1146
  var index = repeaterArray.indexOf(repeaterItem);
@@ -1117,30 +1149,30 @@ var FormConstructorService = /** @class */ (function () {
1117
1149
  repeaterFormArray.push(repeaterItemTemplate);
1118
1150
  }
1119
1151
  }
1120
- catch (e_9_1) { e_9 = { error: e_9_1 }; }
1152
+ catch (e_11_1) { e_11 = { error: e_11_1 }; }
1121
1153
  finally {
1122
1154
  try {
1123
1155
  if (repeaterArray_1_1 && !repeaterArray_1_1.done && (_c = repeaterArray_1.return)) _c.call(repeaterArray_1);
1124
1156
  }
1125
- finally { if (e_9) throw e_9.error; }
1157
+ finally { if (e_11) throw e_11.error; }
1126
1158
  }
1127
1159
  }
1128
1160
  }
1129
- catch (e_8_1) { e_8 = { error: e_8_1 }; }
1161
+ catch (e_10_1) { e_10 = { error: e_10_1 }; }
1130
1162
  finally {
1131
1163
  try {
1132
1164
  if (_e && !_e.done && (_b = _d.return)) _b.call(_d);
1133
1165
  }
1134
- finally { if (e_8) throw e_8.error; }
1166
+ finally { if (e_10) throw e_10.error; }
1135
1167
  }
1136
1168
  }
1137
1169
  }
1138
- catch (e_7_1) { e_7 = { error: e_7_1 }; }
1170
+ catch (e_9_1) { e_9 = { error: e_9_1 }; }
1139
1171
  finally {
1140
1172
  try {
1141
1173
  if (sections_2_1 && !sections_2_1.done && (_a = sections_2.return)) _a.call(sections_2);
1142
1174
  }
1143
- finally { if (e_7) throw e_7.error; }
1175
+ finally { if (e_9) throw e_9.error; }
1144
1176
  }
1145
1177
  };
1146
1178
  FormConstructorService.decorators = [