survery-lib 2.1.21 → 2.1.24

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.
@@ -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,
@@ -684,6 +688,9 @@ class QuestionTextTemplateComponent {
684
688
  isDisabled: value.questionAllInfo.isReadOnly,
685
689
  isShow: value.questionAllInfo.isVisable
686
690
  });
691
+ if (value.isShow == true) {
692
+ this.fCtrls.isShow.setValue(value.isShow);
693
+ }
687
694
  if (value.questionAllInfo.surveyAnswers[0]?.answerId != null && value.questionAllInfo.surveyAnswers[0]?.answerId != undefined) {
688
695
  this.fCtrls.surveyAnswerId.setValue(value.questionAllInfo.surveyAnswers[0].answerId);
689
696
  this.fCtrls.inputTypeId.setValue(value.questionAllInfo.surveyAnswers[0].inputTypeId);
@@ -2039,11 +2046,11 @@ class QuestionInstitutionsTemplateComponent {
2039
2046
  });
2040
2047
  }
2041
2048
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionInstitutionsTemplateComponent, deps: [{ token: i3.Store }, { token: i1.FormBuilder }, { token: ApiService }], target: i0.ɵɵFactoryTarget.Component }); }
2042
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", type: QuestionInstitutionsTemplateComponent, selector: "lib-question-institutions-template", inputs: { isArabicLang: "isArabicLang", setQuestion: "setQuestion" }, ngImport: i0, template: "<div class=\"quastion\">\n <h3 class=\"quastion-title mb-2\">\n <span [innerHTML]=\"fCtrls.title.value\"></span>\n </h3>\n <ng-container *ngFor=\"let item of questionFormArray.controls; trackBy:identify ; let i = index\">\n <div class=\"quastion\" [attr.id]=\"'question_'+item.value.id\"\n *ngIf=\"item.value.level == 1 || ( item.value.level > 1 && item.value.answers.length > 0 )\"\n [ngClass]=\"{'invalid-question': item.controls.answerId.invalid , 'd-none':fCtrls.isShow.value != true}\">\n <h3 class=\"quastion-title \">\n <span [innerHTML]=\"item.value.title\"></span>\n <span style=\"color: red;\" *ngIf=\"fCtrls.isRequired\">*</span>\n </h3>\n <div class=\"text-quastion text-quastion__dropdown\">\n <ng-select [items]=\"item.value.level ==1 ? institutionsQuestionArr() : item.value.answers\" bindValue=\"id\" bindLabel=\"name\" class=\"form-control\"\n [formControl]=\"item.controls.answerId\" [virtualScroll]=\"true\" [disabled]=\"fCtrls.isDisabled.value\" (change)=\"onUpdateAnswer($event,i)\"\n [multiple]=\"false\">\n </ng-select>\n </div>\n </div>\n\n </ng-container>\n</div>\n\n", styles: [""], dependencies: [{ kind: "directive", type: i4.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: i5.NgSelectComponent, selector: "ng-select", inputs: ["bindLabel", "bindValue", "markFirst", "placeholder", "notFoundText", "typeToSearchText", "addTagText", "loadingText", "clearAllText", "appearance", "dropdownPosition", "appendTo", "loading", "closeOnSelect", "hideSelected", "selectOnTab", "openOnEnter", "maxSelectedItems", "groupBy", "groupValue", "bufferAmount", "virtualScroll", "selectableGroup", "selectableGroupAsModel", "searchFn", "trackByFn", "clearOnBackspace", "labelForId", "inputAttrs", "tabIndex", "readonly", "searchWhileComposing", "minTermLength", "editableSearchTerm", "keyDownFn", "typeahead", "multiple", "addTag", "searchable", "clearable", "isOpen", "items", "compareWith", "clearSearchOnAdd", "deselectOnClick"], outputs: ["blur", "focus", "change", "open", "close", "search", "clear", "add", "remove", "scroll", "scrollToEnd"] }] }); }
2049
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", type: QuestionInstitutionsTemplateComponent, selector: "lib-question-institutions-template", inputs: { isArabicLang: "isArabicLang", setQuestion: "setQuestion" }, ngImport: i0, template: "<div class=\"quastion\">\r\n <h3 class=\"quastion-title mb-2\">\r\n <span [innerHTML]=\"fCtrls.title.value\"></span>\r\n </h3>\r\n <ng-container *ngFor=\"let item of questionFormArray.controls; trackBy:identify ; let i = index\">\r\n <div class=\"quastion\" [attr.id]=\"'question_'+item.value.id\"\r\n *ngIf=\"item.value.level == 1 || ( item.value.level > 1 && item.value.answers.length > 0 )\"\r\n [ngClass]=\"{'invalid-question': item.controls.answerId.invalid , 'd-none':fCtrls.isShow.value != true}\">\r\n <h3 class=\"quastion-title \">\r\n <span [innerHTML]=\"item.value.title\"></span>\r\n <span style=\"color: red;\" *ngIf=\"fCtrls.isRequired\">*</span>\r\n </h3>\r\n <div class=\"text-quastion text-quastion__dropdown\">\r\n <ng-select [items]=\"item.value.level ==1 ? institutionsQuestionArr() : item.value.answers\" bindValue=\"id\" bindLabel=\"name\" class=\"form-control\"\r\n [formControl]=\"item.controls.answerId\" [virtualScroll]=\"true\" [disabled]=\"fCtrls.isDisabled.value\" (change)=\"onUpdateAnswer($event,i)\"\r\n [multiple]=\"false\">\r\n </ng-select>\r\n </div>\r\n </div>\r\n\r\n </ng-container>\r\n</div>\r\n\r\n", styles: [""], dependencies: [{ kind: "directive", type: i4.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: i5.NgSelectComponent, selector: "ng-select", inputs: ["bindLabel", "bindValue", "markFirst", "placeholder", "notFoundText", "typeToSearchText", "addTagText", "loadingText", "clearAllText", "appearance", "dropdownPosition", "appendTo", "loading", "closeOnSelect", "hideSelected", "selectOnTab", "openOnEnter", "maxSelectedItems", "groupBy", "groupValue", "bufferAmount", "virtualScroll", "selectableGroup", "selectableGroupAsModel", "searchFn", "trackByFn", "clearOnBackspace", "labelForId", "inputAttrs", "tabIndex", "readonly", "searchWhileComposing", "minTermLength", "editableSearchTerm", "keyDownFn", "typeahead", "multiple", "addTag", "searchable", "clearable", "isOpen", "items", "compareWith", "clearSearchOnAdd", "deselectOnClick"], outputs: ["blur", "focus", "change", "open", "close", "search", "clear", "add", "remove", "scroll", "scrollToEnd"] }] }); }
2043
2050
  }
