survery-lib 2.1.23 → 2.1.25
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/components/question-boolean-template/question-boolean-template.component.mjs +5 -1
- package/esm2022/lib/core/states/survey-store/survey.action.mjs +5 -1
- package/esm2022/lib/core/states/survey-store/survey.effect.mjs +55 -49
- package/esm2022/lib/core/states/survey-store/survey.reducer.mjs +19 -1
- package/fesm2022/survery-lib.mjs +80 -48
- package/fesm2022/survery-lib.mjs.map +1 -1
- package/lib/core/states/survey-store/survey.action.d.ts +14 -0
- package/package.json +1 -1
package/fesm2022/survery-lib.mjs
CHANGED
|
@@ -149,7 +149,9 @@ const addQuestion = createAction('[Survey library] Add Question', props());
|
|
|
149
149
|
const updateQuestionAnswer = createAction('[Survey library] Update Question Answer', props());
|
|
150
150
|
const updateInstitutionQuestionAnswer = createAction('[Survey library] Update Institution Question Answer', props());
|
|
151
151
|
const updateQuestionShow = createAction('[Survey library] Update Question Show', props());
|
|
152
|
+
const updateQuestionsShow = createAction('[Survey library] Update Questions Show', props());
|
|
152
153
|
const updateQuestionDisable = createAction('[Survey library] Update Question Disable', props());
|
|
154
|
+
const updateQuestionsDisable = createAction('[Survey library] Update Questions Disable', props());
|
|
153
155
|
const updateQuestionRequired = createAction('[Survey library] Update Question Required', props());
|
|
154
156
|
const removeQuestion = createAction('[Survey library] Remove Question', props());
|
|
155
157
|
const updatePageId = createAction('[Survey library] Update Page Id', props());
|
|
@@ -161,7 +163,9 @@ const surveyActions = {
|
|
|
161
163
|
updateQuestionAnswer,
|
|
162
164
|
updateInstitutionQuestionAnswer,
|
|
163
165
|
updateQuestionShow,
|
|
166
|
+
updateQuestionsShow,
|
|
164
167
|
updateQuestionDisable,
|
|
168
|
+
updateQuestionsDisable,
|
|
165
169
|
updateQuestionRequired,
|
|
166
170
|
removeQuestion,
|
|
167
171
|
updatePageId,
|
|
@@ -1352,6 +1356,10 @@ class QuestionBooleanTemplateComponent {
|
|
|
1352
1356
|
//updated answer
|
|
1353
1357
|
if (oldValue?.answerId != newValue?.answerId) {
|
|
1354
1358
|
this.fCtrls.answer.setValue(newValue?.answerId, { emitEvent: false });
|
|
1359
|
+
const groupIndex = this.fCtrls.answerArray.value.findIndex(x => x.id == newValue?.answerId);
|
|
1360
|
+
if (groupIndex > -1) {
|
|
1361
|
+
this.fCtrls.answerArray.at(groupIndex).controls.isSelected.setValue(true);
|
|
1362
|
+
}
|
|
1355
1363
|
}
|
|
1356
1364
|
//updated isDisabled
|
|
1357
1365
|
if (oldValue?.isDisabled != newValue?.isDisabled) {
|
|
@@ -2347,6 +2355,15 @@ const _surveyReducer = createReducer(initialSurveyState, on(surveyActions.loadSu
|
|
|
2347
2355
|
}
|
|
2348
2356
|
}, state.questionArr)
|
|
2349
2357
|
};
|
|
2358
|
+
}), on(surveyActions.updateQuestionsShow, (state, props) => {
|
|
2359
|
+
const updates = props.questionIds.map(id => ({
|
|
2360
|
+
id,
|
|
2361
|
+
changes: { isShow: props.isShow }
|
|
2362
|
+
}));
|
|
2363
|
+
return {
|
|
2364
|
+
...state,
|
|
2365
|
+
questionArr: questionAdapter.updateMany(updates, state.questionArr)
|
|
2366
|
+
};
|
|
2350
2367
|
}), on(surveyActions.updateQuestionDisable, (state, props) => {
|
|
2351
2368
|
const question = selectAll(state.questionArr).find(x => x.questionId == props.questionId);
|
|
2352
2369
|
return {
|
|
@@ -2358,6 +2375,15 @@ const _surveyReducer = createReducer(initialSurveyState, on(surveyActions.loadSu
|
|
|
2358
2375
|
}
|
|
2359
2376
|
}, state.questionArr)
|
|
2360
2377
|
};
|
|
2378
|
+
}), on(surveyActions.updateQuestionsDisable, (state, props) => {
|
|
2379
|
+
const updates = props.questionIds.map(id => ({
|
|
2380
|
+
id,
|
|
2381
|
+
changes: { isDisabled: props.isDisabled }
|
|
2382
|
+
}));
|
|
2383
|
+
return {
|
|
2384
|
+
...state,
|
|
2385
|
+
questionArr: questionAdapter.updateMany(updates, state.questionArr)
|
|
2386
|
+
};
|
|
2361
2387
|
}), on(surveyActions.updateQuestionRequired, (state, props) => {
|
|
2362
2388
|
const question = selectAll(state.questionArr).find(x => x.questionId == props.questionId);
|
|
2363
2389
|
return {
|
|
@@ -2416,6 +2442,8 @@ class SurveyEffects {
|
|
|
2416
2442
|
});
|
|
2417
2443
|
var selectedRuleIdArr = formatedRuleArr.filter(x => x.questionId == action.questionId).map(x => Number(x.ruleId));
|
|
2418
2444
|
var arr = ruleArr.filter(x => selectedRuleIdArr.find(c => c == x.ruleId) != null);
|
|
2445
|
+
var toggleShowedQuestionIds = [];
|
|
2446
|
+
var toggleDisabledQuestionIds = [];
|
|
2419
2447
|
arr.forEach(rule => {
|
|
2420
2448
|
this._checkRuleExpsUsecase.execute({
|
|
2421
2449
|
ruleExps: rule.ruleExps,
|
|
@@ -2425,28 +2453,16 @@ class SurveyEffects {
|
|
|
2425
2453
|
if (isPassed) {
|
|
2426
2454
|
rule.ruleResultQuestions.forEach(resultQuestion => {
|
|
2427
2455
|
if (rule.logicActionId == LogicActionEnum.Show) {
|
|
2428
|
-
|
|
2429
|
-
questionId: resultQuestion.questionId,
|
|
2430
|
-
isShow: true
|
|
2431
|
-
}));
|
|
2456
|
+
toggleShowedQuestionIds.push({ questionId: resultQuestion.questionId, isShow: true });
|
|
2432
2457
|
}
|
|
2433
2458
|
else if (rule.logicActionId == LogicActionEnum.Hide) {
|
|
2434
|
-
|
|
2435
|
-
questionId: resultQuestion.questionId,
|
|
2436
|
-
isShow: false
|
|
2437
|
-
}));
|
|
2459
|
+
toggleShowedQuestionIds.push({ questionId: resultQuestion.questionId, isShow: false });
|
|
2438
2460
|
}
|
|
2439
2461
|
else if (rule.logicActionId == LogicActionEnum.Enable) {
|
|
2440
|
-
|
|
2441
|
-
questionId: resultQuestion.questionId,
|
|
2442
|
-
isDisabled: false
|
|
2443
|
-
}));
|
|
2462
|
+
toggleDisabledQuestionIds.push({ questionId: resultQuestion.questionId, isDisabled: false });
|
|
2444
2463
|
}
|
|
2445
2464
|
else if (rule.logicActionId == LogicActionEnum.Disable) {
|
|
2446
|
-
|
|
2447
|
-
questionId: resultQuestion.questionId,
|
|
2448
|
-
isDisabled: true
|
|
2449
|
-
}));
|
|
2465
|
+
toggleDisabledQuestionIds.push({ questionId: resultQuestion.questionId, isDisabled: true });
|
|
2450
2466
|
}
|
|
2451
2467
|
else if (rule.logicActionId == LogicActionEnum.SetAnswer) {
|
|
2452
2468
|
}
|
|
@@ -2456,28 +2472,16 @@ class SurveyEffects {
|
|
|
2456
2472
|
var subQuestions = questionArr.filter(x => x.parentQuestionId == question.questionId);
|
|
2457
2473
|
subQuestions.forEach(subQuestion => {
|
|
2458
2474
|
if (rule.logicActionId == LogicActionEnum.Show) {
|
|
2459
|
-
|
|
2460
|
-
questionId: subQuestion.questionId,
|
|
2461
|
-
isShow: true
|
|
2462
|
-
}));
|
|
2475
|
+
toggleShowedQuestionIds.push({ questionId: subQuestion.questionId, isShow: true });
|
|
2463
2476
|
}
|
|
2464
2477
|
else if (rule.logicActionId == LogicActionEnum.Hide) {
|
|
2465
|
-
|
|
2466
|
-
questionId: subQuestion.questionId,
|
|
2467
|
-
isShow: false
|
|
2468
|
-
}));
|
|
2478
|
+
toggleShowedQuestionIds.push({ questionId: subQuestion.questionId, isShow: false });
|
|
2469
2479
|
}
|
|
2470
2480
|
else if (rule.logicActionId == LogicActionEnum.Enable) {
|
|
2471
|
-
|
|
2472
|
-
questionId: subQuestion.questionId,
|
|
2473
|
-
isDisabled: false
|
|
2474
|
-
}));
|
|
2481
|
+
toggleDisabledQuestionIds.push({ questionId: subQuestion.questionId, isDisabled: false });
|
|
2475
2482
|
}
|
|
2476
2483
|
else if (rule.logicActionId == LogicActionEnum.Disable) {
|
|
2477
|
-
|
|
2478
|
-
questionId: subQuestion.questionId,
|
|
2479
|
-
isDisabled: true
|
|
2480
|
-
}));
|
|
2484
|
+
toggleDisabledQuestionIds.push({ questionId: subQuestion.questionId, isDisabled: true });
|
|
2481
2485
|
}
|
|
2482
2486
|
});
|
|
2483
2487
|
}
|
|
@@ -2486,31 +2490,59 @@ class SurveyEffects {
|
|
|
2486
2490
|
else {
|
|
2487
2491
|
rule.ruleResultQuestions.forEach(resultQuestion => {
|
|
2488
2492
|
const question = questionArr.find(x => x.questionId == resultQuestion.questionId);
|
|
2489
|
-
|
|
2490
|
-
questionId: resultQuestion.questionId,
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
isDisabled: question.isDisabled_default
|
|
2496
|
-
}));
|
|
2493
|
+
if (question.isShow != question.isShow_default) {
|
|
2494
|
+
toggleShowedQuestionIds.push({ questionId: resultQuestion.questionId, isShow: question.isShow_default });
|
|
2495
|
+
}
|
|
2496
|
+
if (question.isDisabled != question.isDisabled_default) {
|
|
2497
|
+
toggleDisabledQuestionIds.push({ questionId: resultQuestion.questionId, isDisabled: question.isDisabled_default });
|
|
2498
|
+
}
|
|
2497
2499
|
if (question.questionType == QuestionTypeEnum.Matrix && question.isQuestionGroup == true) {
|
|
2498
2500
|
var subQuestions = questionArr.filter(x => x.parentQuestionId == question.questionId);
|
|
2499
2501
|
subQuestions.forEach(subQuestion => {
|
|
2500
|
-
|
|
2501
|
-
questionId: subQuestion.questionId,
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
isDisabled: question.isDisabled_default
|
|
2507
|
-
}));
|
|
2502
|
+
if (subQuestion.isShow != subQuestion.isShow_default) {
|
|
2503
|
+
toggleShowedQuestionIds.push({ questionId: subQuestion.questionId, isShow: subQuestion.isShow_default });
|
|
2504
|
+
}
|
|
2505
|
+
if (subQuestion.isDisabled != subQuestion.isDisabled_default) {
|
|
2506
|
+
toggleDisabledQuestionIds.push({ questionId: subQuestion.questionId, isDisabled: question.isDisabled_default });
|
|
2507
|
+
}
|
|
2508
2508
|
});
|
|
2509
2509
|
}
|
|
2510
2510
|
});
|
|
2511
2511
|
}
|
|
2512
2512
|
});
|
|
2513
2513
|
});
|
|
2514
|
+
const showedQuestionIds = toggleShowedQuestionIds.filter(x => x.isShow == true).map(x => x.questionId);
|
|
2515
|
+
if (showedQuestionIds.length > 0) {
|
|
2516
|
+
console.log('showedQuestionIds', showedQuestionIds);
|
|
2517
|
+
this._store.dispatch(surveyActions.updateQuestionsShow({
|
|
2518
|
+
questionIds: showedQuestionIds,
|
|
2519
|
+
isShow: true
|
|
2520
|
+
}));
|
|
2521
|
+
}
|
|
2522
|
+
const hiddenQuestionIds = toggleShowedQuestionIds.filter(x => x.isShow == false).map(x => x.questionId);
|
|
2523
|
+
if (hiddenQuestionIds.length > 0) {
|
|
2524
|
+
console.log('hiddenQuestionIds', hiddenQuestionIds);
|
|
2525
|
+
this._store.dispatch(surveyActions.updateQuestionsShow({
|
|
2526
|
+
questionIds: hiddenQuestionIds,
|
|
2527
|
+
isShow: false
|
|
2528
|
+
}));
|
|
2529
|
+
}
|
|
2530
|
+
const disabledQuestionIds = toggleDisabledQuestionIds.filter(x => x.isDisabled == true).map(x => x.questionId);
|
|
2531
|
+
if (disabledQuestionIds.length > 0) {
|
|
2532
|
+
console.log('disabledQuestionIds', disabledQuestionIds);
|
|
2533
|
+
this._store.dispatch(surveyActions.updateQuestionsDisable({
|
|
2534
|
+
questionIds: disabledQuestionIds,
|
|
2535
|
+
isDisabled: true
|
|
2536
|
+
}));
|
|
2537
|
+
}
|
|
2538
|
+
const enabledQuestionIds = toggleDisabledQuestionIds.filter(x => x.isDisabled == false).map(x => x.questionId);
|
|
2539
|
+
if (enabledQuestionIds.length > 0) {
|
|
2540
|
+
console.log('enabledQuestionIds', enabledQuestionIds);
|
|
2541
|
+
this._store.dispatch(surveyActions.updateQuestionsDisable({
|
|
2542
|
+
questionIds: enabledQuestionIds,
|
|
2543
|
+
isDisabled: false
|
|
2544
|
+
}));
|
|
2545
|
+
}
|
|
2514
2546
|
return of([]);
|
|
2515
2547
|
})), { dispatch: false });
|
|
2516
2548
|
this.loadInstitutionArr$ = createEffect(() => this._actions.pipe(ofType(surveyActions.loadInstitutionArr), withLatestFrom(this._store.select(surveySelectors.institutionArr)), filter(([action, institutionArr]) => institutionArr.length == 0), switchMap(() => {
|