survery-lib 2.1.43 → 2.1.45

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