2044
2051
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionInstitutionsTemplateComponent, decorators: [{
2045
2052
  type: Component,
2046
- args: [{ selector: 'lib-question-institutions-template', template: "<div class=\"quastion\">\n <h3 class=\"quastion-title mb-2\">\n <span [innerHTML]=\"fCtrls.title.value\"></span>\n </h3>\n <ng-container *ngFor=\"let item of questionFormArray.controls; trackBy:identify ; let i = index\">\n <div class=\"quastion\" [attr.id]=\"'question_'+item.value.id\"\n *ngIf=\"item.value.level == 1 || ( item.value.level > 1 && item.value.answers.length > 0 )\"\n [ngClass]=\"{'invalid-question': item.controls.answerId.invalid , 'd-none':fCtrls.isShow.value != true}\">\n <h3 class=\"quastion-title \">\n <span [innerHTML]=\"item.value.title\"></span>\n <span style=\"color: red;\" *ngIf=\"fCtrls.isRequired\">*</span>\n </h3>\n <div class=\"text-quastion text-quastion__dropdown\">\n <ng-select [items]=\"item.value.level ==1 ? institutionsQuestionArr() : item.value.answers\" bindValue=\"id\" bindLabel=\"name\" class=\"form-control\"\n [formControl]=\"item.controls.answerId\" [virtualScroll]=\"true\" [disabled]=\"fCtrls.isDisabled.value\" (change)=\"onUpdateAnswer($event,i)\"\n [multiple]=\"false\">\n </ng-select>\n </div>\n </div>\n\n </ng-container>\n</div>\n\n" }]
2053
+ args: [{ selector: 'lib-question-institutions-template', template: "<div class=\"quastion\">\r\n <h3 class=\"quastion-title mb-2\">\r\n <span [innerHTML]=\"fCtrls.title.value\"></span>\r\n </h3>\r\n <ng-container *ngFor=\"let item of questionFormArray.controls; trackBy:identify ; let i = index\">\r\n <div class=\"quastion\" [attr.id]=\"'question_'+item.value.id\"\r\n *ngIf=\"item.value.level == 1 || ( item.value.level > 1 && item.value.answers.length > 0 )\"\r\n [ngClass]=\"{'invalid-question': item.controls.answerId.invalid , 'd-none':fCtrls.isShow.value != true}\">\r\n <h3 class=\"quastion-title \">\r\n <span [innerHTML]=\"item.value.title\"></span>\r\n <span style=\"color: red;\" *ngIf=\"fCtrls.isRequired\">*</span>\r\n </h3>\r\n <div class=\"text-quastion text-quastion__dropdown\">\r\n <ng-select [items]=\"item.value.level ==1 ? institutionsQuestionArr() : item.value.answers\" bindValue=\"id\" bindLabel=\"name\" class=\"form-control\"\r\n [formControl]=\"item.controls.answerId\" [virtualScroll]=\"true\" [disabled]=\"fCtrls.isDisabled.value\" (change)=\"onUpdateAnswer($event,i)\"\r\n [multiple]=\"false\">\r\n </ng-select>\r\n </div>\r\n </div>\r\n\r\n </ng-container>\r\n</div>\r\n\r\n" }]
2047
2054
  }], ctorParameters: function () { return [{ type: i3.Store }, { type: i1.FormBuilder }, { type: ApiService }]; }, propDecorators: { isArabicLang: [{
2048
2055
  type: Input
2049
2056
  }], setQuestion: [{
@@ -2344,6 +2351,15 @@ const _surveyReducer = createReducer(initialSurveyState, on(surveyActions.loadSu
2344
2351
  }
2345
2352
  }, state.questionArr)
2346
2353
  };
2354
+ }), on(surveyActions.updateQuestionsShow, (state, props) => {
2355
+ const updates = props.questionIds.map(id => ({
2356
+ id,
2357
+ changes: { isShow: props.isShow }
2358
+ }));
2359
+ return {
2360
+ ...state,
2361
+ questionArr: questionAdapter.updateMany(updates, state.questionArr)
2362
+ };
2347
2363
  }), on(surveyActions.updateQuestionDisable, (state, props) => {
2348
2364
  const question = selectAll(state.questionArr).find(x => x.questionId == props.questionId);
2349
2365
  return {
@@ -2355,6 +2371,15 @@ const _surveyReducer = createReducer(initialSurveyState, on(surveyActions.loadSu
2355
2371
  }
2356
2372
  }, state.questionArr)
2357
2373
  };
2374
+ }), on(surveyActions.updateQuestionsDisable, (state, props) => {
2375
+ const updates = props.questionIds.map(id => ({
2376
+ id,
2377
+ changes: { isDisabled: props.isDisabled }
2378
+ }));
2379
+ return {
2380
+ ...state,
2381
+ questionArr: questionAdapter.updateMany(updates, state.questionArr)
2382
+ };
2358
2383
  }), on(surveyActions.updateQuestionRequired, (state, props) => {
2359
2384
  const question = selectAll(state.questionArr).find(x => x.questionId == props.questionId);
2360
2385
  return {
@@ -2413,6 +2438,8 @@ class SurveyEffects {
2413
2438
  });
2414
2439
  var selectedRuleIdArr = formatedRuleArr.filter(x => x.questionId == action.questionId).map(x => Number(x.ruleId));
2415
2440
  var arr = ruleArr.filter(x => selectedRuleIdArr.find(c => c == x.ruleId) != null);
2441
+ var toggleShowedQuestionIds = [];
2442
+ var toggleDisabledQuestionIds = [];
2416
2443
  arr.forEach(rule => {
2417
2444
  this._checkRuleExpsUsecase.execute({
2418
2445
  ruleExps: rule.ruleExps,
@@ -2422,28 +2449,16 @@ class SurveyEffects {
2422
2449
  if (isPassed) {
2423
2450
  rule.ruleResultQuestions.forEach(resultQuestion => {
2424
2451
  if (rule.logicActionId == LogicActionEnum.Show) {
2425
- this._store.dispatch(surveyActions.updateQuestionShow({
2426
- questionId: resultQuestion.questionId,
2427
- isShow: true
2428
- }));
2452
+ toggleShowedQuestionIds.push({ questionId: resultQuestion.questionId, isShow: true });
2429
2453
  }
2430
2454
  else if (rule.logicActionId == LogicActionEnum.Hide) {
2431
- this._store.dispatch(surveyActions.updateQuestionShow({
2432
- questionId: resultQuestion.questionId,
2433
- isShow: false
2434
- }));
2455
+ toggleShowedQuestionIds.push({ questionId: resultQuestion.questionId, isShow: false });
2435
2456
  }
2436
2457
  else if (rule.logicActionId == LogicActionEnum.Enable) {
2437
- this._store.dispatch(surveyActions.updateQuestionDisable({
2438
- questionId: resultQuestion.questionId,
2439
- isDisabled: false
2440
- }));
2458
+ toggleDisabledQuestionIds.push({ questionId: resultQuestion.questionId, isDisabled: false });
2441
2459
  }
2442
2460
  else if (rule.logicActionId == LogicActionEnum.Disable) {
2443
- this._store.dispatch(surveyActions.updateQuestionDisable({
2444
- questionId: resultQuestion.questionId,
2445
- isDisabled: true
2446
- }));
2461
+ toggleDisabledQuestionIds.push({ questionId: resultQuestion.questionId, isDisabled: true });
2447
2462
  }
2448
2463
  else if (rule.logicActionId == LogicActionEnum.SetAnswer) {
2449
2464
  }
@@ -2453,28 +2468,16 @@ class SurveyEffects {
2453
2468
  var subQuestions = questionArr.filter(x => x.parentQuestionId == question.questionId);
2454
2469
  subQuestions.forEach(subQuestion => {
2455
2470
  if (rule.logicActionId == LogicActionEnum.Show) {
2456
- this._store.dispatch(surveyActions.updateQuestionShow({
2457
- questionId: subQuestion.questionId,
2458
- isShow: true
2459
- }));
2471
+ toggleShowedQuestionIds.push({ questionId: subQuestion.questionId, isShow: true });
2460
2472
  }
2461
2473
  else if (rule.logicActionId == LogicActionEnum.Hide) {
2462
- this._store.dispatch(surveyActions.updateQuestionShow({
2463
- questionId: subQuestion.questionId,
2464
- isShow: false
2465
- }));
2474
+ toggleShowedQuestionIds.push({ questionId: subQuestion.questionId, isShow: false });
2466
2475
  }
2467
2476
  else if (rule.logicActionId == LogicActionEnum.Enable) {
2468
- this._store.dispatch(surveyActions.updateQuestionDisable({
2469
- questionId: subQuestion.questionId,
2470
- isDisabled: false
2471
- }));
2477
+ toggleDisabledQuestionIds.push({ questionId: subQuestion.questionId, isDisabled: false });
2472
2478
  }
2473
2479
  else if (rule.logicActionId == LogicActionEnum.Disable) {
2474
- this._store.dispatch(surveyActions.updateQuestionDisable({
2475
- questionId: subQuestion.questionId,
2476
- isDisabled: true
2477
- }));
2480
+ toggleDisabledQuestionIds.push({ questionId: subQuestion.questionId, isDisabled: true });
2478
2481
  }
2479
2482
  });
2480
2483
  }
@@ -2483,18 +2486,59 @@ class SurveyEffects {
2483
2486
  else {
2484
2487
  rule.ruleResultQuestions.forEach(resultQuestion => {
2485
2488
  const question = questionArr.find(x => x.questionId == resultQuestion.questionId);
2486
- this._store.dispatch(surveyActions.updateQuestionShow({
2487
- questionId: resultQuestion.questionId,
2488
- isShow: question.isShow_default
2489
- }));
2490
- this._store.dispatch(surveyActions.updateQuestionDisable({
2491
- questionId: resultQuestion.questionId,
2492
- isDisabled: question.isDisabled_default
2493
- }));
2489
+ if (question.isShow != question.isShow_default) {
2490
+ toggleShowedQuestionIds.push({ questionId: resultQuestion.questionId, isShow: question.isShow_default });
2491
+ }
2492
+ if (question.isDisabled != question.isDisabled_default) {
2493
+ toggleDisabledQuestionIds.push({ questionId: resultQuestion.questionId, isDisabled: question.isDisabled_default });
2494
+ }
2495
+ if (question.questionType == QuestionTypeEnum.Matrix && question.isQuestionGroup == true) {
2496
+ var subQuestions = questionArr.filter(x => x.parentQuestionId == question.questionId);
2497
+ subQuestions.forEach(subQuestion => {
2498
+ if (subQuestion.isShow != subQuestion.isShow_default) {
2499
+ toggleShowedQuestionIds.push({ questionId: subQuestion.questionId, isShow: subQuestion.isShow_default });
2500
+ }
2501
+ if (subQuestion.isDisabled != subQuestion.isDisabled_default) {
2502
+ toggleDisabledQuestionIds.push({ questionId: subQuestion.questionId, isDisabled: question.isDisabled_default });
2503
+ }
2504
+ });
2505
+ }
2494
2506
  });
2495
2507
  }
2496
2508
  });
2497
2509
  });
2510
+ const showedQuestionIds = toggleShowedQuestionIds.filter(x => x.isShow == true).map(x => x.questionId);
2511
+ if (showedQuestionIds.length > 0) {
2512
+ console.log('showedQuestionIds', showedQuestionIds);
2513
+ this._store.dispatch(surveyActions.updateQuestionsShow({
2514
+ questionIds: showedQuestionIds,
2515
+ isShow: true
2516
+ }));
2517
+ }
2518
+ const hiddenQuestionIds = toggleShowedQuestionIds.filter(x => x.isShow == false).map(x => x.questionId);
2519
+ if (hiddenQuestionIds.length > 0) {
2520
+ console.log('hiddenQuestionIds', hiddenQuestionIds);
2521
+ this._store.dispatch(surveyActions.updateQuestionsShow({
2522
+ questionIds: hiddenQuestionIds,
2523
+ isShow: false
2524
+ }));
2525
+ }
2526
+ const disabledQuestionIds = toggleDisabledQuestionIds.filter(x => x.isDisabled == true).map(x => x.questionId);
2527
+ if (disabledQuestionIds.length > 0) {
2528
+ console.log('disabledQuestionIds', disabledQuestionIds);
2529
+ this._store.dispatch(surveyActions.updateQuestionsDisable({
2530
+ questionIds: disabledQuestionIds,
2531
+ isDisabled: true
2532
+ }));
2533
+ }
2534
+ const enabledQuestionIds = toggleDisabledQuestionIds.filter(x => x.isDisabled == false).map(x => x.questionId);
2535
+ if (enabledQuestionIds.length > 0) {
2536
+ console.log('enabledQuestionIds', enabledQuestionIds);
2537
+ this._store.dispatch(surveyActions.updateQuestionsDisable({
2538
+ questionIds: enabledQuestionIds,
2539
+ isDisabled: false
2540
+ }));
2541
+ }
2498
2542
  return of([]);
2499
2543
  })), { dispatch: false });
2500
2544
  this.loadInstitutionArr$ = createEffect(() => this._actions.pipe(ofType(surveyActions.loadInstitutionArr), withLatestFrom(this._store.select(surveySelectors.institutionArr)), filter(([action, institutionArr]) => institutionArr.length == 0), switchMap(() => {