survery-lib 2.1.3 → 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.
- package/esm2022/lib/components/question-boolean-template/question-boolean-template.component.mjs +7 -1
- package/esm2022/lib/components/question-cascade-template/question-cascade-template.component.mjs +4 -5
- package/esm2022/lib/components/question-check-box-template/question-check-box-template.component.mjs +6 -1
- package/esm2022/lib/components/question-dropdown-multi-template/question-dropdown-multi-template.component.mjs +6 -1
- package/esm2022/lib/components/question-dropdown-template/question-dropdown-template.component.mjs +13 -3
- package/esm2022/lib/components/question-feedback-template/question-feedback-template.component.mjs +6 -1
- package/esm2022/lib/components/question-matrix-template/question-matrix-template.component.mjs +6 -1
- package/esm2022/lib/components/question-radio-button-template/question-radio-button-template.component.mjs +7 -1
- package/esm2022/lib/components/question-text-template/question-text-template.component.mjs +6 -1
- package/esm2022/lib/core/states/survey-store/survey.effect.mjs +121 -0
- package/esm2022/lib/survery-lib.component.mjs +8 -5
- package/esm2022/lib/survery-lib.module.mjs +4 -3
- package/fesm2022/survery-lib.mjs +183 -16
- package/fesm2022/survery-lib.mjs.map +1 -1
- package/lib/components/question-boolean-template/question-boolean-template.component.d.ts +1 -0
- package/lib/components/question-cascade-template/question-cascade-template.component.d.ts +1 -1
- package/lib/components/question-check-box-template/question-check-box-template.component.d.ts +1 -0
- package/lib/components/question-dropdown-multi-template/question-dropdown-multi-template.component.d.ts +1 -0
- package/lib/components/question-dropdown-template/question-dropdown-template.component.d.ts +6 -2
- package/lib/components/question-feedback-template/question-feedback-template.component.d.ts +1 -0
- package/lib/components/question-matrix-template/question-matrix-template.component.d.ts +1 -0
- package/lib/components/question-radio-button-template/question-radio-button-template.component.d.ts +1 -0
- package/lib/components/question-text-template/question-text-template.component.d.ts +1 -0
- package/lib/core/states/survey-store/survey.effect.d.ts +13 -0
- package/lib/survery-lib.component.d.ts +4 -2
- package/package.json +3 -2
package/fesm2022/survery-lib.mjs
CHANGED
|
@@ -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
|
|
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) {
|
|
@@ -658,6 +659,10 @@ class QuestionTextTemplateComponent {
|
|
|
658
659
|
}
|
|
659
660
|
this.fCtrls.answer.updateValueAndValidity();
|
|
660
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
|
+
}
|
|
661
666
|
this.toggleEnableAnswer(value.questionAllInfo.isReadOnly);
|
|
662
667
|
}
|
|
663
668
|
}
|
|
@@ -668,6 +673,7 @@ class QuestionTextTemplateComponent {
|
|
|
668
673
|
this._formBuilder = _formBuilder;
|
|
669
674
|
this._surveyLibService = _surveyLibService;
|
|
670
675
|
this._Store = _Store;
|
|
676
|
+
this.questionArr = this._Store.selectSignal(questionSelectors.pageQuestions);
|
|
671
677
|
this.isArabicLang = false;
|
|
672
678
|
this.rForm = this._formBuilder.group({
|
|
673
679
|
id: new FormControl(null),
|
|
@@ -785,6 +791,11 @@ class QuestionRadioButtonTemplateComponent {
|
|
|
785
791
|
this.fCtrls.answer.addValidators([Validators.required]);
|
|
786
792
|
this.fCtrls.answer.updateValueAndValidity();
|
|
787
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
|
+
}
|
|
788
799
|
}
|
|
789
800
|
}
|
|
790
801
|
constructor(_formBuilder, _surveyLibService, _Store) {
|
|
@@ -792,6 +803,7 @@ class QuestionRadioButtonTemplateComponent {
|
|
|
792
803
|
this._surveyLibService = _surveyLibService;
|
|
793
804
|
this._Store = _Store;
|
|
794
805
|
this.elemId = v4();
|
|
806
|
+
this.questionArr = this._Store.selectSignal(questionSelectors.pageQuestions);
|
|
795
807
|
this.rForm = this._formBuilder.group({
|
|
796
808
|
id: new FormControl(null),
|
|
797
809
|
name: new FormControl(null),
|
|
@@ -884,6 +896,10 @@ class QuestionCheckBoxTemplateComponent {
|
|
|
884
896
|
this.fCtrls.answer.addValidators([Validators.required]);
|
|
885
897
|
this.fCtrls.answer.updateValueAndValidity();
|
|
886
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
|
+
}
|
|
887
903
|
}
|
|
888
904
|
}
|
|
889
905
|
constructor(_formBuilder, _surveyLibService, _Store) {
|
|
@@ -891,6 +907,7 @@ class QuestionCheckBoxTemplateComponent {
|
|
|
891
907
|
this._surveyLibService = _surveyLibService;
|
|
892
908
|
this._Store = _Store;
|
|
893
909
|
this.elemId = v4();
|
|
910
|
+
this.questionArr = this._Store.selectSignal(questionSelectors.pageQuestions);
|
|
894
911
|
this.rForm = this._formBuilder.group({
|
|
895
912
|
id: new FormControl(null),
|
|
896
913
|
name: new FormControl(null),
|
|
@@ -987,12 +1004,18 @@ class QuestionDropdownTemplateComponent {
|
|
|
987
1004
|
this.fCtrls.answer.addValidators([Validators.required]);
|
|
988
1005
|
this.fCtrls.answer.updateValueAndValidity();
|
|
989
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
|
+
}
|
|
990
1011
|
}
|
|
991
1012
|
}
|
|
992
1013
|
constructor(_formBuilder, _surveyLibService, _Store) {
|
|
993
1014
|
this._formBuilder = _formBuilder;
|
|
994
1015
|
this._surveyLibService = _surveyLibService;
|
|
995
1016
|
this._Store = _Store;
|
|
1017
|
+
this.subs = new SubSink();
|
|
1018
|
+
this.questionArr = this._Store.selectSignal(questionSelectors.pageQuestions);
|
|
996
1019
|
this.emitter = new EventEmitter();
|
|
997
1020
|
this.rForm = this._formBuilder.group({
|
|
998
1021
|
id: new FormControl(null),
|
|
@@ -1005,8 +1028,11 @@ class QuestionDropdownTemplateComponent {
|
|
|
1005
1028
|
isShow: new FormControl(true),
|
|
1006
1029
|
});
|
|
1007
1030
|
}
|
|
1031
|
+
ngOnDestroy() {
|
|
1032
|
+
this.subs.unsubscribe();
|
|
1033
|
+
}
|
|
1008
1034
|
ngOnInit() {
|
|
1009
|
-
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 => {
|
|
1010
1036
|
const formValue = this.rForm.value;
|
|
1011
1037
|
this._Store.dispatch(surveyActions.updateQuestionAnswer({
|
|
1012
1038
|
questionId: formValue.id,
|
|
@@ -1019,7 +1045,7 @@ class QuestionDropdownTemplateComponent {
|
|
|
1019
1045
|
Answer: value
|
|
1020
1046
|
});
|
|
1021
1047
|
});
|
|
1022
|
-
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)))
|
|
1023
1049
|
.pipe(filter(x => x != null), pairwise()).subscribe(value => {
|
|
1024
1050
|
const oldValue = value[0];
|
|
1025
1051
|
const newValue = value[1];
|
|
@@ -1089,6 +1115,10 @@ class QuestionMatrixTemplateComponent {
|
|
|
1089
1115
|
isValid: group.controls.answer.valid
|
|
1090
1116
|
}));
|
|
1091
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
|
+
}
|
|
1092
1122
|
this.fCtrls.subQuestionArray.push(group);
|
|
1093
1123
|
});
|
|
1094
1124
|
}
|
|
@@ -1098,6 +1128,7 @@ class QuestionMatrixTemplateComponent {
|
|
|
1098
1128
|
this._surveyLibService = _surveyLibService;
|
|
1099
1129
|
this._Store = _Store;
|
|
1100
1130
|
this.elemId = v4();
|
|
1131
|
+
this.questionArr = this._Store.selectSignal(questionSelectors.pageQuestions);
|
|
1101
1132
|
this.rForm = this._formBuilder.group({
|
|
1102
1133
|
id: new FormControl(null),
|
|
1103
1134
|
typeId: new FormControl(null),
|
|
@@ -1187,6 +1218,11 @@ class QuestionBooleanTemplateComponent {
|
|
|
1187
1218
|
this.fCtrls.answer.addValidators([Validators.required]);
|
|
1188
1219
|
this.fCtrls.answer.updateValueAndValidity();
|
|
1189
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
|
+
}
|
|
1190
1226
|
}
|
|
1191
1227
|
}
|
|
1192
1228
|
constructor(_formBuilder, _surveyLibService, _Store) {
|
|
@@ -1194,6 +1230,7 @@ class QuestionBooleanTemplateComponent {
|
|
|
1194
1230
|
this._surveyLibService = _surveyLibService;
|
|
1195
1231
|
this._Store = _Store;
|
|
1196
1232
|
this.elemId = v4();
|
|
1233
|
+
this.questionArr = this._Store.selectSignal(questionSelectors.pageQuestions);
|
|
1197
1234
|
this.rForm = this._formBuilder.group({
|
|
1198
1235
|
id: new FormControl(null),
|
|
1199
1236
|
name: new FormControl(null),
|
|
@@ -1282,6 +1319,10 @@ class QuestionDropdownMultiTemplateComponent {
|
|
|
1282
1319
|
this.fCtrls.answer.addValidators([Validators.required]);
|
|
1283
1320
|
this.fCtrls.answer.updateValueAndValidity();
|
|
1284
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
|
+
}
|
|
1285
1326
|
}
|
|
1286
1327
|
}
|
|
1287
1328
|
constructor(_formBuilder, _surveyLibService, _Store) {
|
|
@@ -1289,6 +1330,7 @@ class QuestionDropdownMultiTemplateComponent {
|
|
|
1289
1330
|
this._surveyLibService = _surveyLibService;
|
|
1290
1331
|
this._Store = _Store;
|
|
1291
1332
|
this.elemId = v4();
|
|
1333
|
+
this.questionArr = this._Store.selectSignal(questionSelectors.pageQuestions);
|
|
1292
1334
|
this.rForm = this._formBuilder.group({
|
|
1293
1335
|
id: new FormControl(null),
|
|
1294
1336
|
name: new FormControl(null),
|
|
@@ -1408,7 +1450,7 @@ class QuestionCascadeTemplateComponent {
|
|
|
1408
1450
|
this._ApiService = _ApiService;
|
|
1409
1451
|
this._Store = _Store;
|
|
1410
1452
|
this.surveyQuestionArr = [];
|
|
1411
|
-
this.pageQuestions$ = this._Store.
|
|
1453
|
+
this.pageQuestions$ = this._Store.selectSignal(questionSelectors.pageQuestions);
|
|
1412
1454
|
this.pageId = null;
|
|
1413
1455
|
this.questionGroupId = null;
|
|
1414
1456
|
this.isPre = false;
|
|
@@ -1486,14 +1528,13 @@ class QuestionCascadeTemplateComponent {
|
|
|
1486
1528
|
group.controls.answer.updateValueAndValidity();
|
|
1487
1529
|
}
|
|
1488
1530
|
this.fCtrls.questionArr.push(group);
|
|
1489
|
-
console.log(this.fCtrls.questionArr.value);
|
|
1490
1531
|
}
|
|
1491
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 }); }
|
|
1492
|
-
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]=\"
|
|
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" }] }); }
|
|
1493
1534
|
}
|
|
1494
1535
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionCascadeTemplateComponent, decorators: [{
|
|
1495
1536
|
type: Component,
|
|
1496
|
-
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]=\"
|
|
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>" }]
|
|
1497
1538
|
}], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: SurveyLibService }, { type: ApiService }, { type: i3.Store }]; }, propDecorators: { pageId: [{
|
|
1498
1539
|
type: Input
|
|
1499
1540
|
}], questionGroupId: [{
|
|
@@ -1543,6 +1584,10 @@ class QuestionFeedbackTemplateComponent {
|
|
|
1543
1584
|
this.fCtrls.answer.addValidators([Validators.required]);
|
|
1544
1585
|
this.fCtrls.answer.updateValueAndValidity();
|
|
1545
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
|
+
}
|
|
1546
1591
|
this.toggleEnableAnswer(value.questionAllInfo.isReadOnly);
|
|
1547
1592
|
}
|
|
1548
1593
|
}
|
|
@@ -1553,6 +1598,7 @@ class QuestionFeedbackTemplateComponent {
|
|
|
1553
1598
|
this._formBuilder = _formBuilder;
|
|
1554
1599
|
this._surveyLibService = _surveyLibService;
|
|
1555
1600
|
this._Store = _Store;
|
|
1601
|
+
this.questionArr = this._Store.selectSignal(questionSelectors.pageQuestions);
|
|
1556
1602
|
this.isArabicLang = false;
|
|
1557
1603
|
this.rForm = this._formBuilder.group({
|
|
1558
1604
|
id: new FormControl(null),
|
|
@@ -1661,8 +1707,8 @@ class SurveryLibComponent {
|
|
|
1661
1707
|
this.surveryLibraryDivId = v4();
|
|
1662
1708
|
this.reloadDefaultAnswerId = v4();
|
|
1663
1709
|
this.questionAnswerArr = [];
|
|
1664
|
-
this.pageQuestionGroups$ = this._Store.
|
|
1665
|
-
this.pageQuestions$ = this._Store.
|
|
1710
|
+
this.pageQuestionGroups$ = this._Store.selectSignal(questionGroupSelectors.pageQuestionGroups);
|
|
1711
|
+
this.pageQuestions$ = this._Store.selectSignal(questionSelectors.pageQuestions);
|
|
1666
1712
|
this.isFirstPage$ = this._Store.select(surveySelectors.isFirstPage);
|
|
1667
1713
|
this.isLastPage$ = this._Store.select(surveySelectors.isLastPage);
|
|
1668
1714
|
this.curruntShowedSurveyPages$ = this._Store.select(surveySelectors.selectedPageIndex).pipe(map(x => x + 1));
|
|
@@ -1685,6 +1731,9 @@ class SurveryLibComponent {
|
|
|
1685
1731
|
questionIdentify(index, item) {
|
|
1686
1732
|
return item.questionId;
|
|
1687
1733
|
}
|
|
1734
|
+
questionGroupIdentify(index, item) {
|
|
1735
|
+
return item.questionGroupId;
|
|
1736
|
+
}
|
|
1688
1737
|
ngOnInit() {
|
|
1689
1738
|
this._Store.select(surveySelectors.selectedPageId).subscribe(value => {
|
|
1690
1739
|
this.fCtrls.currentPageId.setValue(value);
|
|
@@ -1765,11 +1814,11 @@ class SurveryLibComponent {
|
|
|
1765
1814
|
return null;
|
|
1766
1815
|
}
|
|
1767
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 }); }
|
|
1768
|
-
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
|
|
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" }] }); }
|
|
1769
1818
|
}
|
|
1770
1819
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: SurveryLibComponent, decorators: [{
|
|
1771
1820
|
type: Component,
|
|
1772
|
-
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
|
|
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"] }]
|
|
1773
1822
|
}], ctorParameters: function () { return [{ type: SurveyLibService }, { type: i3.Store }, { type: i1.FormBuilder }, { type: CheckRuleExpsUsecase }]; }, propDecorators: { isPre: [{
|
|
1774
1823
|
type: Input
|
|
1775
1824
|
}], surveyLanguageId: [{
|
|
@@ -1914,6 +1963,124 @@ function surveyReducer(state, action) {
|
|
|
1914
1963
|
return _surveyReducer(state, action);
|
|
1915
1964
|
}
|
|
1916
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
|
+
|
|
1917
2084
|
class SurveryLibModule {
|
|
1918
2085
|
static forRoot(config) {
|
|
1919
2086
|
return {
|
|
@@ -1945,11 +2112,11 @@ class SurveryLibModule {
|
|
|
1945
2112
|
MaskedForMinMaxDirective,
|
|
1946
2113
|
FindQuestionPipe,
|
|
1947
2114
|
QuestionFeedbackTemplateComponent,
|
|
1948
|
-
MaskedForMaxLengthDirective], imports: [CommonModule, HttpClientModule, ReactiveFormsModule, FormsModule, NgSelectModule, i3.StoreFeatureModule,
|
|
2115
|
+
MaskedForMaxLengthDirective], imports: [CommonModule, HttpClientModule, ReactiveFormsModule, FormsModule, NgSelectModule, i3.StoreFeatureModule, i1$2.EffectsFeatureModule, RatingModule, PaginationModule], exports: [SurveryLibComponent,
|
|
1949
2116
|
StoreModule] }); }
|
|
1950
2117
|
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: SurveryLibModule, imports: [CommonModule, HttpClientModule, ReactiveFormsModule, FormsModule, NgSelectModule,
|
|
1951
2118
|
StoreModule.forFeature('survey-lib', surveyReducer),
|
|
1952
|
-
EffectsModule.forFeature([]), RatingModule, PaginationModule, StoreModule] }); }
|
|
2119
|
+
EffectsModule.forFeature([SurveyEffects]), RatingModule, PaginationModule, StoreModule] }); }
|
|
1953
2120
|
}
|
|
1954
2121
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: SurveryLibModule, decorators: [{
|
|
1955
2122
|
type: NgModule,
|
|
@@ -1976,7 +2143,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImpor
|
|
|
1976
2143
|
imports: [
|
|
1977
2144
|
CommonModule, HttpClientModule, ReactiveFormsModule, FormsModule, NgSelectModule,
|
|
1978
2145
|
StoreModule.forFeature('survey-lib', surveyReducer),
|
|
1979
|
-
EffectsModule.forFeature([]), RatingModule, PaginationModule
|
|
2146
|
+
EffectsModule.forFeature([SurveyEffects]), RatingModule, PaginationModule
|
|
1980
2147
|
],
|
|
1981
2148
|
exports: [
|
|
1982
2149
|
SurveryLibComponent,
|