survery-lib 2.1.2 → 2.1.4

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.
Files changed (29) hide show
  1. package/esm2022/lib/components/question-boolean-template/question-boolean-template.component.mjs +7 -1
  2. package/esm2022/lib/components/question-cascade-template/question-cascade-template.component.mjs +4 -5
  3. package/esm2022/lib/components/question-check-box-template/question-check-box-template.component.mjs +6 -1
  4. package/esm2022/lib/components/question-dropdown-multi-template/question-dropdown-multi-template.component.mjs +6 -1
  5. package/esm2022/lib/components/question-dropdown-template/question-dropdown-template.component.mjs +13 -3
  6. package/esm2022/lib/components/question-feedback-template/question-feedback-template.component.mjs +6 -1
  7. package/esm2022/lib/components/question-matrix-template/question-matrix-template.component.mjs +6 -1
  8. package/esm2022/lib/components/question-radio-button-template/question-radio-button-template.component.mjs +7 -1
  9. package/esm2022/lib/components/question-text-template/question-text-template.component.mjs +10 -4
  10. package/esm2022/lib/core/states/survey-store/survey.effect.mjs +121 -0
  11. package/esm2022/lib/directives/masked-for-max-length.directive.mjs +35 -0
  12. package/esm2022/lib/survery-lib.component.mjs +8 -5
  13. package/esm2022/lib/survery-lib.module.mjs +9 -5
  14. package/fesm2022/survery-lib.mjs +221 -19
  15. package/fesm2022/survery-lib.mjs.map +1 -1
  16. package/lib/components/question-boolean-template/question-boolean-template.component.d.ts +1 -0
  17. package/lib/components/question-cascade-template/question-cascade-template.component.d.ts +1 -1
  18. package/lib/components/question-check-box-template/question-check-box-template.component.d.ts +1 -0
  19. package/lib/components/question-dropdown-multi-template/question-dropdown-multi-template.component.d.ts +1 -0
  20. package/lib/components/question-dropdown-template/question-dropdown-template.component.d.ts +6 -2
  21. package/lib/components/question-feedback-template/question-feedback-template.component.d.ts +1 -0
  22. package/lib/components/question-matrix-template/question-matrix-template.component.d.ts +1 -0
  23. package/lib/components/question-radio-button-template/question-radio-button-template.component.d.ts +1 -0
  24. package/lib/components/question-text-template/question-text-template.component.d.ts +1 -0
  25. package/lib/core/states/survey-store/survey.effect.d.ts +13 -0
  26. package/lib/directives/masked-for-max-length.directive.d.ts +6 -0
  27. package/lib/survery-lib.component.d.ts +4 -2
  28. package/lib/survery-lib.module.d.ts +10 -9
  29. package/package.json +3 -2
@@ -1,7 +1,7 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { Injectable, Directive, HostListener, Pipe, Component, Input, EventEmitter, Output, InjectionToken, Inject, NgModule } from '@angular/core';
3
3
  import { v4 } from 'uuid';
4
- import { Subject, of, debounceTime, distinctUntilChanged, map, filter, pairwise, take } from 'rxjs';
4
+ import { Subject, of, debounceTime, distinctUntilChanged, map, filter, pairwise, take, withLatestFrom, switchMap } from 'rxjs';
5
5
  import * as i1 from '@angular/forms';
6
6
  import { Validators, FormControl, ReactiveFormsModule, FormsModule } from '@angular/forms';
7
7
  import * as i3 from '@ngrx/store';
@@ -9,6 +9,7 @@ import { createFeatureSelector, createSelector, createAction, props, createReduc
9
9
  import { createEntityAdapter } from '@ngrx/entity';
10
10
  import * as i4 from '@angular/common';
11
11
  import { CommonModule } from '@angular/common';
12
+ import { SubSink } from 'subsink';
12
13
  import * as i5 from '@ng-select/ng-select';
13
14
  import { NgSelectModule } from '@ng-select/ng-select';
14
15
  import * as i1$1 from '@angular/common/http';
@@ -17,8 +18,8 @@ import * as i5$1 from 'ngx-bootstrap/rating';
17
18
  import { RatingModule } from 'ngx-bootstrap/rating';
18
19
  import * as i6 from 'ngx-bootstrap/pagination';
19
20
  import { PaginationModule } from 'ngx-bootstrap/pagination';
20
- import * as i2 from '@ngrx/effects';
21
- import { EffectsModule } from '@ngrx/effects';
21
+ import * as i1$2 from '@ngrx/effects';
22
+ import { createEffect, ofType, EffectsModule } from '@ngrx/effects';
22
23
 
23
24
  var QuestionTypeEnum;
24
25
  (function (QuestionTypeEnum) {
@@ -510,6 +511,39 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImpor
510
511
  args: ['keypress', ['$event']]
511
512
  }] } });
512
513
 
514
+ class MaskedForMaxLengthDirective {
515
+ onKeyUp(event) {
516
+ const input = event.target;
517
+ var max = null;
518
+ if (input.getAttribute('max') !== null) {
519
+ max = parseInt(input.getAttribute('max'));
520
+ }
521
+ var inputVlaue = input.value;
522
+ // allowed key array
523
+ if (max !== null) {
524
+ if (input.selectionStart != input.selectionEnd) {
525
+ let firstPart = input.value.slice(0, input.selectionStart);
526
+ let lastPart = input.value.slice(input.selectionEnd, input.value.length);
527
+ inputVlaue = Number(firstPart + event.key + lastPart);
528
+ }
529
+ if (inputVlaue.length + 1 > max) {
530
+ event.preventDefault();
531
+ }
532
+ }
533
+ }
534
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: MaskedForMaxLengthDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
535
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.7", type: MaskedForMaxLengthDirective, selector: "[libMaskedForMaxLength]", host: { listeners: { "keypress": "onKeyUp($event)" } }, ngImport: i0 }); }
536
+ }
537
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: MaskedForMaxLengthDirective, decorators: [{
538
+ type: Directive,
539
+ args: [{
540
+ selector: '[libMaskedForMaxLength]'
541
+ }]
542
+ }], propDecorators: { onKeyUp: [{
543
+ type: HostListener,
544
+ args: ['keypress', ['$event']]
545
+ }] } });
546
+
513
547
  class TextBoxTypeAttrPipe {
514
548
  transform(value, ...args) {
515
549
  if (value != null) {
@@ -625,6 +659,10 @@ class QuestionTextTemplateComponent {
625
659
  }
626
660
  this.fCtrls.answer.updateValueAndValidity();
627
661
  }
662
+ var question = this.questionArr().find(x => x.questionId == value.questionId);
663
+ if (question?.answerText) {
664
+ this.rForm.controls.answer.setValue(question.answerText, { emitEvent: false });
665
+ }
628
666
  this.toggleEnableAnswer(value.questionAllInfo.isReadOnly);
629
667
  }
630
668
  }
