survery-lib 2.1.43 → 2.1.44
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/esm2022/lib/core/states/entites/question.entity.mjs +1 -1
- package/esm2022/lib/core/states/survey-store/question.selector.mjs +22 -4
- package/esm2022/lib/core/states/survey-store/survey.action.mjs +1 -1
- package/esm2022/lib/core/states/survey-store/survey.effect.mjs +49 -25
- package/esm2022/lib/core/states/survey-store/survey.reducer.mjs +7 -7
- package/esm2022/shared/models/survery-question-result.model.mjs +1 -1
- package/fesm2022/survery-lib.mjs +75 -33
- package/fesm2022/survery-lib.mjs.map +1 -1
- package/lib/core/states/entites/question.entity.d.ts +1 -0
- package/lib/core/states/survey-store/survey.action.d.ts +16 -4
- package/package.json +1 -1
- package/shared/models/survery-question-result.model.d.ts +2 -0
package/fesm2022/survery-lib.mjs
CHANGED
|
@@ -142,25 +142,43 @@ const questionAnswers = createSelector(selectSurveyData, (state) => selectAll$1(
|
|
|
142
142
|
return {
|
|
143
143
|
SurveyPageIndex: x.surveyPageId,
|
|
144
144
|
QuestionId: x.questionId,
|
|
145
|
+
QuestionName: x.questionAllInfo.questionTitle,
|
|
145
146
|
QuestionType: x.questionType,
|
|
146
147
|
AnswerId: x.answerLevelId,
|
|
147
148
|
AnswerText: x.answerText,
|
|
148
149
|
AnswerIdArr: x.answerIdArr,
|
|
149
|
-
AnswerLevelId: x.answerId
|
|
150
|
+
AnswerLevelId: x.answerId,
|
|
151
|
+
PassedRuleQuestionId: x.passedRuleQuestionId
|
|
150
152
|
};
|
|
151
153
|
}
|
|
152
154
|
else {
|
|
153
155
|
return {
|
|
154
156
|
SurveyPageIndex: x.surveyPageId,
|
|
155
157
|
QuestionId: x.questionId,
|
|
158
|
+
QuestionName: x.questionAllInfo.questionTitle,
|
|
156
159
|
QuestionType: x.questionType,
|
|
157
160
|
AnswerId: x.answerId,
|
|
158
161
|
AnswerText: x.answerText,
|
|
159
162
|
AnswerIdArr: x.answerIdArr,
|
|
160
|
-
AnswerLevelId: x.answerLevelId
|
|
163
|
+
AnswerLevelId: x.answerLevelId,
|
|
164
|
+
PassedRuleQuestionId: x.passedRuleQuestionId
|
|
161
165
|
};
|
|
162
166
|
}
|
|
163
|
-
})
|
|
167
|
+
})
|
|
168
|
+
// .filter(res => {
|
|
169
|
+
// if (res.PassedRuleQuestionId !== null && res.PassedRuleQuestionId !== undefined) {
|
|
170
|
+
// var passedRuleQuestion = selectAll(state.questionArr).find(x => x.questionId == res.PassedRuleQuestionId);
|
|
171
|
+
// if (passedRuleQuestion) {
|
|
172
|
+
// const hasAnswerId = res.AnswerId !== null && res.AnswerId !== undefined;
|
|
173
|
+
// const hasAnswerText = res.AnswerText !== null && res.AnswerText !== undefined && res.AnswerText !== '';
|
|
174
|
+
// const hasAnswerIdArr = Array.isArray(res.AnswerIdArr) && res.AnswerIdArr?.length > 0;
|
|
175
|
+
// return hasAnswerId || hasAnswerText || hasAnswerIdArr;
|
|
176
|
+
// }
|
|
177
|
+
// }
|
|
178
|
+
// // Keep the item if at least one of them has a valid value
|
|
179
|
+
// return true;
|
|
180
|
+
// })
|
|
181
|
+
);
|
|
164
182
|
const questionSelectors = {
|
|
165
183
|
allQuestions,
|
|
166
184
|
pageQuestions,
|
|
@@ -2528,9 +2546,9 @@ const _surveyReducer = createReducer(initialSurveyState, on(surveyActions.loadSu
|
|
|
2528
2546
|
}, state.questionArr)
|
|
2529
2547
|
};
|
|
2530
2548
|
}), on(surveyActions.updateQuestionsShow, (state, props) => {
|
|
2531
|
-
const updates = props.
|
|
2532
|
-
id,
|
|
2533
|
-
changes: { isShow: props.isShow }
|
|
2549
|
+
const updates = props.questions.map(q => ({
|
|
2550
|
+
id: q.id,
|
|
2551
|
+
changes: { isShow: props.isShow, passedRuleQuestionId: q.passedRuleQuestionId }
|
|
2534
2552
|
}));
|
|
2535
2553
|
return {
|
|
2536
2554
|
...state,
|
|
@@ -2548,9 +2566,9 @@ const _surveyReducer = createReducer(initialSurveyState, on(surveyActions.loadSu
|
|
|
2548
2566
|
}, state.questionArr)
|
|
2549
2567
|
};
|
|
2550
2568
|
}), on(surveyActions.updateQuestionsDisable, (state, props) => {
|
|
2551
|
-
const updates = props.
|
|
2552
|
-
id,
|
|
2553
|
-
changes: { isDisabled: props.isDisabled }
|
|
2569
|
+
const updates = props.questions.map(q => ({
|
|
2570
|
+
id: q.id,
|
|
2571
|
+
changes: { isDisabled: props.isDisabled, passedRuleQuestionId: q.passedRuleQuestionId }
|
|
2554
2572
|
}));
|
|
2555
2573
|
return {
|
|
2556
2574
|
...state,
|
|
@@ -2627,18 +2645,22 @@ class SurveyEffects {
|
|
|
2627
2645
|
}).subscribe(result => {
|
|
2628
2646
|
var isPassed = result.exprestionResultArr.filter(x => x == false).length == 0;
|
|
2629
2647
|
if (isPassed) {
|
|
2648
|
+
var passedRuleQuestionId = null;
|
|
2649
|
+
if (rule.ruleExps?.length > 0) {
|
|
2650
|
+
passedRuleQuestionId = rule.ruleExps[0]?.questionId;
|
|
2651
|
+
}
|
|
2630
2652
|
rule.ruleResultQuestions.forEach(resultQuestion => {
|
|
2631
2653
|
if (rule.logicActionId == LogicActionEnum.Show) {
|
|
2632
|
-
toggleShowedQuestionIds.push({ questionId: resultQuestion.questionId, isShow: true });
|
|
2654
|
+
toggleShowedQuestionIds.push({ questionId: resultQuestion.questionId, isShow: true, passedRuleQuestionId });
|
|
2633
2655
|
}
|
|
2634
2656
|
else if (rule.logicActionId == LogicActionEnum.Hide) {
|
|
2635
|
-
toggleShowedQuestionIds.push({ questionId: resultQuestion.questionId, isShow: false });
|
|
2657
|
+
toggleShowedQuestionIds.push({ questionId: resultQuestion.questionId, isShow: false, passedRuleQuestionId });
|
|
2636
2658
|
}
|
|
2637
2659
|
else if (rule.logicActionId == LogicActionEnum.Enable) {
|
|
2638
|
-
toggleDisabledQuestionIds.push({ questionId: resultQuestion.questionId, isDisabled: false });
|
|
2660
|
+
toggleDisabledQuestionIds.push({ questionId: resultQuestion.questionId, isDisabled: false, passedRuleQuestionId });
|
|
2639
2661
|
}
|
|
2640
2662
|
else if (rule.logicActionId == LogicActionEnum.Disable) {
|
|
2641
|
-
toggleDisabledQuestionIds.push({ questionId: resultQuestion.questionId, isDisabled: true });
|
|
2663
|
+
toggleDisabledQuestionIds.push({ questionId: resultQuestion.questionId, isDisabled: true, passedRuleQuestionId });
|
|
2642
2664
|
}
|
|
2643
2665
|
else if (rule.logicActionId == LogicActionEnum.SetAnswer) {
|
|
2644
2666
|
}
|
|
@@ -2649,16 +2671,16 @@ class SurveyEffects {
|
|
|
2649
2671
|
var subQuestions = questionArr.filter(x => x.parentQuestionId == question.questionId);
|
|
2650
2672
|
subQuestions.forEach(subQuestion => {
|
|
2651
2673
|
if (rule.logicActionId == LogicActionEnum.Show) {
|
|
2652
|
-
toggleShowedQuestionIds.push({ questionId: subQuestion.questionId, isShow: true });
|
|
2674
|
+
toggleShowedQuestionIds.push({ questionId: subQuestion.questionId, isShow: true, passedRuleQuestionId });
|
|
2653
2675
|
}
|
|
2654
2676
|
else if (rule.logicActionId == LogicActionEnum.Hide) {
|
|
2655
|
-
toggleShowedQuestionIds.push({ questionId: subQuestion.questionId, isShow: false });
|
|
2677
|
+
toggleShowedQuestionIds.push({ questionId: subQuestion.questionId, isShow: false, passedRuleQuestionId });
|
|
2656
2678
|
}
|
|
2657
2679
|
else if (rule.logicActionId == LogicActionEnum.Enable) {
|
|
2658
|
-
toggleDisabledQuestionIds.push({ questionId: subQuestion.questionId, isDisabled: false });
|
|
2680
|
+
toggleDisabledQuestionIds.push({ questionId: subQuestion.questionId, isDisabled: false, passedRuleQuestionId });
|
|
2659
2681
|
}
|
|
2660
2682
|
else if (rule.logicActionId == LogicActionEnum.Disable) {
|
|
2661
|
-
toggleDisabledQuestionIds.push({ questionId: subQuestion.questionId, isDisabled: true });
|
|
2683
|
+
toggleDisabledQuestionIds.push({ questionId: subQuestion.questionId, isDisabled: true, passedRuleQuestionId });
|
|
2662
2684
|
}
|
|
2663
2685
|
});
|
|
2664
2686
|
}
|
|
@@ -2670,19 +2692,19 @@ class SurveyEffects {
|
|
|
2670
2692
|
const question = questionArr.find(x => x.questionId == resultQuestion.questionId);
|
|
2671
2693
|
if (question) {
|
|
2672
2694
|
if (question.isShow != question.isShow_default) {
|
|
2673
|
-
toggleShowedQuestionIds.push({ questionId: resultQuestion.questionId, isShow: question.isShow_default });
|
|
2695
|
+
toggleShowedQuestionIds.push({ questionId: resultQuestion.questionId, isShow: question.isShow_default, passedRuleQuestionId: null });
|
|
2674
2696
|
}
|
|
2675
2697
|
if (question.isDisabled != question.isDisabled_default) {
|
|
2676
|
-
toggleDisabledQuestionIds.push({ questionId: resultQuestion.questionId, isDisabled: question.isDisabled_default });
|
|
2698
|
+
toggleDisabledQuestionIds.push({ questionId: resultQuestion.questionId, isDisabled: question.isDisabled_default, passedRuleQuestionId: null });
|
|
2677
2699
|
}
|
|
2678
2700
|
if (question.questionType == QuestionTypeEnum.Matrix && question.isQuestionGroup == true) {
|
|
2679
2701
|
var subQuestions = questionArr.filter(x => x.parentQuestionId == question.questionId);
|
|
2680
2702
|
subQuestions.forEach(subQuestion => {
|
|
2681
2703
|
if (subQuestion.isShow != subQuestion.isShow_default) {
|
|
2682
|
-
toggleShowedQuestionIds.push({ questionId: subQuestion.questionId, isShow: subQuestion.isShow_default });
|
|
2704
|
+
toggleShowedQuestionIds.push({ questionId: subQuestion.questionId, isShow: subQuestion.isShow_default, passedRuleQuestionId: null });
|
|
2683
2705
|
}
|
|
2684
2706
|
if (subQuestion.isDisabled != subQuestion.isDisabled_default) {
|
|
2685
|
-
toggleDisabledQuestionIds.push({ questionId: subQuestion.questionId, isDisabled: question.isDisabled_default });
|
|
2707
|
+
toggleDisabledQuestionIds.push({ questionId: subQuestion.questionId, isDisabled: question.isDisabled_default, passedRuleQuestionId: null });
|
|
2686
2708
|
}
|
|
2687
2709
|
});
|
|
2688
2710
|
}
|
|
@@ -2691,31 +2713,51 @@ class SurveyEffects {
|
|
|
2691
2713
|
}
|
|
2692
2714
|
});
|
|
2693
2715
|
});
|
|
2694
|
-
const
|
|
2695
|
-
if (
|
|
2716
|
+
const hiddenQuestions = toggleShowedQuestionIds.filter(x => x.isShow == false);
|
|
2717
|
+
if (hiddenQuestions.length > 0) {
|
|
2696
2718
|
this._store.dispatch(surveyActions.updateQuestionsShow({
|
|
2697
|
-
|
|
2719
|
+
questions: hiddenQuestions.map(x => {
|
|
2720
|
+
return {
|
|
2721
|
+
id: x.questionId,
|
|
2722
|
+
passedRuleQuestionId: x.passedRuleQuestionId
|
|
2723
|
+
};
|
|
2724
|
+
}),
|
|
2698
2725
|
isShow: false
|
|
2699
2726
|
}));
|
|
2700
2727
|
}
|
|
2701
|
-
const
|
|
2702
|
-
if (
|
|
2728
|
+
const showedQuestions = toggleShowedQuestionIds.filter(x => x.isShow == true);
|
|
2729
|
+
if (showedQuestions.length > 0) {
|
|
2703
2730
|
this._store.dispatch(surveyActions.updateQuestionsShow({
|
|
2704
|
-
|
|
2731
|
+
questions: showedQuestions.map(x => {
|
|
2732
|
+
return {
|
|
2733
|
+
id: x.questionId,
|
|
2734
|
+
passedRuleQuestionId: x.passedRuleQuestionId
|
|
2735
|
+
};
|
|
2736
|
+
}),
|
|
2705
2737
|
isShow: true
|
|
2706
2738
|
}));
|
|
2707
2739
|
}
|
|
2708
|
-
const
|
|
2709
|
-
if (
|
|
2740
|
+
const disabledQuestions = toggleDisabledQuestionIds.filter(x => x.isDisabled == true);
|
|
2741
|
+
if (disabledQuestions.length > 0) {
|
|
2710
2742
|
this._store.dispatch(surveyActions.updateQuestionsDisable({
|
|
2711
|
-
|
|
2743
|
+
questions: disabledQuestions.map(x => {
|
|
2744
|
+
return {
|
|
2745
|
+
id: x.questionId,
|
|
2746
|
+
passedRuleQuestionId: x.passedRuleQuestionId
|
|
2747
|
+
};
|
|
2748
|
+
}),
|
|
2712
2749
|
isDisabled: true
|
|
2713
2750
|
}));
|
|
2714
2751
|
}
|
|
2715
|
-
const
|
|
2716
|
-
if (
|
|
2752
|
+
const enabledQuestions = toggleDisabledQuestionIds.filter(x => x.isDisabled == false);
|
|
2753
|
+
if (enabledQuestions.length > 0) {
|
|
2717
2754
|
this._store.dispatch(surveyActions.updateQuestionsDisable({
|
|
2718
|
-
|
|
2755
|
+
questions: enabledQuestions.map(x => {
|
|
2756
|
+
return {
|
|
2757
|
+
id: x.questionId,
|
|
2758
|
+
passedRuleQuestionId: x.passedRuleQuestionId
|
|
2759
|
+
};
|
|
2760
|
+
}),
|
|
2719
2761
|
isDisabled: false
|
|
2720
2762
|
}));
|
|
2721
2763
|
}
|