dynamic-questionnaire-form 1.1.0
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.
- package/dist/esm/Validate/validate.d.ts +5 -0
- package/dist/esm/Validate/validate.js +15 -0
- package/dist/esm/Validate/validate.js.map +1 -0
- package/dist/esm/components/ComplianceQuestionarie/FlaggReasonForm.d.ts +4 -0
- package/dist/esm/components/ComplianceQuestionarie/FlaggReasonForm.js +95 -0
- package/dist/esm/components/ComplianceQuestionarie/FlaggReasonForm.js.map +1 -0
- package/dist/esm/components/ComplianceQuestionarie/NewTaskForm.d.ts +13 -0
- package/dist/esm/components/ComplianceQuestionarie/NewTaskForm.js +37 -0
- package/dist/esm/components/ComplianceQuestionarie/NewTaskForm.js.map +1 -0
- package/dist/esm/components/ComplianceQuestionarie/Questionnaire.d.ts +35 -0
- package/dist/esm/components/ComplianceQuestionarie/Questionnaire.js +260 -0
- package/dist/esm/components/ComplianceQuestionarie/Questionnaire.js.map +1 -0
- package/dist/esm/components/ComplianceQuestionarie/QuestionnaireForm.d.ts +22 -0
- package/dist/esm/components/ComplianceQuestionarie/QuestionnaireForm.js +1119 -0
- package/dist/esm/components/ComplianceQuestionarie/QuestionnaireForm.js.map +1 -0
- package/dist/esm/components/Questionnaire/Questionnaire.d.ts +56 -0
- package/dist/esm/components/Questionnaire/Questionnaire.js +636 -0
- package/dist/esm/components/Questionnaire/Questionnaire.js.map +1 -0
- package/dist/esm/components/Questionnaire/QuestionnaireForm.d.ts +29 -0
- package/dist/esm/components/Questionnaire/QuestionnaireForm.js +716 -0
- package/dist/esm/components/Questionnaire/QuestionnaireForm.js.map +1 -0
- package/dist/esm/components/index.d.ts +3 -0
- package/dist/esm/components/index.js +4 -0
- package/dist/esm/components/index.js.map +1 -0
- package/dist/esm/helpers/GenericHelpers.d.ts +48 -0
- package/dist/esm/helpers/GenericHelpers.js +73 -0
- package/dist/esm/helpers/GenericHelpers.js.map +1 -0
- package/dist/esm/helpers/NormalizeHelpers.d.ts +19 -0
- package/dist/esm/helpers/NormalizeHelpers.js +327 -0
- package/dist/esm/helpers/NormalizeHelpers.js.map +1 -0
- package/dist/esm/images/Assigned.svg +11 -0
- package/dist/esm/images/Oval.svg +13 -0
- package/dist/esm/images/backGray.svg +10 -0
- package/dist/esm/images/check.svg +12 -0
- package/dist/esm/images/checkOval.svg +14 -0
- package/dist/esm/images/checked.svg +13 -0
- package/dist/esm/images/checkedPlane.svg +12 -0
- package/dist/esm/images/comment.svg +12 -0
- package/dist/esm/images/copy.svg +1 -0
- package/dist/esm/images/delete.svg +13 -0
- package/dist/esm/images/flagPlane.svg +11 -0
- package/dist/esm/images/help.svg +15 -0
- package/dist/esm/images/history.svg +11 -0
- package/dist/esm/images/infoIcon.svg +17 -0
- package/dist/esm/images/message.svg +12 -0
- package/dist/esm/images/red-flag.svg +11 -0
- package/dist/esm/images/writing.svg +11 -0
- package/dist/esm/images/writingredFlag.svg +13 -0
- package/dist/esm/images/x.svg +9 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/models/ComplianeQuestionarie.d.ts +88 -0
- package/dist/esm/models/ComplianeQuestionarie.js +2 -0
- package/dist/esm/models/ComplianeQuestionarie.js.map +1 -0
- package/dist/esm/models/QuestionarieModel.d.ts +89 -0
- package/dist/esm/models/QuestionarieModel.js +2 -0
- package/dist/esm/models/QuestionarieModel.js.map +1 -0
- package/dist/esm/scss/styles.css +866 -0
- package/dist/esm/scss/styles.css.map +1 -0
- package/package.json +64 -0
|
@@ -0,0 +1,636 @@
|
|
|
1
|
+
import { __assign, __extends, __spreadArray } from "tslib";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import QuestionnaireForm from "./QuestionnaireForm";
|
|
4
|
+
import { ParseJson, QuestionTypes, transformDateWithoutTime } from "../../helpers/GenericHelpers";
|
|
5
|
+
var QuestionnaireComponent = /** @class */ (function (_super) {
|
|
6
|
+
__extends(QuestionnaireComponent, _super);
|
|
7
|
+
function QuestionnaireComponent(props) {
|
|
8
|
+
var _this = _super.call(this, props) || this;
|
|
9
|
+
_this.setQuestions = function () {
|
|
10
|
+
var _a, _b, _c;
|
|
11
|
+
//Constructing redux form values by using questionsData
|
|
12
|
+
var initialValues = {};
|
|
13
|
+
(_a = _this.props.questionsData) === null || _a === void 0 ? void 0 : _a.forEach(function (element) {
|
|
14
|
+
var _a, _b, _c, _d, _e, _f;
|
|
15
|
+
var _g, _h, _j;
|
|
16
|
+
if (element.options.length > 0) {
|
|
17
|
+
var s = (_g = element.answers) === null || _g === void 0 ? void 0 : _g.map(function (elm) { return parseInt(elm.optionId); });
|
|
18
|
+
var val = (_a = {}, _a["question_" + element.clientQuestionId.toString()] = s, _a);
|
|
19
|
+
Object.assign(initialValues, val);
|
|
20
|
+
}
|
|
21
|
+
else if (element.questionType === QuestionTypes.Text
|
|
22
|
+
|| element.questionType === QuestionTypes.TextArea
|
|
23
|
+
|| element.questionType === QuestionTypes.Entertext
|
|
24
|
+
|| element.questionType === QuestionTypes.Email
|
|
25
|
+
|| element.questionType === QuestionTypes.PhoneNumber
|
|
26
|
+
|| element.questionType === QuestionTypes.Number
|
|
27
|
+
|| element.questionType === QuestionTypes.Currency
|
|
28
|
+
|| element.questionType === QuestionTypes.AlphaNumeric
|
|
29
|
+
|| element.questionType === QuestionTypes.ZipCode
|
|
30
|
+
|| element.questionType === QuestionTypes.SSN
|
|
31
|
+
|| element.questionType === QuestionTypes.DecimalNumber
|
|
32
|
+
|| element.questionType === QuestionTypes.EIN
|
|
33
|
+
|| element.questionType === QuestionTypes.TaxId
|
|
34
|
+
|| element.questionType === QuestionTypes.FaxId
|
|
35
|
+
|| element.questionType === QuestionTypes.disableTextField
|
|
36
|
+
|| element.questionType === QuestionTypes.LabelText
|
|
37
|
+
|| element.questionType === QuestionTypes.NumericId
|
|
38
|
+
|| element.questionType === QuestionTypes.ROUTINGNUMBER
|
|
39
|
+
|| element.questionType === QuestionTypes.Percentage
|
|
40
|
+
|| element.questionType === QuestionTypes.Percentage25A
|
|
41
|
+
|| element.questionType === QuestionTypes.Percentage25B
|
|
42
|
+
|| element.questionType === QuestionTypes.SalesPercentage
|
|
43
|
+
|| element.questionType === QuestionTypes.NumberOfMonths) {
|
|
44
|
+
var answerObj = element.answers != null ? element.answers[0] : null;
|
|
45
|
+
var val = (_b = {},
|
|
46
|
+
_b["question_" + element.clientQuestionId.toString()] = answerObj === null || answerObj === void 0 ? void 0 : answerObj.answer,
|
|
47
|
+
_b);
|
|
48
|
+
Object.assign(initialValues, val);
|
|
49
|
+
}
|
|
50
|
+
else if (element.questionType === QuestionTypes.FileUpload
|
|
51
|
+
|| element.questionType === QuestionTypes.PDFFileUpload) {
|
|
52
|
+
var answers = (_h = element === null || element === void 0 ? void 0 : element.answers) === null || _h === void 0 ? void 0 : _h.map(function (item) {
|
|
53
|
+
if (item.answer) {
|
|
54
|
+
return ParseJson(item.answer);
|
|
55
|
+
}
|
|
56
|
+
return null;
|
|
57
|
+
});
|
|
58
|
+
answers = answers === null || answers === void 0 ? void 0 : answers.filter(function (item) { return item != null; });
|
|
59
|
+
var val = (_c = {},
|
|
60
|
+
_c["question_" + element.clientQuestionId.toString()] = answers,
|
|
61
|
+
_c);
|
|
62
|
+
Object.assign(initialValues, val);
|
|
63
|
+
}
|
|
64
|
+
else if (element.questionType == QuestionTypes.Checkbox || element.questionType == QuestionTypes.PercentageValidationCheckbox) {
|
|
65
|
+
var answerObj = element.answers != null ? element.answers[0] : null;
|
|
66
|
+
var val = (_d = {},
|
|
67
|
+
_d["question_" + element.clientQuestionId] = (answerObj === null || answerObj === void 0 ? void 0 : answerObj.answer) === "true" ? true : false,
|
|
68
|
+
_d);
|
|
69
|
+
Object.assign(initialValues, val);
|
|
70
|
+
}
|
|
71
|
+
else if (QuestionTypes.DatePicker) {
|
|
72
|
+
if (element.answers != null) {
|
|
73
|
+
var value = transformDateWithoutTime((_j = element === null || element === void 0 ? void 0 : element.answers[0]) === null || _j === void 0 ? void 0 : _j.answer);
|
|
74
|
+
var val = (_e = {},
|
|
75
|
+
_e["question_" + element.clientQuestionId.toString()] = value,
|
|
76
|
+
_e);
|
|
77
|
+
Object.assign(initialValues, val);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
var answerObj = element.answers != null ? element.answers[0] : null;
|
|
82
|
+
var val = (_f = {},
|
|
83
|
+
_f["question_" + element.clientQuestionId.toString()] = answerObj === null || answerObj === void 0 ? void 0 : answerObj.optionId,
|
|
84
|
+
_f);
|
|
85
|
+
Object.assign(initialValues, val);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
if (((_c = (_b = _this.props) === null || _b === void 0 ? void 0 : _b.questionsData) === null || _c === void 0 ? void 0 : _c.length) > 0) {
|
|
89
|
+
var questionsData = _this.props.questionsData;
|
|
90
|
+
questionsData = questionsData === null || questionsData === void 0 ? void 0 : questionsData.sort(function (a, b) { return (a === null || a === void 0 ? void 0 : a.questionSequence) - (b === null || b === void 0 ? void 0 : b.questionSequence); });
|
|
91
|
+
var currentQuestions_1 = questionsData === null || questionsData === void 0 ? void 0 : questionsData.filter(function (m) { return m.dependent == false; });
|
|
92
|
+
//find the dependent questions based on answers
|
|
93
|
+
Object.keys(initialValues).forEach(function (key) {
|
|
94
|
+
var _a;
|
|
95
|
+
if (Array.isArray(initialValues[key])) {
|
|
96
|
+
var clientQuestionId_1 = parseInt(key.replace("question_", ''));
|
|
97
|
+
var answeredQuestion_1 = (_a = _this.props.questionsData) === null || _a === void 0 ? void 0 : _a.find(function (m) { return m.clientQuestionId == clientQuestionId_1; });
|
|
98
|
+
if (answeredQuestion_1) {
|
|
99
|
+
var options = answeredQuestion_1.options.filter(function (ele) { var _a; return ((_a = initialValues[key]) === null || _a === void 0 ? void 0 : _a.indexOf(ele.value)) > -1 && ele.goToNextQuestion != null; });
|
|
100
|
+
options.forEach(function (option) {
|
|
101
|
+
var _a;
|
|
102
|
+
var nextQuestion = (_a = _this.props.questionsData) === null || _a === void 0 ? void 0 : _a.find(function (ele) {
|
|
103
|
+
return ele.questionId == option.goToNextQuestion && ele.serialNumber == answeredQuestion_1.serialNumber;
|
|
104
|
+
});
|
|
105
|
+
if (nextQuestion) {
|
|
106
|
+
if (currentQuestions_1.find(function (m) { return m.questionId == (nextQuestion === null || nextQuestion === void 0 ? void 0 : nextQuestion.questionId) &&
|
|
107
|
+
m.serialNumber == answeredQuestion_1.serialNumber; })) {
|
|
108
|
+
nextQuestion = undefined;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
var answeredQuestionIndex = currentQuestions_1.findIndex(function (m) { return m.questionId == (answeredQuestion_1 === null || answeredQuestion_1 === void 0 ? void 0 : answeredQuestion_1.questionId) && m.serialNumber == answeredQuestion_1.serialNumber; });
|
|
112
|
+
if (nextQuestion && nextQuestion.denpendentQuestionGroupId) {
|
|
113
|
+
var groupQuestions = _this.getDependentGroupQuestions(nextQuestion, true);
|
|
114
|
+
// need to append to the current question
|
|
115
|
+
groupQuestions.forEach(function (question, index) {
|
|
116
|
+
currentQuestions_1.splice(answeredQuestionIndex + 1 + index, 0, question);
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
if (nextQuestion && !nextQuestion.denpendentQuestionGroupId) {
|
|
120
|
+
currentQuestions_1.splice(answeredQuestionIndex + 1, 0, nextQuestion);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
currentQuestions_1 = currentQuestions_1.sort(function (a, b) { return (a === null || a === void 0 ? void 0 : a.questionSequence) - (b === null || b === void 0 ? void 0 : b.questionSequence); });
|
|
127
|
+
_this.setState({
|
|
128
|
+
currentQuestions: currentQuestions_1,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
_this.setState(function (prevstate) { return (__assign(__assign({}, prevstate), { formInitialvalues: initialValues })); });
|
|
132
|
+
};
|
|
133
|
+
_this.getDependentGroupQuestions = function (question, includeSerialNumbers) {
|
|
134
|
+
if (includeSerialNumbers === void 0) { includeSerialNumbers = false; }
|
|
135
|
+
if (question && question.denpendentQuestionGroupId) {
|
|
136
|
+
var denpendentQuestionGroupId_1 = question.denpendentQuestionGroupId;
|
|
137
|
+
var questionsdata = Object.assign([], _this.props.questionsData);
|
|
138
|
+
if (includeSerialNumbers) {
|
|
139
|
+
var groupQuestions = questionsdata === null || questionsdata === void 0 ? void 0 : questionsdata.filter(function (element) { return element.denpendentQuestionGroupId == denpendentQuestionGroupId_1; }).sort(function (a, b) {
|
|
140
|
+
return (a === null || a === void 0 ? void 0 : a.questionSequence) - (b === null || b === void 0 ? void 0 : b.questionSequence);
|
|
141
|
+
});
|
|
142
|
+
return groupQuestions;
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
var groupQuestions = questionsdata === null || questionsdata === void 0 ? void 0 : questionsdata.filter(function (element) { return element.denpendentQuestionGroupId == denpendentQuestionGroupId_1
|
|
146
|
+
&& element.serialNumber == question.serialNumber; }).sort(function (a, b) {
|
|
147
|
+
return (a === null || a === void 0 ? void 0 : a.questionSequence) - (b === null || b === void 0 ? void 0 : b.questionSequence);
|
|
148
|
+
});
|
|
149
|
+
return groupQuestions;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return [];
|
|
153
|
+
};
|
|
154
|
+
_this.saveQuestion = function (values) {
|
|
155
|
+
_this.saveAndPrepareNextQuestion(values.questionData, values.oldAnswer);
|
|
156
|
+
};
|
|
157
|
+
_this.saveAndPrepareNextQuestion = function (values, oldAnswer) {
|
|
158
|
+
var _a, _b;
|
|
159
|
+
var removedDependentQuestions = [];
|
|
160
|
+
var clientQuestionId = parseInt(Object.keys(values)[0]);
|
|
161
|
+
var questionAnswer = values[clientQuestionId];
|
|
162
|
+
var currentQuestions = __spreadArray([], _this.state.currentQuestions, true);
|
|
163
|
+
var answeredQuestion = currentQuestions.find(function (e) { return e.clientQuestionId == clientQuestionId; });
|
|
164
|
+
if (!answeredQuestion) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
var questionsCompleted = false;
|
|
168
|
+
//remove the dependent question based on previous answer
|
|
169
|
+
if (answeredQuestion.questionType !== QuestionTypes.Text && answeredQuestion.answers) {
|
|
170
|
+
var option_1 = null;
|
|
171
|
+
if (Array.isArray(answeredQuestion.answers) &&
|
|
172
|
+
(answeredQuestion === null || answeredQuestion === void 0 ? void 0 : answeredQuestion.answers.length) > 0 &&
|
|
173
|
+
Array.isArray(oldAnswer[clientQuestionId])) {
|
|
174
|
+
var latestRemovedOption_1 = null;
|
|
175
|
+
if (questionAnswer == null) {
|
|
176
|
+
latestRemovedOption_1 = oldAnswer[clientQuestionId];
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
var answers_1 = Array.isArray(questionAnswer) ? questionAnswer : [];
|
|
180
|
+
latestRemovedOption_1 = (_a = oldAnswer[clientQuestionId]) === null || _a === void 0 ? void 0 : _a.find(function (m) { return !answers_1.includes(m); });
|
|
181
|
+
}
|
|
182
|
+
option_1 = answeredQuestion === null || answeredQuestion === void 0 ? void 0 : answeredQuestion.options.find(function (ele) { return ele.value == latestRemovedOption_1; });
|
|
183
|
+
}
|
|
184
|
+
else if (Array.isArray(answeredQuestion.answers) &&
|
|
185
|
+
answeredQuestion.answers.length > 0 && !Array.isArray(oldAnswer[clientQuestionId])) {
|
|
186
|
+
var latestRemovedOption_2 = oldAnswer[clientQuestionId];
|
|
187
|
+
option_1 = (_b = answeredQuestion.options) === null || _b === void 0 ? void 0 : _b.find(function (ele) { return ele.value == latestRemovedOption_2; });
|
|
188
|
+
}
|
|
189
|
+
if (option_1 && option_1.goToNextQuestion) {
|
|
190
|
+
//remove the answer of the dependent question
|
|
191
|
+
var dependentQuestion_1 = currentQuestions.find(function (m) { return m.questionId == (option_1 === null || option_1 === void 0 ? void 0 : option_1.goToNextQuestion) &&
|
|
192
|
+
m.serialNumber == (answeredQuestion === null || answeredQuestion === void 0 ? void 0 : answeredQuestion.serialNumber); });
|
|
193
|
+
if (dependentQuestion_1 && (dependentQuestion_1 === null || dependentQuestion_1 === void 0 ? void 0 : dependentQuestion_1.denpendentQuestionGroupId)) {
|
|
194
|
+
// remove all the group questions
|
|
195
|
+
var groupQuestions = currentQuestions
|
|
196
|
+
.filter(function (m) { return m.denpendentQuestionGroupId == (dependentQuestion_1 === null || dependentQuestion_1 === void 0 ? void 0 : dependentQuestion_1.denpendentQuestionGroupId); }
|
|
197
|
+
// && m.serialNumber == dependentQuestion?.serialNumber
|
|
198
|
+
);
|
|
199
|
+
var deleteAllSerials = false;
|
|
200
|
+
//delete all serials number questions within dependent group if deleteAllSerials is true
|
|
201
|
+
if (groupQuestions && groupQuestions.length > 0 && groupQuestions[0].deleteAllSerials) {
|
|
202
|
+
groupQuestions = currentQuestions
|
|
203
|
+
.filter(function (m) { return m.denpendentQuestionGroupId == (dependentQuestion_1 === null || dependentQuestion_1 === void 0 ? void 0 : dependentQuestion_1.denpendentQuestionGroupId); });
|
|
204
|
+
deleteAllSerials = true;
|
|
205
|
+
}
|
|
206
|
+
if (deleteAllSerials == true) {
|
|
207
|
+
var dependentQuestionIds_1 = [];
|
|
208
|
+
groupQuestions.forEach(function (groupQuestion) {
|
|
209
|
+
dependentQuestionIds_1 = dependentQuestionIds_1
|
|
210
|
+
.concat(_this.getAllDependentQuestions(groupQuestion.questionId, groupQuestion.serialNumber));
|
|
211
|
+
});
|
|
212
|
+
var removedQuestions = currentQuestions.filter(function (m) { return (dependentQuestionIds_1 === null || dependentQuestionIds_1 === void 0 ? void 0 : dependentQuestionIds_1.indexOf(m.questionId)) > -1; });
|
|
213
|
+
removedDependentQuestions = removedDependentQuestions.concat(removedQuestions);
|
|
214
|
+
var removedClientQuestionIds_1 = removedDependentQuestions.map(function (m) { return m.clientQuestionId; });
|
|
215
|
+
currentQuestions = currentQuestions
|
|
216
|
+
.filter(function (m) { return (removedClientQuestionIds_1 === null || removedClientQuestionIds_1 === void 0 ? void 0 : removedClientQuestionIds_1.indexOf(m.clientQuestionId)) == -1; });
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
var dependentQuestionIds_2 = [];
|
|
220
|
+
groupQuestions.forEach(function (groupQuestion) {
|
|
221
|
+
dependentQuestionIds_2 = dependentQuestionIds_2
|
|
222
|
+
.concat(_this.getAllDependentQuestions(groupQuestion.questionId, groupQuestion.serialNumber));
|
|
223
|
+
});
|
|
224
|
+
var removedQuestions = currentQuestions
|
|
225
|
+
.filter(function (m) { return (dependentQuestionIds_2 === null || dependentQuestionIds_2 === void 0 ? void 0 : dependentQuestionIds_2.indexOf(m.questionId)) > -1; }
|
|
226
|
+
// &&m.serialNumber == dependentQuestion?.serialNumber
|
|
227
|
+
);
|
|
228
|
+
removedDependentQuestions = removedDependentQuestions.concat(removedQuestions);
|
|
229
|
+
var removedClientQuestionIds_2 = removedDependentQuestions.map(function (m) { return m.clientQuestionId; });
|
|
230
|
+
currentQuestions = currentQuestions
|
|
231
|
+
.filter(function (m) { return (removedClientQuestionIds_2 === null || removedClientQuestionIds_2 === void 0 ? void 0 : removedClientQuestionIds_2.indexOf(m.clientQuestionId)) == -1; });
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
else if (dependentQuestion_1) {
|
|
235
|
+
var dependentQuestionIds_3 = _this.getAllDependentQuestions(dependentQuestion_1 === null || dependentQuestion_1 === void 0 ? void 0 : dependentQuestion_1.questionId, dependentQuestion_1 === null || dependentQuestion_1 === void 0 ? void 0 : dependentQuestion_1.serialNumber);
|
|
236
|
+
// post this question to remove API
|
|
237
|
+
var removedQuestions = currentQuestions
|
|
238
|
+
.filter(function (m) { return (dependentQuestionIds_3 === null || dependentQuestionIds_3 === void 0 ? void 0 : dependentQuestionIds_3.indexOf(m.questionId)) > -1 &&
|
|
239
|
+
m.serialNumber == (dependentQuestion_1 === null || dependentQuestion_1 === void 0 ? void 0 : dependentQuestion_1.serialNumber); });
|
|
240
|
+
removedDependentQuestions = removedDependentQuestions.concat(removedQuestions);
|
|
241
|
+
var removedClientQuestionIds_3 = removedDependentQuestions.map(function (m) { return m.clientQuestionId; });
|
|
242
|
+
currentQuestions = currentQuestions.filter(function (m) { return (removedClientQuestionIds_3 === null || removedClientQuestionIds_3 === void 0 ? void 0 : removedClientQuestionIds_3.indexOf(m.clientQuestionId)) == -1; });
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
//get the next question from the questionsData
|
|
247
|
+
var nextQuestion = null;
|
|
248
|
+
// case 1 -- find the go to question id based on the option selected
|
|
249
|
+
if (answeredQuestion.questionType !== QuestionTypes.Text
|
|
250
|
+
&& answeredQuestion.questionType !== QuestionTypes.TextArea
|
|
251
|
+
&& answeredQuestion.questionType !== QuestionTypes.SSN
|
|
252
|
+
&& answeredQuestion.questionType !== QuestionTypes.EIN
|
|
253
|
+
&& answeredQuestion.questionType !== QuestionTypes.Email
|
|
254
|
+
&& answeredQuestion.questionType !== QuestionTypes.Number
|
|
255
|
+
&& answeredQuestion.questionType !== QuestionTypes.NumericId
|
|
256
|
+
&& answeredQuestion.questionType !== QuestionTypes.ROUTINGNUMBER
|
|
257
|
+
&& answeredQuestion.questionType !== QuestionTypes.PhoneNumber
|
|
258
|
+
&& answeredQuestion.questionType !== QuestionTypes.Currency
|
|
259
|
+
&& answeredQuestion.questionType !== QuestionTypes.AlphaNumeric
|
|
260
|
+
&& answeredQuestion.questionType !== QuestionTypes.ZipCode
|
|
261
|
+
&& answeredQuestion.questionType !== QuestionTypes.TaxId
|
|
262
|
+
&& answeredQuestion.questionType !== QuestionTypes.FaxId
|
|
263
|
+
&& answeredQuestion.questionType !== QuestionTypes.disableTextField
|
|
264
|
+
&& answeredQuestion.questionType !== QuestionTypes.LabelText
|
|
265
|
+
&& answeredQuestion.questionType !== QuestionTypes.Percentage
|
|
266
|
+
&& answeredQuestion.questionType !== QuestionTypes.Percentage25A
|
|
267
|
+
&& answeredQuestion.questionType !== QuestionTypes.Percentage25B
|
|
268
|
+
&& answeredQuestion.questionType !== QuestionTypes.SalesPercentage
|
|
269
|
+
&& answeredQuestion.questionType !== QuestionTypes.NumberOfMonths) {
|
|
270
|
+
var option_2 = null;
|
|
271
|
+
if (Array.isArray(questionAnswer)) {
|
|
272
|
+
var latestOption_1 = questionAnswer === null || questionAnswer === void 0 ? void 0 : questionAnswer.find(function (m) { var _a; return ((_a = oldAnswer[clientQuestionId]) === null || _a === void 0 ? void 0 : _a.indexOf(m)) == -1; });
|
|
273
|
+
option_2 = answeredQuestion.options.find(function (ele) { return ele.value == latestOption_1; });
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
option_2 = answeredQuestion.options.find(function (ele) { return ele.value == parseInt(questionAnswer); });
|
|
277
|
+
}
|
|
278
|
+
nextQuestion = _this.props.questionsData
|
|
279
|
+
.find(function (ele) { return ele.questionId == (option_2 === null || option_2 === void 0 ? void 0 : option_2.goToNextQuestion) &&
|
|
280
|
+
ele.serialNumber == (answeredQuestion === null || answeredQuestion === void 0 ? void 0 : answeredQuestion.serialNumber); });
|
|
281
|
+
}
|
|
282
|
+
//check if it is already exists in current Questions
|
|
283
|
+
if (nextQuestion) {
|
|
284
|
+
if (currentQuestions.find(function (m) { return m.questionId == (nextQuestion === null || nextQuestion === void 0 ? void 0 : nextQuestion.questionId) &&
|
|
285
|
+
m.serialNumber == (answeredQuestion === null || answeredQuestion === void 0 ? void 0 : answeredQuestion.serialNumber); })) {
|
|
286
|
+
nextQuestion = null;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
//check the denpendentQuestionGroupId
|
|
290
|
+
if (nextQuestion && nextQuestion.denpendentQuestionGroupId) {
|
|
291
|
+
var groupQuestions = _this.getDependentGroupQuestions(nextQuestion);
|
|
292
|
+
// need to append to the current question
|
|
293
|
+
var answeredQuestionIndex_1 = currentQuestions.findIndex(function (m) { return m.questionId == (answeredQuestion === null || answeredQuestion === void 0 ? void 0 : answeredQuestion.questionId) && m.serialNumber == answeredQuestion.serialNumber; });
|
|
294
|
+
groupQuestions.forEach(function (question, index) {
|
|
295
|
+
currentQuestions.splice(answeredQuestionIndex_1 + 1 + index, 0, question);
|
|
296
|
+
});
|
|
297
|
+
//currentQuestions = currentQuestions.concat(groupQuestions);
|
|
298
|
+
}
|
|
299
|
+
else if (nextQuestion) {
|
|
300
|
+
//set the next question
|
|
301
|
+
var answeredQuestionIndex = currentQuestions.findIndex(function (m) { return m.questionId == (answeredQuestion === null || answeredQuestion === void 0 ? void 0 : answeredQuestion.questionId) && m.serialNumber == answeredQuestion.serialNumber; });
|
|
302
|
+
currentQuestions.splice(answeredQuestionIndex + 1, 0, nextQuestion);
|
|
303
|
+
//currentQuestions.push(nextQuestion);
|
|
304
|
+
}
|
|
305
|
+
else {
|
|
306
|
+
questionsCompleted = true;
|
|
307
|
+
}
|
|
308
|
+
if (Array.isArray(questionAnswer)) {
|
|
309
|
+
answeredQuestion.answers = questionAnswer.map(function (item) {
|
|
310
|
+
return { answer: item, optionId: item };
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
else if (questionAnswer == null) {
|
|
314
|
+
answeredQuestion.answers = [];
|
|
315
|
+
}
|
|
316
|
+
else {
|
|
317
|
+
answeredQuestion.answers = [
|
|
318
|
+
{ answer: questionAnswer, optionId: questionAnswer },
|
|
319
|
+
];
|
|
320
|
+
}
|
|
321
|
+
if (_this.props.onSaveQuestion) {
|
|
322
|
+
_this.props.onSaveQuestion(answeredQuestion, oldAnswer);
|
|
323
|
+
}
|
|
324
|
+
if (removedDependentQuestions.length > 0) {
|
|
325
|
+
removedDependentQuestions.filter(function (m) { return m.serialNumber == 0; }).forEach(function (question) {
|
|
326
|
+
var _a;
|
|
327
|
+
var previousAnswer = (_a = {}, _a[question.clientQuestionId] = question.answers, _a);
|
|
328
|
+
question.answers = [];
|
|
329
|
+
if (_this.props.onSaveQuestion) {
|
|
330
|
+
_this.props.onSaveQuestion(question, previousAnswer);
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
//remove repetative question groups
|
|
334
|
+
if (removedDependentQuestions.filter(function (m) { return m.serialNumber > 0; }).length > 0) {
|
|
335
|
+
if (_this.props.onRemoveGroupQuestionBulk) {
|
|
336
|
+
var requestPayload_1 = [];
|
|
337
|
+
var groupsToDelete = removedDependentQuestions.filter(function (m) { return m.serialNumber > 0; });
|
|
338
|
+
groupsToDelete.forEach(function (item) {
|
|
339
|
+
if (requestPayload_1.find(function (m) { return m.selectedSerialNumber == item.serialNumber; }) == null)
|
|
340
|
+
requestPayload_1.push({
|
|
341
|
+
questionGroupId: item.questionGroupId,
|
|
342
|
+
selectedSerialNumber: item.serialNumber
|
|
343
|
+
});
|
|
344
|
+
});
|
|
345
|
+
_this.props.onRemoveGroupQuestionBulk(requestPayload_1);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
currentQuestions = currentQuestions.sort(function (a, b) { return (a === null || a === void 0 ? void 0 : a.questionSequence) - (b === null || b === void 0 ? void 0 : b.questionSequence); });
|
|
350
|
+
_this.setState({
|
|
351
|
+
currentQuestions: currentQuestions,
|
|
352
|
+
questionsCompleted: questionsCompleted,
|
|
353
|
+
});
|
|
354
|
+
};
|
|
355
|
+
_this.preparePostDto = function (allValues) {
|
|
356
|
+
var final = [];
|
|
357
|
+
_this.state.currentQuestions.forEach(function (element) {
|
|
358
|
+
var _a;
|
|
359
|
+
if (element.questionType == QuestionTypes.Text
|
|
360
|
+
|| element.questionType == QuestionTypes.TextArea
|
|
361
|
+
|| element.questionType == QuestionTypes.Entertext
|
|
362
|
+
|| element.questionType == QuestionTypes.Number
|
|
363
|
+
|| element.questionType === QuestionTypes.Currency
|
|
364
|
+
|| element.questionType === QuestionTypes.AlphaNumeric
|
|
365
|
+
|| element.questionType === QuestionTypes.ZipCode
|
|
366
|
+
|| element.questionType === QuestionTypes.SSN
|
|
367
|
+
|| element.questionType === QuestionTypes.EIN
|
|
368
|
+
|| element.questionType === QuestionTypes.PhoneNumber
|
|
369
|
+
|| element.questionType === QuestionTypes.Email
|
|
370
|
+
|| element.questionType === QuestionTypes.TaxId
|
|
371
|
+
|| element.questionType === QuestionTypes.FaxId
|
|
372
|
+
|| element.questionType === QuestionTypes.disableTextField
|
|
373
|
+
|| element.questionType === QuestionTypes.LabelText
|
|
374
|
+
|| element.questionType === QuestionTypes.NumericId
|
|
375
|
+
|| element.questionType === QuestionTypes.ROUTINGNUMBER
|
|
376
|
+
|| element.questionType === QuestionTypes.Percentage
|
|
377
|
+
|| element.questionType === QuestionTypes.Percentage25A
|
|
378
|
+
|| element.questionType === QuestionTypes.Percentage25B
|
|
379
|
+
|| element.questionType === QuestionTypes.SalesPercentage
|
|
380
|
+
|| element.questionType === QuestionTypes.NumberOfMonths) {
|
|
381
|
+
var setObj = {
|
|
382
|
+
questionId: element.questionId,
|
|
383
|
+
questionText: element.questionText,
|
|
384
|
+
questionType: element.questionType,
|
|
385
|
+
shortCode: element.shortCode,
|
|
386
|
+
questoionSummaryText: element.questoionSummaryText,
|
|
387
|
+
answers: [{ answer: allValues["question_" + element.clientQuestionId] }],
|
|
388
|
+
options: [],
|
|
389
|
+
};
|
|
390
|
+
final.push(setObj);
|
|
391
|
+
}
|
|
392
|
+
else if (element.questionType == QuestionTypes.MultiSelectionCheckBox || QuestionTypes.MultiSelectionDropdown) {
|
|
393
|
+
var val_1 = allValues["question_" + element.clientQuestionId];
|
|
394
|
+
var ops = (_a = element === null || element === void 0 ? void 0 : element.options) === null || _a === void 0 ? void 0 : _a.filter(function (ele) { return val_1 === null || val_1 === void 0 ? void 0 : val_1.includes(ele === null || ele === void 0 ? void 0 : ele.value); });
|
|
395
|
+
var options_1 = [];
|
|
396
|
+
var answers_2 = [];
|
|
397
|
+
ops.map(function (op) {
|
|
398
|
+
var ops1 = {
|
|
399
|
+
value: op.value,
|
|
400
|
+
text: op.text,
|
|
401
|
+
};
|
|
402
|
+
options_1.push(ops1);
|
|
403
|
+
answers_2.push({ optionId: op.value, answer: op.value });
|
|
404
|
+
});
|
|
405
|
+
var setObj = {
|
|
406
|
+
questionId: element.questionId,
|
|
407
|
+
questionText: element.questionText,
|
|
408
|
+
questionType: element.questionType,
|
|
409
|
+
questoionSummaryText: element.questoionSummaryText,
|
|
410
|
+
shortCode: element.shortCode,
|
|
411
|
+
options: options_1,
|
|
412
|
+
answers: answers_2
|
|
413
|
+
};
|
|
414
|
+
final.push(setObj);
|
|
415
|
+
}
|
|
416
|
+
else if (element.questionType == QuestionTypes.SingleSelectionBoxSelection) {
|
|
417
|
+
var val_2 = allValues["question_" + element.clientQuestionId];
|
|
418
|
+
var ops = element.options.filter(function (ele) { return ele.value == val_2; });
|
|
419
|
+
var options_2 = [];
|
|
420
|
+
var answers_3 = [];
|
|
421
|
+
ops.map(function (op) {
|
|
422
|
+
var ops2 = {
|
|
423
|
+
value: op.value,
|
|
424
|
+
text: op.text,
|
|
425
|
+
};
|
|
426
|
+
options_2.push(ops2);
|
|
427
|
+
answers_3.push({ optionId: op.value, answer: op.value });
|
|
428
|
+
});
|
|
429
|
+
var setObj = {
|
|
430
|
+
questionId: element.questionId,
|
|
431
|
+
questionText: element.questionText,
|
|
432
|
+
questionType: element.questionType,
|
|
433
|
+
questoionSummaryText: element.questoionSummaryText,
|
|
434
|
+
shortCode: element.shortCode,
|
|
435
|
+
options: options_2,
|
|
436
|
+
answers: answers_3
|
|
437
|
+
};
|
|
438
|
+
final.push(setObj);
|
|
439
|
+
}
|
|
440
|
+
else {
|
|
441
|
+
var val_3 = allValues["question_" + element.clientQuestionId];
|
|
442
|
+
var ops = element.options.filter(function (ele) { return ele.value == val_3; });
|
|
443
|
+
var options_3 = [];
|
|
444
|
+
var answers_4 = [];
|
|
445
|
+
ops.map(function (op) {
|
|
446
|
+
var ops3 = {
|
|
447
|
+
value: op.value,
|
|
448
|
+
text: op.text,
|
|
449
|
+
};
|
|
450
|
+
options_3.push(ops3);
|
|
451
|
+
answers_4.push({ optionId: op.value, answer: op.value });
|
|
452
|
+
});
|
|
453
|
+
var setObj = {
|
|
454
|
+
questionId: element.questionId,
|
|
455
|
+
questionText: element.questionText,
|
|
456
|
+
questionType: element.questionType,
|
|
457
|
+
questoionSummaryText: element.questoionSummaryText,
|
|
458
|
+
shortCode: element.shortCode,
|
|
459
|
+
options: options_3,
|
|
460
|
+
answers: answers_4
|
|
461
|
+
};
|
|
462
|
+
final.push(setObj);
|
|
463
|
+
}
|
|
464
|
+
});
|
|
465
|
+
return final;
|
|
466
|
+
};
|
|
467
|
+
_this.hndleNext = function (values) {
|
|
468
|
+
var postDto = _this.preparePostDto(values);
|
|
469
|
+
_this.props.onNextPage(postDto);
|
|
470
|
+
};
|
|
471
|
+
_this.handlePrevious = function (values) {
|
|
472
|
+
var postDto = _this.preparePostDto(values);
|
|
473
|
+
_this.props.onPreviousPage(postDto);
|
|
474
|
+
};
|
|
475
|
+
_this.getAllDependentQuestions = function (questionId, serialNumber) {
|
|
476
|
+
var dependentQuestionIds = [];
|
|
477
|
+
dependentQuestionIds.push(questionId);
|
|
478
|
+
var currentQuestions = __spreadArray([], _this.state.currentQuestions, true);
|
|
479
|
+
var answeredQuestion = currentQuestions.find(function (e) { return e.questionId == questionId &&
|
|
480
|
+
e.serialNumber == serialNumber; });
|
|
481
|
+
if (!answeredQuestion) {
|
|
482
|
+
return [];
|
|
483
|
+
}
|
|
484
|
+
var options = null;
|
|
485
|
+
if (Array.isArray(answeredQuestion.answers) && answeredQuestion.answers.length > 0) {
|
|
486
|
+
var selectedOptions_1 = answeredQuestion.answers.map(function (m) { return m.optionId ? parseInt(m.optionId.toString()) : 0; });
|
|
487
|
+
options = answeredQuestion === null || answeredQuestion === void 0 ? void 0 : answeredQuestion.options.filter(function (ele) { return (selectedOptions_1 === null || selectedOptions_1 === void 0 ? void 0 : selectedOptions_1.indexOf(ele.value)) > -1; });
|
|
488
|
+
options.forEach(function (m) {
|
|
489
|
+
if (m.goToNextQuestion) {
|
|
490
|
+
//check for group questions
|
|
491
|
+
var dependentQuestion = currentQuestions.find(function (e) { return e.questionId == m.goToNextQuestion &&
|
|
492
|
+
e.serialNumber == serialNumber; });
|
|
493
|
+
if (dependentQuestion && dependentQuestion.denpendentQuestionGroupId) {
|
|
494
|
+
var dependentGroupQuestions = _this.getDependentGroupQuestions(dependentQuestion);
|
|
495
|
+
dependentGroupQuestions.forEach(function (groupQuestion) {
|
|
496
|
+
dependentQuestionIds.push(groupQuestion.questionId);
|
|
497
|
+
var childDependents = _this.getAllDependentQuestions(groupQuestion.questionId, serialNumber);
|
|
498
|
+
dependentQuestionIds = dependentQuestionIds.concat(childDependents);
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
else if (dependentQuestion && dependentQuestion.denpendentQuestionGroupId == null) {
|
|
502
|
+
dependentQuestionIds.push(m.goToNextQuestion);
|
|
503
|
+
var childDependents = _this.getAllDependentQuestions(m.goToNextQuestion, serialNumber);
|
|
504
|
+
dependentQuestionIds = dependentQuestionIds.concat(childDependents);
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
});
|
|
508
|
+
return dependentQuestionIds;
|
|
509
|
+
}
|
|
510
|
+
return dependentQuestionIds;
|
|
511
|
+
};
|
|
512
|
+
_this.onSelectCheckedQuestions = function (question) {
|
|
513
|
+
if (!_this.props.onSelectCheckedQuestions) {
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
if (question.isRepetitive !== true && question.dependent == false && question.denpendentQuestionGroupId === null) {
|
|
517
|
+
var clientQuestionIds = _this.getAllDependentQuestionsForAllOptions(question.clientQuestionId, question.serialNumber);
|
|
518
|
+
_this.props.onSelectCheckedQuestions(clientQuestionIds);
|
|
519
|
+
}
|
|
520
|
+
else if (question.isRepetitive === true) {
|
|
521
|
+
var clientQuestionIds = _this.state.currentQuestions
|
|
522
|
+
.filter(function (m) { return m.questionGroupId == question.questionGroupId &&
|
|
523
|
+
m.serialNumber == question.serialNumber; }).map(function (m) { return m.clientQuestionId; });
|
|
524
|
+
_this.props.onSelectCheckedQuestions(clientQuestionIds);
|
|
525
|
+
}
|
|
526
|
+
else if (question.denpendentQuestionGroupId) {
|
|
527
|
+
var clientQuestionIds = _this.state.currentQuestions
|
|
528
|
+
.filter(function (m) { return m.denpendentQuestionGroupId == question.denpendentQuestionGroupId; })
|
|
529
|
+
.map(function (m) { return m.clientQuestionId; });
|
|
530
|
+
_this.props.onSelectCheckedQuestions(clientQuestionIds);
|
|
531
|
+
}
|
|
532
|
+
};
|
|
533
|
+
_this.unSelectedCheckedQuestions = function (question) {
|
|
534
|
+
if (!_this.props.unSelectedCheckedQuestions) {
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
537
|
+
if (question.isRepetitive !== true && question.dependent == false && question.denpendentQuestionGroupId === null) {
|
|
538
|
+
var clientQuestionIds = _this.getAllDependentQuestionsForAllOptions(question.clientQuestionId, question.serialNumber);
|
|
539
|
+
_this.props.unSelectedCheckedQuestions(clientQuestionIds);
|
|
540
|
+
}
|
|
541
|
+
else if (question.isRepetitive === true) {
|
|
542
|
+
var clientQuestionIds = _this.state.currentQuestions
|
|
543
|
+
.filter(function (m) { return m.questionGroupId == question.questionGroupId &&
|
|
544
|
+
m.serialNumber == question.serialNumber; }).map(function (m) { return m.clientQuestionId; });
|
|
545
|
+
_this.props.unSelectedCheckedQuestions(clientQuestionIds);
|
|
546
|
+
}
|
|
547
|
+
else if (question.denpendentQuestionGroupId) {
|
|
548
|
+
var clientQuestionIds = _this.state.currentQuestions
|
|
549
|
+
.filter(function (m) { return m.denpendentQuestionGroupId == question.denpendentQuestionGroupId; })
|
|
550
|
+
.map(function (m) { return m.clientQuestionId; });
|
|
551
|
+
_this.props.unSelectedCheckedQuestions(clientQuestionIds);
|
|
552
|
+
}
|
|
553
|
+
};
|
|
554
|
+
_this.assigneModalFunc = function (question) {
|
|
555
|
+
if (!_this.props.assigneModalFunc) {
|
|
556
|
+
return;
|
|
557
|
+
}
|
|
558
|
+
if (question.isRepetitive !== true && question.dependent == false && question.denpendentQuestionGroupId === null) {
|
|
559
|
+
var clientQuestionIds = _this.getAllDependentQuestionsForAllOptions(question.clientQuestionId, question.serialNumber);
|
|
560
|
+
_this.props.assigneModalFunc(question, clientQuestionIds);
|
|
561
|
+
}
|
|
562
|
+
else if (question.isRepetitive === true) {
|
|
563
|
+
var clientQuestionIds = _this.state.currentQuestions
|
|
564
|
+
.filter(function (m) { return m.questionGroupId == question.questionGroupId &&
|
|
565
|
+
m.serialNumber == question.serialNumber; }).map(function (m) { return m.clientQuestionId; });
|
|
566
|
+
_this.props.assigneModalFunc(question, clientQuestionIds);
|
|
567
|
+
}
|
|
568
|
+
else if (question.denpendentQuestionGroupId) {
|
|
569
|
+
var clientQuestionIds = _this.state.currentQuestions
|
|
570
|
+
.filter(function (m) { return m.denpendentQuestionGroupId == question.denpendentQuestionGroupId; })
|
|
571
|
+
.map(function (m) { return m.clientQuestionId; });
|
|
572
|
+
_this.props.assigneModalFunc(question, clientQuestionIds);
|
|
573
|
+
}
|
|
574
|
+
};
|
|
575
|
+
_this.getAllDependentQuestionsForAllOptions = function (clientQuestionId, serialNumber) {
|
|
576
|
+
var dependentQuestionIds = [];
|
|
577
|
+
dependentQuestionIds.push(clientQuestionId);
|
|
578
|
+
var currentQuestions = _this.props.questionsData;
|
|
579
|
+
var answeredQuestion = currentQuestions.find(function (e) { return e.clientQuestionId == clientQuestionId; });
|
|
580
|
+
if (!answeredQuestion) {
|
|
581
|
+
return [];
|
|
582
|
+
}
|
|
583
|
+
if (Array.isArray(answeredQuestion.options) && answeredQuestion.options.length > 0) {
|
|
584
|
+
answeredQuestion.options.forEach(function (m) {
|
|
585
|
+
if (m.goToNextQuestion) {
|
|
586
|
+
//check for group questions
|
|
587
|
+
var dependentQuestion = currentQuestions.find(function (e) { return e.questionId == m.goToNextQuestion &&
|
|
588
|
+
e.serialNumber == serialNumber; });
|
|
589
|
+
if (dependentQuestion && dependentQuestion.denpendentQuestionGroupId) {
|
|
590
|
+
var dependentGroupQuestions = _this.getDependentGroupQuestions(dependentQuestion, true);
|
|
591
|
+
dependentGroupQuestions.forEach(function (groupQuestion) {
|
|
592
|
+
var childDependents = _this.getAllDependentQuestionsForAllOptions(groupQuestion.clientQuestionId, serialNumber);
|
|
593
|
+
dependentQuestionIds = dependentQuestionIds.concat(childDependents);
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
else if (dependentQuestion && dependentQuestion.denpendentQuestionGroupId == null) {
|
|
597
|
+
var childDependents = _this.getAllDependentQuestionsForAllOptions(dependentQuestion.clientQuestionId, serialNumber);
|
|
598
|
+
dependentQuestionIds = dependentQuestionIds.concat(childDependents);
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
});
|
|
602
|
+
return dependentQuestionIds;
|
|
603
|
+
}
|
|
604
|
+
return dependentQuestionIds;
|
|
605
|
+
};
|
|
606
|
+
_this.state = {
|
|
607
|
+
questionsCompleted: false,
|
|
608
|
+
currentQuestions: [],
|
|
609
|
+
formInitialvalues: {},
|
|
610
|
+
};
|
|
611
|
+
return _this;
|
|
612
|
+
}
|
|
613
|
+
// service = new Service();
|
|
614
|
+
QuestionnaireComponent.prototype.componentDidMount = function () {
|
|
615
|
+
this.setQuestions();
|
|
616
|
+
};
|
|
617
|
+
QuestionnaireComponent.prototype.componentDidUpdate = function (previousProps) {
|
|
618
|
+
var _a, _b;
|
|
619
|
+
if (((_a = previousProps.questionsData) === null || _a === void 0 ? void 0 : _a.length) != ((_b = this.props.questionsData) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
620
|
+
this.setQuestions();
|
|
621
|
+
}
|
|
622
|
+
if (previousProps.refreshQuestionsData != this.props.refreshQuestionsData && this.props.refreshQuestionsData) {
|
|
623
|
+
this.setQuestions();
|
|
624
|
+
}
|
|
625
|
+
};
|
|
626
|
+
QuestionnaireComponent.prototype.render = function () {
|
|
627
|
+
var _a;
|
|
628
|
+
console.log("QuestionnaireComponent render", this.state, this.props, this.props.saveQuestionnaire);
|
|
629
|
+
return (React.createElement(React.Fragment, null,
|
|
630
|
+
React.createElement("div", { className: "questionaryWrap" },
|
|
631
|
+
React.createElement(QuestionnaireForm, { onSaveQuestion: this.saveQuestion, currentQuestions: this.state.currentQuestions, onNextPage: this.hndleNext, onPreviousPage: this.handlePrevious, displayNextPrevButtons: this.props.displayNextPrevButtons, questionsCompleted: this.state.questionsCompleted, formInitialvalues: this.state.formInitialvalues, disableFields: this.props.disableFields, canAddGroupQuestions: this.props.canAddGroupQuestions, onAddGroupQuestion: this.props.onAddGroupQuestion, onRemoveGroupQuestion: this.props.onRemoveGroupQuestion, formName: this.props.formName, asigneeModeOn: (_a = this.props) === null || _a === void 0 ? void 0 : _a.asigneeModeOn, onSelectCheckedQuestions: this.onSelectCheckedQuestions, unSelectedCheckedQuestions: this.unSelectedCheckedQuestions, assigneModalFunc: this.assigneModalFunc, saveQuestionnaire: this.props.saveQuestionnaire, addAnotherNotRequired: this.props.addAnotherNotRequired, onClickFile: this.props.onClickFile, onFocusOut: this.props.onFocusOut, clientProductId: this.props.clientProductId, percentageQIds: this.props.percentageQIds }))));
|
|
632
|
+
};
|
|
633
|
+
return QuestionnaireComponent;
|
|
634
|
+
}(React.Component));
|
|
635
|
+
export default QuestionnaireComponent;
|
|
636
|
+
//# sourceMappingURL=Questionnaire.js.map
|