@@ -635,6 +673,7 @@ class QuestionTextTemplateComponent {
635
673
  this._formBuilder = _formBuilder;
636
674
  this._surveyLibService = _surveyLibService;
637
675
  this._Store = _Store;
676
+ this.questionArr = this._Store.selectSignal(questionSelectors.pageQuestions);
638
677
  this.isArabicLang = false;
639
678
  this.rForm = this._formBuilder.group({
640
679
  id: new FormControl(null),
@@ -709,11 +748,11 @@ class QuestionTextTemplateComponent {
709
748
  this.fCtrls.answer.updateValueAndValidity();
710
749
  }
711
750
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionTextTemplateComponent, deps: [{ token: i1.FormBuilder }, { token: SurveyLibService }, { token: i3.Store }], target: i0.ɵɵFactoryTarget.Component }); }
712
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", type: QuestionTextTemplateComponent, selector: "lib-question-text-template", inputs: { isArabicLang: "isArabicLang", setQuestion: "setQuestion", isDisabled: "isDisabled" }, ngImport: i0, template: "<div class=\"quastion\" [formGroup]=\"rForm\" [attr.id]=\"'question_'+fCtrls.id.value\"\r\n [ngClass]=\"{'invalid-question': fCtrls.answer.invalid , 'd-none':fCtrls.isShow.value != true}\">\r\n <h3 class=\"quastion-title \">\r\n <span [innerHTML]=\"surveyQuestion?.questionTitle\"></span>\r\n <span style=\"color: red;\" *ngIf=\"surveyQuestion.isRequired\">*</span>\r\n <p *ngIf=\"questionMinMaxIndicator\" class=\"text-danger\">\r\n <small >{{questionMinMaxIndicator}}</small>\r\n </p> \r\n </h3>\r\n <div class=\"text-quastion\">\r\n <ng-container *ngIf=\"isTextArea == false else textAreaTemplate\">\r\n <input class=\"form-control\" libMaskedForMinMax\r\n *ngIf=\"fCtrls.inputTypeId.value == inputTypeEnum.Number else inputTextTypeNumberTemplate\"\r\n [attr.min]=\"fCtrls.inputMin.value\" [attr.max]=\"fCtrls.inputMax.value\" [formControl]=\"convertToFormControl(fCtrls.answer)\"\r\n [disabled]=\"isDisabled\" [attr.type]=\"fCtrls.inputTypeId.value | textBoxTypeAttr\">\r\n </ng-container>\r\n <ng-template #textAreaTemplate>\r\n <textarea class=\"form-control\" rows=\"2\" [formControl]=\"convertToFormControl(fCtrls.answer)\"\r\n [disabled]=\"isDisabled\"></textarea>\r\n </ng-template>\r\n </div>\r\n\r\n <ng-template #inputTextTypeNumberTemplate>\r\n <input class=\"form-control\" [attr.min]=\"fCtrls.inputMin.value\"\r\n [attr.max]=\"fCtrls.inputMax.value\" [formControl]=\"convertToFormControl(fCtrls.answer)\"\r\n [disabled]=\"isDisabled\" [attr.type]=\"fCtrls.inputTypeId.value | textBoxTypeAttr\">\r\n </ng-template>", styles: [""], dependencies: [{ kind: "directive", type: i4.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: MaskedForMinMaxDirective, selector: "[libMaskedForMinMax]" }, { kind: "pipe", type: TextBoxTypeAttrPipe, name: "textBoxTypeAttr" }] }); }
751
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", type: QuestionTextTemplateComponent, selector: "lib-question-text-template", inputs: { isArabicLang: "isArabicLang", setQuestion: "setQuestion", isDisabled: "isDisabled" }, ngImport: i0, template: "<div class=\"quastion\" [formGroup]=\"rForm\" [attr.id]=\"'question_'+fCtrls.id.value\"\r\n [ngClass]=\"{'invalid-question': fCtrls.answer.invalid , 'd-none':fCtrls.isShow.value != true}\">\r\n <h3 class=\"quastion-title \">\r\n <span [innerHTML]=\"surveyQuestion?.questionTitle\"></span>\r\n <span style=\"color: red;\" *ngIf=\"surveyQuestion.isRequired\">*</span>\r\n <p *ngIf=\"questionMinMaxIndicator\" class=\"text-danger\">\r\n <small >{{questionMinMaxIndicator}}</small>\r\n </p> \r\n </h3>\r\n <div class=\"text-quastion\">\r\n <ng-container *ngIf=\"isTextArea == false else textAreaTemplate\">\r\n <input class=\"form-control\" libMaskedForMinMax\r\n *ngIf=\"fCtrls.inputTypeId.value == inputTypeEnum.Number else inputTextTypeNumberTemplate\"\r\n [attr.min]=\"fCtrls.inputMin.value\" [attr.max]=\"fCtrls.inputMax.value\" [formControl]=\"convertToFormControl(fCtrls.answer)\"\r\n [disabled]=\"isDisabled\" [attr.type]=\"fCtrls.inputTypeId.value | textBoxTypeAttr\">\r\n </ng-container>\r\n <ng-template #textAreaTemplate>\r\n <textarea class=\"form-control\" rows=\"2\" [formControl]=\"convertToFormControl(fCtrls.answer)\"\r\n [disabled]=\"isDisabled\"></textarea>\r\n </ng-template>\r\n </div>\r\n\r\n <ng-template #inputTextTypeNumberTemplate>\r\n <input class=\"form-control\" libMaskedForMaxLength \r\n [attr.max]=\"fCtrls.inputMax.value\" [formControl]=\"convertToFormControl(fCtrls.answer)\"\r\n [disabled]=\"isDisabled\" [attr.type]=\"fCtrls.inputTypeId.value | textBoxTypeAttr\">\r\n </ng-template>", styles: [""], dependencies: [{ kind: "directive", type: i4.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: MaskedForMinMaxDirective, selector: "[libMaskedForMinMax]" }, { kind: "directive", type: MaskedForMaxLengthDirective, selector: "[libMaskedForMaxLength]" }, { kind: "pipe", type: TextBoxTypeAttrPipe, name: "textBoxTypeAttr" }] }); }
713
752
  }
714
753
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionTextTemplateComponent, decorators: [{
715
754
  type: Component,
716
- args: [{ selector: 'lib-question-text-template', template: "<div class=\"quastion\" [formGroup]=\"rForm\" [attr.id]=\"'question_'+fCtrls.id.value\"\r\n [ngClass]=\"{'invalid-question': fCtrls.answer.invalid , 'd-none':fCtrls.isShow.value != true}\">\r\n <h3 class=\"quastion-title \">\r\n <span [innerHTML]=\"surveyQuestion?.questionTitle\"></span>\r\n <span style=\"color: red;\" *ngIf=\"surveyQuestion.isRequired\">*</span>\r\n <p *ngIf=\"questionMinMaxIndicator\" class=\"text-danger\">\r\n <small >{{questionMinMaxIndicator}}</small>\r\n </p> \r\n </h3>\r\n <div class=\"text-quastion\">\r\n <ng-container *ngIf=\"isTextArea == false else textAreaTemplate\">\r\n <input class=\"form-control\" libMaskedForMinMax\r\n *ngIf=\"fCtrls.inputTypeId.value == inputTypeEnum.Number else inputTextTypeNumberTemplate\"\r\n [attr.min]=\"fCtrls.inputMin.value\" [attr.max]=\"fCtrls.inputMax.value\" [formControl]=\"convertToFormControl(fCtrls.answer)\"\r\n [disabled]=\"isDisabled\" [attr.type]=\"fCtrls.inputTypeId.value | textBoxTypeAttr\">\r\n </ng-container>\r\n <ng-template #textAreaTemplate>\r\n <textarea class=\"form-control\" rows=\"2\" [formControl]=\"convertToFormControl(fCtrls.answer)\"\r\n [disabled]=\"isDisabled\"></textarea>\r\n </ng-template>\r\n </div>\r\n\r\n <ng-template #inputTextTypeNumberTemplate>\r\n <input class=\"form-control\" [attr.min]=\"fCtrls.inputMin.value\"\r\n [attr.max]=\"fCtrls.inputMax.value\" [formControl]=\"convertToFormControl(fCtrls.answer)\"\r\n [disabled]=\"isDisabled\" [attr.type]=\"fCtrls.inputTypeId.value | textBoxTypeAttr\">\r\n </ng-template>" }]
755
+ args: [{ selector: 'lib-question-text-template', template: "<div class=\"quastion\" [formGroup]=\"rForm\" [attr.id]=\"'question_'+fCtrls.id.value\"\r\n [ngClass]=\"{'invalid-question': fCtrls.answer.invalid , 'd-none':fCtrls.isShow.value != true}\">\r\n <h3 class=\"quastion-title \">\r\n <span [innerHTML]=\"surveyQuestion?.questionTitle\"></span>\r\n <span style=\"color: red;\" *ngIf=\"surveyQuestion.isRequired\">*</span>\r\n <p *ngIf=\"questionMinMaxIndicator\" class=\"text-danger\">\r\n <small >{{questionMinMaxIndicator}}</small>\r\n </p> \r\n </h3>\r\n <div class=\"text-quastion\">\r\n <ng-container *ngIf=\"isTextArea == false else textAreaTemplate\">\r\n <input class=\"form-control\" libMaskedForMinMax\r\n *ngIf=\"fCtrls.inputTypeId.value == inputTypeEnum.Number else inputTextTypeNumberTemplate\"\r\n [attr.min]=\"fCtrls.inputMin.value\" [attr.max]=\"fCtrls.inputMax.value\" [formControl]=\"convertToFormControl(fCtrls.answer)\"\r\n [disabled]=\"isDisabled\" [attr.type]=\"fCtrls.inputTypeId.value | textBoxTypeAttr\">\r\n </ng-container>\r\n <ng-template #textAreaTemplate>\r\n <textarea class=\"form-control\" rows=\"2\" [formControl]=\"convertToFormControl(fCtrls.answer)\"\r\n [disabled]=\"isDisabled\"></textarea>\r\n </ng-template>\r\n </div>\r\n\r\n <ng-template #inputTextTypeNumberTemplate>\r\n <input class=\"form-control\" libMaskedForMaxLength \r\n [attr.max]=\"fCtrls.inputMax.value\" [formControl]=\"convertToFormControl(fCtrls.answer)\"\r\n [disabled]=\"isDisabled\" [attr.type]=\"fCtrls.inputTypeId.value | textBoxTypeAttr\">\r\n </ng-template>" }]
717
756
  }], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: SurveyLibService }, { type: i3.Store }]; }, propDecorators: { isArabicLang: [{
718
757
  type: Input
719
758
  }], setQuestion: [{
@@ -752,6 +791,11 @@ class QuestionRadioButtonTemplateComponent {
752
791
  this.fCtrls.answer.addValidators([Validators.required]);
753
792
  this.fCtrls.answer.updateValueAndValidity();
754
793
  }
794
+ var question = this.questionArr().find(x => x.questionId == value.questionId);
795
+ if (question?.answerId) {
796
+ this.rForm.controls.answer.setValue(question.answerId, { emitEvent: false });
797
+ this.fCtrls.answerArray.controls.find(x => x.value.id == question.answerId).controls.isSelected.setValue(true);
798
+ }
755
799
  }
756
800
  }
757
801
  constructor(_formBuilder, _surveyLibService, _Store) {
@@ -759,6 +803,7 @@ class QuestionRadioButtonTemplateComponent {
759
803
  this._surveyLibService = _surveyLibService;
760
804
  this._Store = _Store;
761
805
  this.elemId = v4();
806
+ this.questionArr = this._Store.selectSignal(questionSelectors.pageQuestions);
762
807
  this.rForm = this._formBuilder.group({
763
808
  id: new FormControl(null),
764
809
  name: new FormControl(null),
@@ -851,6 +896,10 @@ class QuestionCheckBoxTemplateComponent {
851
896
  this.fCtrls.answer.addValidators([Validators.required]);
852
897
  this.fCtrls.answer.updateValueAndValidity();
853
898
  }
899
+ var question = this.questionArr().find(x => x.questionId == value.questionId);
900
+ if (question?.answerIdArr) {
901
+ this.rForm.controls.answer.setValue(question.answerIdArr, { emitEvent: false });
902
+ }
854
903
  }
855
904
  }
856
905
  constructor(_formBuilder, _surveyLibService, _Store) {
@@ -858,6 +907,7 @@ class QuestionCheckBoxTemplateComponent {
858
907
  this._surveyLibService = _surveyLibService;
859
908
  this._Store = _Store;
860
909
  this.elemId = v4();
910
+ this.questionArr = this._Store.selectSignal(questionSelectors.pageQuestions);
861
911
  this.rForm = this._formBuilder.group({
862
912
  id: new FormControl(null),
863
913
  name: new FormControl(null),
@@ -954,12 +1004,18 @@ class QuestionDropdownTemplateComponent {
954
1004
  this.fCtrls.answer.addValidators([Validators.required]);
955
1005
  this.fCtrls.answer.updateValueAndValidity();
956
1006
  }
1007
+ var question = this.questionArr().find(x => x.questionId == value.questionId);
1008
+ if (question?.answerId) {
1009
+ this.rForm.controls.answer.setValue(question.answerId, { emitEvent: false });
1010
+ }
957
1011
  }
958
1012
  }
959
1013
  constructor(_formBuilder, _surveyLibService, _Store) {
960
1014
  this._formBuilder = _formBuilder;
961
1015
  this._surveyLibService = _surveyLibService;
962
1016
  this._Store = _Store;
1017
+ this.subs = new SubSink();
1018
+ this.questionArr = this._Store.selectSignal(questionSelectors.pageQuestions);
963
1019
  this.emitter = new EventEmitter();
964
1020
  this.rForm = this._formBuilder.group({
965
1021
  id: new FormControl(null),
@@ -972,8 +1028,11 @@ class QuestionDropdownTemplateComponent {
972
1028
  isShow: new FormControl(true),
973
1029
  });
974
1030
  }
1031
+ ngOnDestroy() {
1032
+ this.subs.unsubscribe();
1033
+ }
975
1034
  ngOnInit() {
976
- this.fCtrls.answer.valueChanges.pipe().pipe(debounceTime(200), distinctUntilChanged()).subscribe(value => {
1035
+ this.subs.sink = this.fCtrls.answer.valueChanges.pipe().pipe(debounceTime(200), distinctUntilChanged()).subscribe(value => {
977
1036
  const formValue = this.rForm.value;
978
1037
  this._Store.dispatch(surveyActions.updateQuestionAnswer({
979
1038
  questionId: formValue.id,
@@ -986,7 +1045,7 @@ class QuestionDropdownTemplateComponent {
986
1045
  Answer: value
987
1046
  });
988
1047
  });
989
- this._Store.select(questionSelectors.pageQuestions).pipe(map(arr => arr.find(x => x.questionId == this.fCtrls.id.value)))
1048
+ this.subs.sink = this._Store.select(questionSelectors.pageQuestions).pipe(map(arr => arr.find(x => x.questionId == this.fCtrls.id.value)))
990
1049
  .pipe(filter(x => x != null), pairwise()).subscribe(value => {
991
1050
  const oldValue = value[0];
992
1051
  const newValue = value[1];
@@ -1056,6 +1115,10 @@ class QuestionMatrixTemplateComponent {
1056
1115
  isValid: group.controls.answer.valid
1057
1116
  }));
1058
1117
  });
1118
+ var question = this.questionArr().find(x => x.questionId == group.value.subQuestionId);
1119
+ if (question != null) {
1120
+ group.controls.answer.setValue(question.answerId, { emitEvent: false });
1121
+ }
1059
1122
  this.fCtrls.subQuestionArray.push(group);
1060
1123
  });
1061
1124
  }
@@ -1065,6 +1128,7 @@ class QuestionMatrixTemplateComponent {
1065
1128
  this._surveyLibService = _surveyLibService;
1066
1129
  this._Store = _Store;
1067
1130
  this.elemId = v4();
1131
+ this.questionArr = this._Store.selectSignal(questionSelectors.pageQuestions);
1068
1132
  this.rForm = this._formBuilder.group({
1069
1133
  id: new FormControl(null),
1070
1134
  typeId: new FormControl(null),
@@ -1154,6 +1218,11 @@ class QuestionBooleanTemplateComponent {
1154
1218
  this.fCtrls.answer.addValidators([Validators.required]);
1155
1219
  this.fCtrls.answer.updateValueAndValidity();
1156
1220
  }
1221
+ var question = this.questionArr().find(x => x.questionId == value.questionId);
1222
+ if (question?.answerId) {
1223
+ this.rForm.controls.answer.setValue(question.answerId, { emitEvent: false });
1224
+ this.fCtrls.answerArray.controls.find(x => x.value.id == question.answerId).controls.isSelected.setValue(true);
1225
+ }
1157
1226
  }
1158
1227
  }
1159
1228
  constructor(_formBuilder, _surveyLibService, _Store) {
@@ -1161,6 +1230,7 @@ class QuestionBooleanTemplateComponent {
1161
1230
  this._surveyLibService = _surveyLibService;
1162
1231
  this._Store = _Store;
1163
1232
  this.elemId = v4();
1233
+ this.questionArr = this._Store.selectSignal(questionSelectors.pageQuestions);
1164
1234
  this.rForm = this._formBuilder.group({
1165
1235
  id: new FormControl(null),
1166
1236
  name: new FormControl(null),
@@ -1249,6 +1319,10 @@ class QuestionDropdownMultiTemplateComponent {
1249
1319
  this.fCtrls.answer.addValidators([Validators.required]);
1250
1320
  this.fCtrls.answer.updateValueAndValidity();
1251
1321
  }
1322
+ var question = this.questionArr().find(x => x.questionId == value.questionId);
1323
+ if (question?.answerIdArr) {
1324
+ this.rForm.controls.answer.setValue(question.answerIdArr, { emitEvent: false });
1325
+ }
1252
1326
  }
1253
1327
  }
1254
1328
  constructor(_formBuilder, _surveyLibService, _Store) {
@@ -1256,6 +1330,7 @@ class QuestionDropdownMultiTemplateComponent {
1256
1330
  this._surveyLibService = _surveyLibService;
1257
1331
  this._Store = _Store;
1258
1332
  this.elemId = v4();
1333
+ this.questionArr = this._Store.selectSignal(questionSelectors.pageQuestions);
1259
1334
  this.rForm = this._formBuilder.group({
1260
1335
  id: new FormControl(null),
1261
1336
  name: new FormControl(null),
@@ -1375,7 +1450,7 @@ class QuestionCascadeTemplateComponent {
1375
1450
  this._ApiService = _ApiService;
1376
1451
  this._Store = _Store;
1377
1452
  this.surveyQuestionArr = [];
1378
- this.pageQuestions$ = this._Store.select(questionSelectors.pageQuestions);
1453
+ this.pageQuestions$ = this._Store.selectSignal(questionSelectors.pageQuestions);
1379
1454
  this.pageId = null;
1380
1455
  this.questionGroupId = null;
1381
1456
  this.isPre = false;
@@ -1453,14 +1528,13 @@ class QuestionCascadeTemplateComponent {
1453
1528
  group.controls.answer.updateValueAndValidity();
1454
1529
  }
1455
1530
  this.fCtrls.questionArr.push(group);
1456
- console.log(this.fCtrls.questionArr.value);
1457
1531
  }
1458
1532
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionCascadeTemplateComponent, deps: [{ token: i1.FormBuilder }, { token: SurveyLibService }, { token: ApiService }, { token: i3.Store }], target: i0.ɵɵFactoryTarget.Component }); }
1459
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", type: QuestionCascadeTemplateComponent, selector: "lib-question-cascade-template", inputs: { pageId: "pageId", questionGroupId: "questionGroupId", isPre: "isPre", surveyLanguageId: "surveyLanguageId", applicantKey: "applicantKey", setQuestion: "setQuestion" }, ngImport: i0, template: "<ng-container *ngFor=\"let item of questionFormArray.controls; trackBy:identify ; let i = index\">\r\n <lib-question-dropdown-template #questionDropdownTemplate [setQuestion]=\"(pageQuestions$ |async) |findQuestion :item.value.id \"\r\n (emitter)=\"onUpdateAnswer($event)\" >\r\n </lib-question-dropdown-template> \r\n</ng-container>", styles: [""], dependencies: [{ kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "component", type: QuestionDropdownTemplateComponent, selector: "lib-question-dropdown-template", inputs: ["setQuestion"], outputs: ["emitter"] }, { kind: "pipe", type: i4.AsyncPipe, name: "async" }, { kind: "pipe", type: FindQuestionPipe, name: "findQuestion" }] }); }
1533
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", type: QuestionCascadeTemplateComponent, selector: "lib-question-cascade-template", inputs: { pageId: "pageId", questionGroupId: "questionGroupId", isPre: "isPre", surveyLanguageId: "surveyLanguageId", applicantKey: "applicantKey", setQuestion: "setQuestion" }, ngImport: i0, template: "<ng-container *ngFor=\"let item of questionFormArray.controls; trackBy:identify ; let i = index\">\r\n <lib-question-dropdown-template #questionDropdownTemplate [setQuestion]=\"pageQuestions$() |findQuestion :item.value.id \"\r\n (emitter)=\"onUpdateAnswer($event)\" >\r\n </lib-question-dropdown-template> \r\n</ng-container>", styles: [""], dependencies: [{ kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "component", type: QuestionDropdownTemplateComponent, selector: "lib-question-dropdown-template", inputs: ["setQuestion"], outputs: ["emitter"] }, { kind: "pipe", type: FindQuestionPipe, name: "findQuestion" }] }); }
1460
1534
  }
1461
1535
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionCascadeTemplateComponent, decorators: [{
1462
1536
  type: Component,
1463
- args: [{ selector: 'lib-question-cascade-template', template: "<ng-container *ngFor=\"let item of questionFormArray.controls; trackBy:identify ; let i = index\">\r\n <lib-question-dropdown-template #questionDropdownTemplate [setQuestion]=\"(pageQuestions$ |async) |findQuestion :item.value.id \"\r\n (emitter)=\"onUpdateAnswer($event)\" >\r\n </lib-question-dropdown-template> \r\n</ng-container>" }]
1537
+ args: [{ selector: 'lib-question-cascade-template', template: "<ng-container *ngFor=\"let item of questionFormArray.controls; trackBy:identify ; let i = index\">\r\n <lib-question-dropdown-template #questionDropdownTemplate [setQuestion]=\"pageQuestions$() |findQuestion :item.value.id \"\r\n (emitter)=\"onUpdateAnswer($event)\" >\r\n </lib-question-dropdown-template> \r\n</ng-container>" }]
1464
1538
  }], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: SurveyLibService }, { type: ApiService }, { type: i3.Store }]; }, propDecorators: { pageId: [{
1465
1539
  type: Input
1466
1540
  }], questionGroupId: [{
@@ -1510,6 +1584,10 @@ class QuestionFeedbackTemplateComponent {
1510
1584
  this.fCtrls.answer.addValidators([Validators.required]);
1511
1585
  this.fCtrls.answer.updateValueAndValidity();
1512
1586
  }
1587
+ var question = this.questionArr().find(x => x.questionId == value.questionId);
1588
+ if (question?.answerText) {
1589
+ this.rForm.controls.answer.setValue(question.answerText, { emitEvent: false });
1590
+ }
1513
1591
  this.toggleEnableAnswer(value.questionAllInfo.isReadOnly);
1514
1592
  }
1515
1593
  }
@@ -1520,6 +1598,7 @@ class QuestionFeedbackTemplateComponent {
1520
1598
  this._formBuilder = _formBuilder;
1521
1599
  this._surveyLibService = _surveyLibService;
1522
1600
  this._Store = _Store;
1601
+ this.questionArr = this._Store.selectSignal(questionSelectors.pageQuestions);
1523
1602
  this.isArabicLang = false;
1524
1603
  this.rForm = this._formBuilder.group({
1525
1604
  id: new FormControl(null),
@@ -1628,8 +1707,8 @@ class SurveryLibComponent {
1628
1707
  this.surveryLibraryDivId = v4();
1629
1708
  this.reloadDefaultAnswerId = v4();
1630
1709
  this.questionAnswerArr = [];
1631
- this.pageQuestionGroups$ = this._Store.select(questionGroupSelectors.pageQuestionGroups);
1632
- this.pageQuestions$ = this._Store.select(questionSelectors.pageQuestions);
1710
+ this.pageQuestionGroups$ = this._Store.selectSignal(questionGroupSelectors.pageQuestionGroups);
1711
+ this.pageQuestions$ = this._Store.selectSignal(questionSelectors.pageQuestions);
1633
1712
  this.isFirstPage$ = this._Store.select(surveySelectors.isFirstPage);
1634
1713
  this.isLastPage$ = this._Store.select(surveySelectors.isLastPage);
1635
1714
  this.curruntShowedSurveyPages$ = this._Store.select(surveySelectors.selectedPageIndex).pipe(map(x => x + 1));
@@ -1652,6 +1731,9 @@ class SurveryLibComponent {
1652
1731
  questionIdentify(index, item) {
1653
1732
  return item.questionId;
1654
1733
  }
1734
+ questionGroupIdentify(index, item) {
1735
+ return item.questionGroupId;
1736
+ }
1655
1737
  ngOnInit() {
1656
1738
  this._Store.select(surveySelectors.selectedPageId).subscribe(value => {
1657
1739
  this.fCtrls.currentPageId.setValue(value);
@@ -1732,11 +1814,11 @@ class SurveryLibComponent {
1732
1814
  return null;
1733
1815
  }
1734
1816
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: SurveryLibComponent, deps: [{ token: SurveyLibService }, { token: i3.Store }, { token: i1.FormBuilder }, { token: CheckRuleExpsUsecase }], target: i0.ɵɵFactoryTarget.Component }); }
1735
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", type: SurveryLibComponent, selector: "lib-survery-lib", inputs: { isPre: "isPre", surveyLanguageId: "surveyLanguageId", applicantKey: "applicantKey", isArabicLang: "isArabicLang" }, outputs: { surveyResultEmit: "surveyResultEmit", selectLanguageEmit: "selectLanguageEmit" }, ngImport: i0, template: "<div id=\"survery-card-{{surveryLibraryDivId}}\" class=\"survay-card\">\r\n <div [attr.id]=\"'survey-page_'+fCtrls.currentPageId.value\">\r\n <ng-container *ngFor=\"let item of (pageQuestionGroups$ | async)\">\r\n <div class=\"survay-card\">\r\n <div class=\"survay-card-body\">\r\n <div class=\"survay-group\">\r\n <div class=\"title\">\r\n <h2 class=\"group-title\" [innerHTML]=\"item.questionGroupName\">\r\n </h2>\r\n <span class=\"group-sub-title \" [innerHTML]=\"item.questionGroupDescription\">\r\n </span>\r\n </div>\r\n <ng-container\r\n *ngFor=\"let question of ((pageQuestions$|async) |filterQuestion : item.questionGroupId); trackBy:questionIdentify\">\r\n <lib-question-boolean-template #questionBooleanTemplate [setQuestion]=\"question\"\r\n *ngIf=\"question.questionType == questionTypeEnum.Boolean\">\r\n </lib-question-boolean-template>\r\n\r\n <lib-question-text-template #questionTextTemplate [setQuestion]=\"question\"\r\n *ngIf=\"question.questionType == questionTypeEnum.TextInput\"\r\n [isArabicLang]=\"isArabicLang\"></lib-question-text-template>\r\n\r\n <lib-question-feedback-template #questionFeedTemplate [setQuestion]=\"question\"\r\n *ngIf=\"question.questionType == questionTypeEnum.FeedBack\"\r\n [isArabicLang]=\"isArabicLang\"></lib-question-feedback-template>\r\n\r\n <lib-question-radio-button-template #questionRadioButtonTemplate [setQuestion]=\"question\"\r\n *ngIf=\"question.questionType == questionTypeEnum.RadioButton\">\r\n </lib-question-radio-button-template>\r\n\r\n <lib-question-dropdown-template #questionDropdownTemplate [setQuestion]=\"question\"\r\n *ngIf=\"question.questionType == questionTypeEnum.DropDown\"></lib-question-dropdown-template>\r\n\r\n <lib-question-dropdown-multi-template [setQuestion]=\"question\"\r\n *ngIf=\"question.questionType == questionTypeEnum.DropDownMulti\">\r\n </lib-question-dropdown-multi-template>\r\n\r\n <lib-question-check-box-template #questionCheckBoxTemplate [setQuestion]=\"question\"\r\n *ngIf=\"question.questionType == questionTypeEnum.CheckBox\">\r\n </lib-question-check-box-template>\r\n\r\n <lib-question-matrix-template #questionMatrixTemplate [setQuestion]=\"question\"\r\n *ngIf=\"question.questionType == questionTypeEnum.Matrix\">\r\n </lib-question-matrix-template>\r\n\r\n <lib-question-cascade-template #questionCascadeTemplate [setQuestion]=\"question\"\r\n *ngIf=\"question.questionType == questionTypeEnum.Cascade\"\r\n [applicantKey]=\"applicantKey\" [isPre]=\"isPre\" [surveyLanguageId]=\"surveyLanguageId\"\r\n [pageId]=\"question.surveyPageId\" [questionGroupId]=\"question.questionGroupId\"></lib-question-cascade-template>\r\n </ng-container>\r\n </div>\r\n </div>\r\n </div>\r\n </ng-container>\r\n </div>\r\n <div class=\"survay-card-footr\" *ngIf=\"fCtrls.showedSurveyPages.value.length > 0\">\r\n <div class=\"container\" style=\" justify-content: start;\">\r\n <div class=\"survay-pagination fw-bold\">\r\n <span>{{ curruntShowedSurveyPages$ | async}}</span>\r\n <span class=\"ms-2 me-2\">{{isArabicLang ? '\u0645\u0646' : 'of'}} </span>\r\n <span>{{fCtrls.showedSurveyPages.value.length}}</span>\r\n </div>\r\n </div>\r\n </div>\r\n</div>", styles: [".disable__btn{background-color:gray!important;cursor:not-allowed}.quastion{padding:10px}.quastion .quastion-title{color:var(--dark-100, #363636);text-align:right;font-family:Almarai;font-size:18px;font-style:normal;font-weight:700;line-height:20.6px}\n"], dependencies: [{ kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: QuestionTextTemplateComponent, selector: "lib-question-text-template", inputs: ["isArabicLang", "setQuestion", "isDisabled"] }, { kind: "component", type: QuestionRadioButtonTemplateComponent, selector: "lib-question-radio-button-template", inputs: ["setQuestion"] }, { kind: "component", type: QuestionCheckBoxTemplateComponent, selector: "lib-question-check-box-template", inputs: ["setQuestion"] }, { kind: "component", type: QuestionDropdownTemplateComponent, selector: "lib-question-dropdown-template", inputs: ["setQuestion"], outputs: ["emitter"] }, { kind: "component", type: QuestionMatrixTemplateComponent, selector: "lib-question-matrix-template", inputs: ["setQuestion"] }, { kind: "component", type: QuestionBooleanTemplateComponent, selector: "lib-question-boolean-template", inputs: ["setQuestion"] }, { kind: "component", type: QuestionDropdownMultiTemplateComponent, selector: "lib-question-dropdown-multi-template", inputs: ["setQuestion"] }, { kind: "component", type: QuestionCascadeTemplateComponent, selector: "lib-question-cascade-template", inputs: ["pageId", "questionGroupId", "isPre", "surveyLanguageId", "applicantKey", "setQuestion"] }, { kind: "component", type: QuestionFeedbackTemplateComponent, selector: "lib-question-feedback-template", inputs: ["isArabicLang", "setQuestion", "isDisabled"] }, { kind: "pipe", type: i4.AsyncPipe, name: "async" }, { kind: "pipe", type: FilterQuestionPipe, name: "filterQuestion" }] }); }
1817
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", type: SurveryLibComponent, selector: "lib-survery-lib", inputs: { isPre: "isPre", surveyLanguageId: "surveyLanguageId", applicantKey: "applicantKey", isArabicLang: "isArabicLang" }, outputs: { surveyResultEmit: "surveyResultEmit", selectLanguageEmit: "selectLanguageEmit" }, ngImport: i0, template: "<div id=\"survery-card-{{surveryLibraryDivId}}\" class=\"survay-card\">\r\n <div [attr.id]=\"'survey-page_'+fCtrls.currentPageId.value\">\r\n <ng-container *ngFor=\"let item of pageQuestionGroups$(); trackBy:questionGroupIdentify\">\r\n <div class=\"survay-card\">\r\n <div class=\"survay-card-body\">\r\n <div class=\"survay-group\">\r\n <div class=\"title\">\r\n <h2 class=\"group-title\" [innerHTML]=\"item.questionGroupName\">\r\n </h2>\r\n <span class=\"group-sub-title \" [innerHTML]=\"item.questionGroupDescription\">\r\n </span>\r\n </div>\r\n <ng-container\r\n *ngFor=\"let question of (pageQuestions$() |filterQuestion : item.questionGroupId); trackBy:questionIdentify\">\r\n <lib-question-boolean-template #questionBooleanTemplate [setQuestion]=\"question\"\r\n *ngIf=\"question.questionType == questionTypeEnum.Boolean\">\r\n </lib-question-boolean-template>\r\n\r\n <lib-question-text-template #questionTextTemplate [setQuestion]=\"question\"\r\n *ngIf=\"question.questionType == questionTypeEnum.TextInput\"\r\n [isArabicLang]=\"isArabicLang\"></lib-question-text-template>\r\n\r\n <lib-question-feedback-template #questionFeedTemplate [setQuestion]=\"question\"\r\n *ngIf=\"question.questionType == questionTypeEnum.FeedBack\"\r\n [isArabicLang]=\"isArabicLang\"></lib-question-feedback-template>\r\n\r\n <lib-question-radio-button-template #questionRadioButtonTemplate [setQuestion]=\"question\"\r\n *ngIf=\"question.questionType == questionTypeEnum.RadioButton\">\r\n </lib-question-radio-button-template>\r\n\r\n <lib-question-dropdown-template #questionDropdownTemplate [setQuestion]=\"question\"\r\n *ngIf=\"question.questionType == questionTypeEnum.DropDown\"></lib-question-dropdown-template>\r\n\r\n <lib-question-dropdown-multi-template [setQuestion]=\"question\"\r\n *ngIf=\"question.questionType == questionTypeEnum.DropDownMulti\">\r\n </lib-question-dropdown-multi-template>\r\n\r\n <lib-question-check-box-template #questionCheckBoxTemplate [setQuestion]=\"question\"\r\n *ngIf=\"question.questionType == questionTypeEnum.CheckBox\">\r\n </lib-question-check-box-template>\r\n\r\n <lib-question-matrix-template #questionMatrixTemplate [setQuestion]=\"question\"\r\n *ngIf=\"question.questionType == questionTypeEnum.Matrix\">\r\n </lib-question-matrix-template>\r\n\r\n <lib-question-cascade-template #questionCascadeTemplate [setQuestion]=\"question\"\r\n *ngIf=\"question.questionType == questionTypeEnum.Cascade\"\r\n [applicantKey]=\"applicantKey\" [isPre]=\"isPre\" [surveyLanguageId]=\"surveyLanguageId\"\r\n [pageId]=\"question.surveyPageId\" [questionGroupId]=\"question.questionGroupId\"></lib-question-cascade-template>\r\n </ng-container>\r\n </div>\r\n </div>\r\n </div>\r\n </ng-container>\r\n </div>\r\n <div class=\"survay-card-footr\" *ngIf=\"fCtrls.showedSurveyPages.value.length > 0\">\r\n <div class=\"container\" style=\" justify-content: start;\">\r\n <div class=\"survay-pagination fw-bold\">\r\n <span>{{ curruntShowedSurveyPages$ | async}}</span>\r\n <span class=\"ms-2 me-2\">{{isArabicLang ? '\u0645\u0646' : 'of'}} </span>\r\n <span>{{fCtrls.showedSurveyPages.value.length}}</span>\r\n </div>\r\n </div>\r\n </div>\r\n</div>", styles: [".disable__btn{background-color:gray!important;cursor:not-allowed}.quastion{padding:10px}.quastion .quastion-title{color:var(--dark-100, #363636);text-align:right;font-family:Almarai;font-size:18px;font-style:normal;font-weight:700;line-height:20.6px}\n"], dependencies: [{ kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: QuestionTextTemplateComponent, selector: "lib-question-text-template", inputs: ["isArabicLang", "setQuestion", "isDisabled"] }, { kind: "component", type: QuestionRadioButtonTemplateComponent, selector: "lib-question-radio-button-template", inputs: ["setQuestion"] }, { kind: "component", type: QuestionCheckBoxTemplateComponent, selector: "lib-question-check-box-template", inputs: ["setQuestion"] }, { kind: "component", type: QuestionDropdownTemplateComponent, selector: "lib-question-dropdown-template", inputs: ["setQuestion"], outputs: ["emitter"] }, { kind: "component", type: QuestionMatrixTemplateComponent, selector: "lib-question-matrix-template", inputs: ["setQuestion"] }, { kind: "component", type: QuestionBooleanTemplateComponent, selector: "lib-question-boolean-template", inputs: ["setQuestion"] }, { kind: "component", type: QuestionDropdownMultiTemplateComponent, selector: "lib-question-dropdown-multi-template", inputs: ["setQuestion"] }, { kind: "component", type: QuestionCascadeTemplateComponent, selector: "lib-question-cascade-template", inputs: ["pageId", "questionGroupId", "isPre", "surveyLanguageId", "applicantKey", "setQuestion"] }, { kind: "component", type: QuestionFeedbackTemplateComponent, selector: "lib-question-feedback-template", inputs: ["isArabicLang", "setQuestion", "isDisabled"] }, { kind: "pipe", type: i4.AsyncPipe, name: "async" }, { kind: "pipe", type: FilterQuestionPipe, name: "filterQuestion" }] }); }
1736
1818
  }
1737
1819
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: SurveryLibComponent, decorators: [{
1738
1820
  type: Component,
1739
- args: [{ selector: 'lib-survery-lib', template: "<div id=\"survery-card-{{surveryLibraryDivId}}\" class=\"survay-card\">\r\n <div [attr.id]=\"'survey-page_'+fCtrls.currentPageId.value\">\r\n <ng-container *ngFor=\"let item of (pageQuestionGroups$ | async)\">\r\n <div class=\"survay-card\">\r\n <div class=\"survay-card-body\">\r\n <div class=\"survay-group\">\r\n <div class=\"title\">\r\n <h2 class=\"group-title\" [innerHTML]=\"item.questionGroupName\">\r\n </h2>\r\n <span class=\"group-sub-title \" [innerHTML]=\"item.questionGroupDescription\">\r\n </span>\r\n </div>\r\n <ng-container\r\n *ngFor=\"let question of ((pageQuestions$|async) |filterQuestion : item.questionGroupId); trackBy:questionIdentify\">\r\n <lib-question-boolean-template #questionBooleanTemplate [setQuestion]=\"question\"\r\n *ngIf=\"question.questionType == questionTypeEnum.Boolean\">\r\n </lib-question-boolean-template>\r\n\r\n <lib-question-text-template #questionTextTemplate [setQuestion]=\"question\"\r\n *ngIf=\"question.questionType == questionTypeEnum.TextInput\"\r\n [isArabicLang]=\"isArabicLang\"></lib-question-text-template>\r\n\r\n <lib-question-feedback-template #questionFeedTemplate [setQuestion]=\"question\"\r\n *ngIf=\"question.questionType == questionTypeEnum.FeedBack\"\r\n [isArabicLang]=\"isArabicLang\"></lib-question-feedback-template>\r\n\r\n <lib-question-radio-button-template #questionRadioButtonTemplate [setQuestion]=\"question\"\r\n *ngIf=\"question.questionType == questionTypeEnum.RadioButton\">\r\n </lib-question-radio-button-template>\r\n\r\n <lib-question-dropdown-template #questionDropdownTemplate [setQuestion]=\"question\"\r\n *ngIf=\"question.questionType == questionTypeEnum.DropDown\"></lib-question-dropdown-template>\r\n\r\n <lib-question-dropdown-multi-template [setQuestion]=\"question\"\r\n *ngIf=\"question.questionType == questionTypeEnum.DropDownMulti\">\r\n </lib-question-dropdown-multi-template>\r\n\r\n <lib-question-check-box-template #questionCheckBoxTemplate [setQuestion]=\"question\"\r\n *ngIf=\"question.questionType == questionTypeEnum.CheckBox\">\r\n </lib-question-check-box-template>\r\n\r\n <lib-question-matrix-template #questionMatrixTemplate [setQuestion]=\"question\"\r\n *ngIf=\"question.questionType == questionTypeEnum.Matrix\">\r\n </lib-question-matrix-template>\r\n\r\n <lib-question-cascade-template #questionCascadeTemplate [setQuestion]=\"question\"\r\n *ngIf=\"question.questionType == questionTypeEnum.Cascade\"\r\n [applicantKey]=\"applicantKey\" [isPre]=\"isPre\" [surveyLanguageId]=\"surveyLanguageId\"\r\n [pageId]=\"question.surveyPageId\" [questionGroupId]=\"question.questionGroupId\"></lib-question-cascade-template>\r\n </ng-container>\r\n </div>\r\n </div>\r\n </div>\r\n </ng-container>\r\n </div>\r\n <div class=\"survay-card-footr\" *ngIf=\"fCtrls.showedSurveyPages.value.length > 0\">\r\n <div class=\"container\" style=\" justify-content: start;\">\r\n <div class=\"survay-pagination fw-bold\">\r\n <span>{{ curruntShowedSurveyPages$ | async}}</span>\r\n <span class=\"ms-2 me-2\">{{isArabicLang ? '\u0645\u0646' : 'of'}} </span>\r\n <span>{{fCtrls.showedSurveyPages.value.length}}</span>\r\n </div>\r\n </div>\r\n </div>\r\n</div>", styles: [".disable__btn{background-color:gray!important;cursor:not-allowed}.quastion{padding:10px}.quastion .quastion-title{color:var(--dark-100, #363636);text-align:right;font-family:Almarai;font-size:18px;font-style:normal;font-weight:700;line-height:20.6px}\n"] }]
1821
+ args: [{ selector: 'lib-survery-lib', template: "<div id=\"survery-card-{{surveryLibraryDivId}}\" class=\"survay-card\">\r\n <div [attr.id]=\"'survey-page_'+fCtrls.currentPageId.value\">\r\n <ng-container *ngFor=\"let item of pageQuestionGroups$(); trackBy:questionGroupIdentify\">\r\n <div class=\"survay-card\">\r\n <div class=\"survay-card-body\">\r\n <div class=\"survay-group\">\r\n <div class=\"title\">\r\n <h2 class=\"group-title\" [innerHTML]=\"item.questionGroupName\">\r\n </h2>\r\n <span class=\"group-sub-title \" [innerHTML]=\"item.questionGroupDescription\">\r\n </span>\r\n </div>\r\n <ng-container\r\n *ngFor=\"let question of (pageQuestions$() |filterQuestion : item.questionGroupId); trackBy:questionIdentify\">\r\n <lib-question-boolean-template #questionBooleanTemplate [setQuestion]=\"question\"\r\n *ngIf=\"question.questionType == questionTypeEnum.Boolean\">\r\n </lib-question-boolean-template>\r\n\r\n <lib-question-text-template #questionTextTemplate [setQuestion]=\"question\"\r\n *ngIf=\"question.questionType == questionTypeEnum.TextInput\"\r\n [isArabicLang]=\"isArabicLang\"></lib-question-text-template>\r\n\r\n <lib-question-feedback-template #questionFeedTemplate [setQuestion]=\"question\"\r\n *ngIf=\"question.questionType == questionTypeEnum.FeedBack\"\r\n [isArabicLang]=\"isArabicLang\"></lib-question-feedback-template>\r\n\r\n <lib-question-radio-button-template #questionRadioButtonTemplate [setQuestion]=\"question\"\r\n *ngIf=\"question.questionType == questionTypeEnum.RadioButton\">\r\n </lib-question-radio-button-template>\r\n\r\n <lib-question-dropdown-template #questionDropdownTemplate [setQuestion]=\"question\"\r\n *ngIf=\"question.questionType == questionTypeEnum.DropDown\"></lib-question-dropdown-template>\r\n\r\n <lib-question-dropdown-multi-template [setQuestion]=\"question\"\r\n *ngIf=\"question.questionType == questionTypeEnum.DropDownMulti\">\r\n </lib-question-dropdown-multi-template>\r\n\r\n <lib-question-check-box-template #questionCheckBoxTemplate [setQuestion]=\"question\"\r\n *ngIf=\"question.questionType == questionTypeEnum.CheckBox\">\r\n </lib-question-check-box-template>\r\n\r\n <lib-question-matrix-template #questionMatrixTemplate [setQuestion]=\"question\"\r\n *ngIf=\"question.questionType == questionTypeEnum.Matrix\">\r\n </lib-question-matrix-template>\r\n\r\n <lib-question-cascade-template #questionCascadeTemplate [setQuestion]=\"question\"\r\n *ngIf=\"question.questionType == questionTypeEnum.Cascade\"\r\n [applicantKey]=\"applicantKey\" [isPre]=\"isPre\" [surveyLanguageId]=\"surveyLanguageId\"\r\n [pageId]=\"question.surveyPageId\" [questionGroupId]=\"question.questionGroupId\"></lib-question-cascade-template>\r\n </ng-container>\r\n </div>\r\n </div>\r\n </div>\r\n </ng-container>\r\n </div>\r\n <div class=\"survay-card-footr\" *ngIf=\"fCtrls.showedSurveyPages.value.length > 0\">\r\n <div class=\"container\" style=\" justify-content: start;\">\r\n <div class=\"survay-pagination fw-bold\">\r\n <span>{{ curruntShowedSurveyPages$ | async}}</span>\r\n <span class=\"ms-2 me-2\">{{isArabicLang ? '\u0645\u0646' : 'of'}} </span>\r\n <span>{{fCtrls.showedSurveyPages.value.length}}</span>\r\n </div>\r\n </div>\r\n </div>\r\n</div>", styles: [".disable__btn{background-color:gray!important;cursor:not-allowed}.quastion{padding:10px}.quastion .quastion-title{color:var(--dark-100, #363636);text-align:right;font-family:Almarai;font-size:18px;font-style:normal;font-weight:700;line-height:20.6px}\n"] }]
1740
1822
  }], ctorParameters: function () { return [{ type: SurveyLibService }, { type: i3.Store }, { type: i1.FormBuilder }, { type: CheckRuleExpsUsecase }]; }, propDecorators: { isPre: [{
1741
1823
  type: Input
1742
1824
  }], surveyLanguageId: [{
@@ -1881,6 +1963,124 @@ function surveyReducer(state, action) {
1881
1963
  return _surveyReducer(state, action);
1882
1964
  }
1883
1965
 
1966
+ var LogicActionEnum;
1967
+ (function (LogicActionEnum) {
1968
+ LogicActionEnum[LogicActionEnum["Show"] = 1] = "Show";
1969
+ LogicActionEnum[LogicActionEnum["Hide"] = 2] = "Hide";
1970
+ LogicActionEnum[LogicActionEnum["Enable"] = 3] = "Enable";
1971
+ LogicActionEnum[LogicActionEnum["Disable"] = 4] = "Disable";
1972
+ LogicActionEnum[LogicActionEnum["SetAnswer"] = 5] = "SetAnswer";
1973
+ })(LogicActionEnum || (LogicActionEnum = {}));
1974
+
1975
+ class SurveyEffects {
1976
+ constructor(_actions, _store, _checkRuleExpsUsecase) {
1977
+ this._actions = _actions;
1978
+ this._store = _store;
1979
+ this._checkRuleExpsUsecase = _checkRuleExpsUsecase;
1980
+ this.updateQuestionAnswer$ = createEffect(() => this._actions.pipe(ofType(surveyActions.updateQuestionAnswer), withLatestFrom(this._store.select(surveySelectors.ruleArr), this._store.select(questionSelectors.allQuestions)), switchMap(([action, ruleArr, questionArr]) => {
1981
+ var formatedRuleArr = [];
1982
+ ruleArr.forEach(rule => {
1983
+ rule.ruleExps.forEach(ruleQuestion => {
1984
+ formatedRuleArr.push({
1985
+ ruleId: rule.ruleId,
1986
+ questionId: ruleQuestion.questionId
1987
+ });
1988
+ });
1989
+ });
1990
+ var selectedRuleIdArr = formatedRuleArr.filter(x => x.questionId == action.questionId).map(x => Number(x.ruleId));
1991
+ var arr = ruleArr.filter(x => selectedRuleIdArr.find(c => c == x.ruleId) != null);
1992
+ arr.forEach(rule => {
1993
+ this._checkRuleExpsUsecase.execute({
1994
+ ruleExps: rule.ruleExps,
1995
+ questions: questionArr,
1996
+ }).subscribe(result => {
1997
+ var isPassed = result.exprestionResultArr.filter(x => x == false).length == 0;
1998
+ if (isPassed) {
1999
+ rule.ruleResultQuestions.forEach(resultQuestion => {
2000
+ if (rule.logicActionId == LogicActionEnum.Show) {
2001
+ this._store.dispatch(surveyActions.updateQuestionShow({
2002
+ questionId: resultQuestion.questionId,
2003
+ isShow: true
2004
+ }));
2005
+ }
2006
+ else if (rule.logicActionId == LogicActionEnum.Hide) {
2007
+ this._store.dispatch(surveyActions.updateQuestionShow({
2008
+ questionId: resultQuestion.questionId,
2009
+ isShow: false
2010
+ }));
2011
+ }
2012
+ else if (rule.logicActionId == LogicActionEnum.Enable) {
2013
+ this._store.dispatch(surveyActions.updateQuestionDisable({
2014
+ questionId: resultQuestion.questionId,
2015
+ isDisabled: false
2016
+ }));
2017
+ }
2018
+ else if (rule.logicActionId == LogicActionEnum.Disable) {
2019
+ this._store.dispatch(surveyActions.updateQuestionDisable({
2020
+ questionId: resultQuestion.questionId,
2021
+ isDisabled: true
2022
+ }));
2023
+ }
2024
+ else if (rule.logicActionId == LogicActionEnum.SetAnswer) {
2025
+ }
2026
+ const question = questionArr.find(x => x.questionId == resultQuestion.questionId);
2027
+ //update matrix sub questions
2028
+ if (question.questionType == QuestionTypeEnum.Matrix && question.isMatrixGroup == true) {
2029
+ var subQuestions = questionArr.filter(x => x.parentQuestionId == question.questionId);
2030
+ subQuestions.forEach(subQuestion => {
2031
+ if (rule.logicActionId == LogicActionEnum.Show) {
2032
+ this._store.dispatch(surveyActions.updateQuestionShow({
2033
+ questionId: subQuestion.questionId,
2034
+ isShow: true
2035
+ }));
2036
+ }
2037
+ else if (rule.logicActionId == LogicActionEnum.Hide) {
2038
+ this._store.dispatch(surveyActions.updateQuestionShow({
2039
+ questionId: subQuestion.questionId,
2040
+ isShow: false
2041
+ }));
2042
+ }
2043
+ else if (rule.logicActionId == LogicActionEnum.Enable) {
2044
+ this._store.dispatch(surveyActions.updateQuestionDisable({
2045
+ questionId: subQuestion.questionId,
2046
+ isDisabled: false
2047
+ }));
2048
+ }
2049
+ else if (rule.logicActionId == LogicActionEnum.Disable) {
2050
+ this._store.dispatch(surveyActions.updateQuestionDisable({
2051
+ questionId: subQuestion.questionId,
2052
+ isDisabled: true
2053
+ }));
2054
+ }
2055
+ });
2056
+ }
2057
+ });
2058
+ }
2059
+ else {
2060
+ rule.ruleResultQuestions.forEach(resultQuestion => {
2061
+ const question = questionArr.find(x => x.questionId == resultQuestion.questionId);
2062
+ this._store.dispatch(surveyActions.updateQuestionShow({
2063
+ questionId: resultQuestion.questionId,
2064
+ isShow: question.isShow_default
2065
+ }));
2066
+ this._store.dispatch(surveyActions.updateQuestionDisable({
2067
+ questionId: resultQuestion.questionId,
2068
+ isDisabled: question.isDisabled_default
2069
+ }));
2070
+ });
2071
+ }
2072
+ });
2073
+ });
2074
+ return of([]);
2075
+ })), { dispatch: false });
2076
+ }
2077
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: SurveyEffects, deps: [{ token: i1$2.Actions }, { token: i3.Store }, { token: CheckRuleExpsUsecase }], target: i0.ɵɵFactoryTarget.Injectable }); }
2078
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: SurveyEffects }); }
2079
+ }
2080
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: SurveyEffects, decorators: [{
2081
+ type: Injectable
2082
+ }], ctorParameters: function () { return [{ type: i1$2.Actions }, { type: i3.Store }, { type: CheckRuleExpsUsecase }]; } });
2083
+
1884
2084
  class SurveryLibModule {
1885
2085
  static forRoot(config) {
1886
2086
  return {
@@ -1911,11 +2111,12 @@ class SurveryLibModule {
1911
2111
  QuestionCascadeTemplateComponent,
1912
2112
  MaskedForMinMaxDirective,
1913
2113
  FindQuestionPipe,
1914
- QuestionFeedbackTemplateComponent], imports: [CommonModule, HttpClientModule, ReactiveFormsModule, FormsModule, NgSelectModule, i3.StoreFeatureModule, i2.EffectsFeatureModule, RatingModule, PaginationModule], exports: [SurveryLibComponent,
2114
+ QuestionFeedbackTemplateComponent,
2115
+ MaskedForMaxLengthDirective], imports: [CommonModule, HttpClientModule, ReactiveFormsModule, FormsModule, NgSelectModule, i3.StoreFeatureModule, i1$2.EffectsFeatureModule, RatingModule, PaginationModule], exports: [SurveryLibComponent,
1915
2116
  StoreModule] }); }
1916
2117
  static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: SurveryLibModule, imports: [CommonModule, HttpClientModule, ReactiveFormsModule, FormsModule, NgSelectModule,
1917
2118
  StoreModule.forFeature('survey-lib', surveyReducer),
1918
- EffectsModule.forFeature([]), RatingModule, PaginationModule, StoreModule] }); }
2119
+ EffectsModule.forFeature([SurveyEffects]), RatingModule, PaginationModule, StoreModule] }); }
1919
2120
  }
1920
2121
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: SurveryLibModule, decorators: [{
1921
2122
  type: NgModule,
@@ -1936,12 +2137,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImpor
1936
2137
  QuestionCascadeTemplateComponent,
1937
2138
  MaskedForMinMaxDirective,
1938
2139
  FindQuestionPipe,
1939
- QuestionFeedbackTemplateComponent
2140
+ QuestionFeedbackTemplateComponent,
2141
+ MaskedForMaxLengthDirective
1940
2142
  ],
1941
2143
  imports: [
1942
2144
  CommonModule, HttpClientModule, ReactiveFormsModule, FormsModule, NgSelectModule,
1943
2145
  StoreModule.forFeature('survey-lib', surveyReducer),
1944
- EffectsModule.forFeature([]), RatingModule, PaginationModule
2146
+ EffectsModule.forFeature([SurveyEffects]), RatingModule, PaginationModule
1945
2147
  ],
1946
2148
  exports: [
1947
2149
  SurveryLibComponent,