survery-lib 0.1.59 → 0.2.1
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/README.md +52 -52
- package/assets/style.css +398 -398
- package/esm2022/lib/components/question-boolean-template/question-boolean-template.component.mjs +59 -54
- package/esm2022/lib/components/question-cascade-template/question-cascade-template.component.mjs +46 -20
- package/esm2022/lib/components/question-check-box-template/question-check-box-template.component.mjs +65 -55
- package/esm2022/lib/components/question-dropdown-multi-template/question-dropdown-multi-template.component.mjs +62 -52
- package/esm2022/lib/components/question-dropdown-template/question-dropdown-template.component.mjs +54 -36
- package/esm2022/lib/components/question-matrix-template/question-matrix-template.component.mjs +67 -55
- package/esm2022/lib/components/question-radio-button-template/question-radio-button-template.component.mjs +62 -52
- package/esm2022/lib/components/question-text-template/question-text-template.component.mjs +77 -69
- package/esm2022/lib/core/states/entites/question-group.entity.mjs +8 -0
- package/esm2022/lib/core/states/entites/question.entity.mjs +8 -0
- package/esm2022/lib/core/states/entites/rule.entity.mjs +8 -0
- package/esm2022/lib/core/states/survey-store/question-group.selector.mjs +9 -0
- package/esm2022/lib/core/states/survey-store/question.selector.mjs +22 -0
- package/esm2022/lib/core/states/survey-store/survey.action.mjs +18 -0
- package/esm2022/lib/core/states/survey-store/survey.reducer.mjs +102 -0
- package/esm2022/lib/core/states/survey-store/survey.selector.mjs +33 -0
- package/esm2022/lib/directives/masked-for-min-max.directive.mjs +9 -6
- package/esm2022/lib/pipes/default-question-answer.pipe.mjs +1 -1
- package/esm2022/lib/pipes/default-question-answers.pipe.mjs +1 -1
- package/esm2022/lib/pipes/filter-question.pipe.mjs +3 -3
- package/esm2022/lib/pipes/find-question.pipe.mjs +19 -0
- package/esm2022/lib/pipes/text-box-type-attr.pipe.mjs +1 -1
- package/esm2022/lib/services/api.service.mjs +1 -1
- package/esm2022/lib/services/survey-lib.service.mjs +100 -51
- package/esm2022/lib/survery-lib.component.mjs +80 -285
- package/esm2022/lib/survery-lib.module.mjs +21 -7
- package/esm2022/lib/usecases/check-rule-exps.usecase.mjs +1 -1
- package/esm2022/public-api.mjs +1 -1
- package/esm2022/shared/form-interfaces/survery-lib.form-interface.mjs +1 -1
- package/fesm2022/survery-lib.mjs +840 -714
- package/fesm2022/survery-lib.mjs.map +1 -1
- package/lib/components/question-boolean-template/question-boolean-template.component.d.ts +7 -6
- package/lib/components/question-cascade-template/question-cascade-template.component.d.ts +9 -6
- package/lib/components/question-check-box-template/question-check-box-template.component.d.ts +7 -6
- package/lib/components/question-dropdown-multi-template/question-dropdown-multi-template.component.d.ts +6 -6
- package/lib/components/question-dropdown-template/question-dropdown-template.component.d.ts +5 -2
- package/lib/components/question-matrix-template/question-matrix-template.component.d.ts +7 -6
- package/lib/components/question-radio-button-template/question-radio-button-template.component.d.ts +7 -6
- package/lib/components/question-text-template/question-text-template.component.d.ts +8 -7
- package/lib/core/states/entites/question-group.entity.d.ts +11 -0
- package/lib/core/states/entites/question.entity.d.ts +27 -0
- package/lib/core/states/entites/rule.entity.d.ts +8 -0
- package/lib/core/states/survey-store/question-group.selector.d.ts +4 -0
- package/lib/core/states/survey-store/question.selector.d.ts +7 -0
- package/lib/core/states/survey-store/survey.action.d.ts +54 -0
- package/lib/core/states/survey-store/survey.reducer.d.ts +12 -0
- package/lib/core/states/survey-store/survey.selector.d.ts +9 -0
- package/lib/pipes/filter-question.pipe.d.ts +2 -3
- package/lib/pipes/find-question.pipe.d.ts +8 -0
- package/lib/services/survey-lib.service.d.ts +4 -32
- package/lib/survery-lib.component.d.ts +15 -23
- package/lib/survery-lib.module.d.ts +9 -6
- package/lib/usecases/check-rule-exps.usecase.d.ts +2 -3
- package/package.json +1 -1
- package/shared/form-interfaces/survery-lib.form-interface.d.ts +3 -3
package/fesm2022/survery-lib.mjs
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Injectable, Directive, HostListener, Pipe,
|
|
2
|
+
import { Injectable, Directive, HostListener, Pipe, Component, Input, EventEmitter, Output, InjectionToken, Inject, NgModule } from '@angular/core';
|
|
3
3
|
import { v4 } from 'uuid';
|
|
4
|
-
import {
|
|
4
|
+
import { of, debounceTime, distinctUntilChanged, map, filter, pairwise, take } from 'rxjs';
|
|
5
|
+
import * as i5 from '@angular/forms';
|
|
6
|
+
import { Validators, FormControl, ReactiveFormsModule, FormsModule } from '@angular/forms';
|
|
7
|
+
import * as i3 from '@ngrx/store';
|
|
8
|
+
import { createFeatureSelector, createSelector, createAction, props, createReducer, on, StoreModule } from '@ngrx/store';
|
|
9
|
+
import { createEntityAdapter } from '@ngrx/entity';
|
|
10
|
+
import * as i4 from '@angular/common';
|
|
11
|
+
import { CommonModule } from '@angular/common';
|
|
5
12
|
import * as i1 from '@ng-stack/forms';
|
|
6
13
|
import { Validators as Validators$1, NgsFormsModule } from '@ng-stack/forms';
|
|
7
|
-
import * as
|
|
8
|
-
import { CommonModule } from '@angular/common';
|
|
9
|
-
import * as i4 from '@angular/forms';
|
|
10
|
-
import { Validators, ReactiveFormsModule, FormsModule } from '@angular/forms';
|
|
11
|
-
import * as i5 from '@ng-select/ng-select';
|
|
14
|
+
import * as i6 from '@ng-select/ng-select';
|
|
12
15
|
import { NgSelectModule } from '@ng-select/ng-select';
|
|
13
16
|
import * as i1$1 from '@angular/common/http';
|
|
14
17
|
import { HttpHeaders, HttpClientModule } from '@angular/common/http';
|
|
18
|
+
import * as i2 from '@ngrx/effects';
|
|
19
|
+
import { EffectsModule } from '@ngrx/effects';
|
|
15
20
|
|
|
16
21
|
var QuestionTypeEnum;
|
|
17
22
|
(function (QuestionTypeEnum) {
|
|
@@ -25,15 +30,6 @@ var QuestionTypeEnum;
|
|
|
25
30
|
QuestionTypeEnum[QuestionTypeEnum["Cascade"] = 8] = "Cascade";
|
|
26
31
|
})(QuestionTypeEnum || (QuestionTypeEnum = {}));
|
|
27
32
|
|
|
28
|
-
var LogicActionEnum;
|
|
29
|
-
(function (LogicActionEnum) {
|
|
30
|
-
LogicActionEnum[LogicActionEnum["Show"] = 1] = "Show";
|
|
31
|
-
LogicActionEnum[LogicActionEnum["Hide"] = 2] = "Hide";
|
|
32
|
-
LogicActionEnum[LogicActionEnum["Enable"] = 3] = "Enable";
|
|
33
|
-
LogicActionEnum[LogicActionEnum["Disable"] = 4] = "Disable";
|
|
34
|
-
LogicActionEnum[LogicActionEnum["SetAnswer"] = 5] = "SetAnswer";
|
|
35
|
-
})(LogicActionEnum || (LogicActionEnum = {}));
|
|
36
|
-
|
|
37
33
|
var InputTypeEnum;
|
|
38
34
|
(function (InputTypeEnum) {
|
|
39
35
|
InputTypeEnum[InputTypeEnum["Color"] = 1] = "Color";
|
|
@@ -46,59 +42,202 @@ var InputTypeEnum;
|
|
|
46
42
|
InputTypeEnum[InputTypeEnum["Phone"] = 8] = "Phone";
|
|
47
43
|
})(InputTypeEnum || (InputTypeEnum = {}));
|
|
48
44
|
|
|
45
|
+
function selectQuestionId(a) {
|
|
46
|
+
return a.questionId;
|
|
47
|
+
}
|
|
48
|
+
const questionAdapter = createEntityAdapter({
|
|
49
|
+
selectId: selectQuestionId
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
function selectRuleId(a) {
|
|
53
|
+
return a.ruleId;
|
|
54
|
+
}
|
|
55
|
+
const ruleAdapter = createEntityAdapter({
|
|
56
|
+
selectId: selectRuleId
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const { selectAll: selectAll$3, selectIds: selectIds$3 } = questionAdapter.getSelectors();
|
|
60
|
+
const selectSurveyData$2 = createFeatureSelector('survey-lib');
|
|
61
|
+
const selectedPageId = createSelector(selectSurveyData$2, (state) => state.selectedPageId);
|
|
62
|
+
const showedSurveyPages = createSelector(selectSurveyData$2, (state) => {
|
|
63
|
+
var pageArr = selectAll$3(state.questionArr).filter(x => x.isShow == true).map(x => x.surveyPageId);
|
|
64
|
+
const distinctArray = pageArr.filter((n, i) => pageArr.indexOf(n) === i);
|
|
65
|
+
return distinctArray.sort((a, b) => a - b);
|
|
66
|
+
});
|
|
67
|
+
const selectedPageIndex = createSelector(showedSurveyPages, selectSurveyData$2, (pageArr, state) => {
|
|
68
|
+
return pageArr.findIndex(x => x == state.selectedPageId);
|
|
69
|
+
});
|
|
70
|
+
const isFirstPage = createSelector(showedSurveyPages, selectSurveyData$2, (pageArr, state) => {
|
|
71
|
+
if (pageArr.length > 0) {
|
|
72
|
+
return pageArr.findIndex(x => x == state.selectedPageId) == 0;
|
|
73
|
+
}
|
|
74
|
+
return true;
|
|
75
|
+
});
|
|
76
|
+
const isLastPage = createSelector(showedSurveyPages, selectSurveyData$2, (pageArr, state) => {
|
|
77
|
+
return pageArr.findIndex(x => x == state.selectedPageId) == (pageArr.length - 1);
|
|
78
|
+
});
|
|
79
|
+
const ruleArr = createSelector(selectSurveyData$2, (state) => ruleAdapter.getSelectors().selectAll(state.ruleArr));
|
|
80
|
+
const surveySelectors = {
|
|
81
|
+
selectedPageId,
|
|
82
|
+
selectedPageIndex,
|
|
83
|
+
showedSurveyPages,
|
|
84
|
+
isFirstPage,
|
|
85
|
+
isLastPage,
|
|
86
|
+
ruleArr
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
function selectQuestionGroupId(a) {
|
|
90
|
+
return a.questionGroupId;
|
|
91
|
+
}
|
|
92
|
+
const questionGroupAdapter = createEntityAdapter({
|
|
93
|
+
selectId: selectQuestionGroupId
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
const { selectAll: selectAll$2, selectIds: selectIds$2 } = questionGroupAdapter.getSelectors();
|
|
97
|
+
const selectSurveyData$1 = createFeatureSelector('survey-lib');
|
|
98
|
+
const pageQuestionGroups = createSelector(selectSurveyData$1, (state) => selectAll$2(state.questionGroupArr).filter(x => x.surveyPageId == state.selectedPageId));
|
|
99
|
+
const questionGroupSelectors = {
|
|
100
|
+
pageQuestionGroups
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const { selectAll: selectAll$1, selectIds: selectIds$1 } = questionAdapter.getSelectors();
|
|
104
|
+
const selectSurveyData = createFeatureSelector('survey-lib');
|
|
105
|
+
const allQuestions = createSelector(selectSurveyData, (state) => selectAll$1(state.questionArr));
|
|
106
|
+
const pageQuestions = createSelector(selectSurveyData, (state) => selectAll$1(state.questionArr).filter(x => x.surveyPageId == state.selectedPageId));
|
|
107
|
+
const questionAnswers = createSelector(selectSurveyData, (state) => selectAll$1(state.questionArr).filter(x => x.isMatrixGroup != true).map(x => {
|
|
108
|
+
return {
|
|
109
|
+
SurveyPageIndex: x.surveyPageId,
|
|
110
|
+
QuestionId: x.questionId,
|
|
111
|
+
QuestionType: x.questionType,
|
|
112
|
+
AnswerId: x.answerId,
|
|
113
|
+
AnswerText: x.answerText,
|
|
114
|
+
AnswerIdArr: x.answerIdArr
|
|
115
|
+
};
|
|
116
|
+
}));
|
|
117
|
+
const questionSelectors = {
|
|
118
|
+
allQuestions,
|
|
119
|
+
pageQuestions,
|
|
120
|
+
questionAnswers
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const loadSurvey = createAction('[Survey library] Load Survey', props());
|
|
124
|
+
const addQuestion = createAction('[Survey library] Add Question', props());
|
|
125
|
+
const updateQuestionAnswer = createAction('[Survey library] Update Question Answer', props());
|
|
126
|
+
const updateQuestionShow = createAction('[Survey library] Update Question Show', props());
|
|
127
|
+
const updateQuestionDisable = createAction('[Survey library] Update Question Disable', props());
|
|
128
|
+
const removeQuestion = createAction('[Survey library] Remove Question', props());
|
|
129
|
+
const updatePageId = createAction('[Survey library] Update Page Id', props());
|
|
130
|
+
const surveyActions = {
|
|
131
|
+
loadSurvey,
|
|
132
|
+
addQuestion,
|
|
133
|
+
updateQuestionAnswer,
|
|
134
|
+
updateQuestionShow,
|
|
135
|
+
updateQuestionDisable,
|
|
136
|
+
removeQuestion,
|
|
137
|
+
updatePageId,
|
|
138
|
+
};
|
|
139
|
+
|
|
49
140
|
class SurveyLibService {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
get surveyAnswersObsrv() {
|
|
54
|
-
return this.surveyAnswersSubject.asObservable();
|
|
55
|
-
}
|
|
56
|
-
get reloadSurveyObsrv() {
|
|
57
|
-
return this.reloadSurveySubject.asObservable();
|
|
58
|
-
}
|
|
59
|
-
get questionIsShowObsrv() {
|
|
60
|
-
return this.questionIsShowSubject.asObservable();
|
|
61
|
-
}
|
|
62
|
-
get questionIsDisabledObsrv() {
|
|
63
|
-
return this.questionIsDisabledSubject.asObservable();
|
|
64
|
-
}
|
|
65
|
-
get addQuestionObsrv() {
|
|
66
|
-
return this.addQuestionSubject.asObservable();
|
|
67
|
-
}
|
|
68
|
-
get removeQuestionObsrv() {
|
|
69
|
-
return this.removeQuestionSubject.asObservable();
|
|
70
|
-
}
|
|
71
|
-
constructor() {
|
|
72
|
-
this.surveyDataSubject = new Subject();
|
|
73
|
-
this.surveyAnswersSubject = new Subject();
|
|
74
|
-
this.reloadSurveySubject = new Subject();
|
|
75
|
-
this.questionIsShowSubject = new Subject();
|
|
76
|
-
this.questionIsDisabledSubject = new Subject();
|
|
77
|
-
this.addQuestionSubject = new Subject();
|
|
78
|
-
this.removeQuestionSubject = new Subject();
|
|
141
|
+
constructor(_Store) {
|
|
142
|
+
this._Store = _Store;
|
|
79
143
|
}
|
|
80
144
|
setSurveyData(survey) {
|
|
81
|
-
|
|
145
|
+
var questionArr = [];
|
|
146
|
+
var questionGroupArr = [];
|
|
147
|
+
survey.surveyPages.forEach((page, pageIndex) => {
|
|
148
|
+
page.surveyQuestionGroups.forEach(group => {
|
|
149
|
+
questionGroupArr.push({
|
|
150
|
+
questionGroupId: group.questionGroupId,
|
|
151
|
+
questionGroupName: group.questionGroupName,
|
|
152
|
+
questionGroupDescription: group.questionGroupDescription,
|
|
153
|
+
surveyPageId: page.pageId
|
|
154
|
+
});
|
|
155
|
+
group.surveyQuestions.forEach(question => {
|
|
156
|
+
var newQuestions = this.addQuestion(question, page.pageId, group.questionGroupId);
|
|
157
|
+
questionArr.push(...newQuestions);
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
var pageIdArr = survey.surveyPages.map(x => x.pageId);
|
|
162
|
+
this._Store.dispatch(surveyActions.loadSurvey({
|
|
163
|
+
questionArr: questionArr,
|
|
164
|
+
ruleArr: survey.surveyRules,
|
|
165
|
+
questionGroupArr: questionGroupArr,
|
|
166
|
+
selectedPageId: Math.min(...pageIdArr)
|
|
167
|
+
}));
|
|
168
|
+
}
|
|
169
|
+
addQuestion(question, pageIndex, questionGroupId) {
|
|
170
|
+
var questionArr = [{
|
|
171
|
+
surveyPageId: pageIndex,
|
|
172
|
+
questionId: question.questionId,
|
|
173
|
+
questionType: question.questionTypeId,
|
|
174
|
+
inputTypeId: question.surveyAnswers[0].inputTypeId,
|
|
175
|
+
isMatrixGroup: question.questionTypeId == QuestionTypeEnum.Matrix,
|
|
176
|
+
answerId: null,
|
|
177
|
+
answerIdArr: null,
|
|
178
|
+
answerText: null,
|
|
179
|
+
isRequired: question.isRequired,
|
|
180
|
+
isValid: null,
|
|
181
|
+
isDisabled: question.isReadOnly,
|
|
182
|
+
isShow: question.isVisable,
|
|
183
|
+
isDisabled_default: question.isReadOnly,
|
|
184
|
+
isShow_default: question.isVisable,
|
|
185
|
+
questionGroupId: questionGroupId,
|
|
186
|
+
parentQuestionId: null,
|
|
187
|
+
questionAllInfo: question
|
|
188
|
+
}];
|
|
189
|
+
if (question.questionTypeId == QuestionTypeEnum.Matrix) {
|
|
190
|
+
question.surveySubQuestions.forEach(subQuestion => {
|
|
191
|
+
questionArr.push({
|
|
192
|
+
surveyPageId: pageIndex,
|
|
193
|
+
questionId: subQuestion.questionId,
|
|
194
|
+
questionType: question.questionTypeId,
|
|
195
|
+
inputTypeId: question.surveyAnswers[0].inputTypeId,
|
|
196
|
+
isMatrixGroup: false,
|
|
197
|
+
answerId: null,
|
|
198
|
+
answerIdArr: null,
|
|
199
|
+
answerText: null,
|
|
200
|
+
isRequired: question.isRequired,
|
|
201
|
+
isValid: null,
|
|
202
|
+
isDisabled: question.isReadOnly,
|
|
203
|
+
isShow: question.isVisable,
|
|
204
|
+
isDisabled_default: question.isReadOnly,
|
|
205
|
+
isShow_default: question.isVisable,
|
|
206
|
+
parentQuestionId: question.questionId,
|
|
207
|
+
questionGroupId: questionGroupId,
|
|
208
|
+
questionAllInfo: question
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
return questionArr;
|
|
82
213
|
}
|
|
83
214
|
setsurveyAnswers(model) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
215
|
+
model.defaultAnswers.forEach(answer => {
|
|
216
|
+
if (answer.QuestionType == QuestionTypeEnum.TextInput) {
|
|
217
|
+
this._Store.dispatch(surveyActions.updateQuestionAnswer({
|
|
218
|
+
questionId: answer.QuestionId,
|
|
219
|
+
answer: answer.AnswerText,
|
|
220
|
+
isValid: true
|
|
221
|
+
}));
|
|
222
|
+
}
|
|
223
|
+
else if (answer.QuestionType == QuestionTypeEnum.CheckBox
|
|
224
|
+
|| answer.QuestionType == QuestionTypeEnum.DropDownMulti) {
|
|
225
|
+
this._Store.dispatch(surveyActions.updateQuestionAnswer({
|
|
226
|
+
questionId: answer.QuestionId,
|
|
227
|
+
answer: answer.AnswerIdArr,
|
|
228
|
+
isValid: true
|
|
229
|
+
}));
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
this._Store.dispatch(surveyActions.updateQuestionAnswer({
|
|
233
|
+
questionId: answer.QuestionId,
|
|
234
|
+
answer: answer.AnswerId,
|
|
235
|
+
isValid: true
|
|
236
|
+
}));
|
|
237
|
+
}
|
|
238
|
+
});
|
|
100
239
|
}
|
|
101
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: SurveyLibService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
240
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: SurveyLibService, deps: [{ token: i3.Store }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
102
241
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: SurveyLibService, providedIn: 'root' }); }
|
|
103
242
|
}
|
|
104
243
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: SurveyLibService, decorators: [{
|
|
@@ -106,7 +245,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImpor
|
|
|
106
245
|
args: [{
|
|
107
246
|
providedIn: 'root'
|
|
108
247
|
}]
|
|
109
|
-
}], ctorParameters: function () { return []; } });
|
|
248
|
+
}], ctorParameters: function () { return [{ type: i3.Store }]; } });
|
|
110
249
|
|
|
111
250
|
var LogicPropertyEnum;
|
|
112
251
|
(function (LogicPropertyEnum) {
|
|
@@ -314,11 +453,14 @@ class MaskedForMinMaxDirective {
|
|
|
314
453
|
inputVlaue = Number(firstPart + event.key + lastPart);
|
|
315
454
|
}
|
|
316
455
|
}
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
456
|
+
if (min != null) {
|
|
457
|
+
var allowed = min.length - 1;
|
|
458
|
+
if (allowed > 0 && inputVlaue.length > allowed) {
|
|
459
|
+
if (parseInt(inputVlaue) < min) {
|
|
460
|
+
event.preventDefault();
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
}
|
|
322
464
|
if (max !== null) {
|
|
323
465
|
if (parseInt(inputVlaue) > max) {
|
|
324
466
|
event.preventDefault();
|
|
@@ -402,54 +544,56 @@ class QuestionTextTemplateComponent {
|
|
|
402
544
|
return null;
|
|
403
545
|
}
|
|
404
546
|
set setQuestion(value) {
|
|
405
|
-
this.surveyQuestion
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
if (value.
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
547
|
+
if (!this.surveyQuestion) {
|
|
548
|
+
this.surveyQuestion = value.questionAllInfo;
|
|
549
|
+
this.isTextArea = value.questionAllInfo.isAdvanceTextArea;
|
|
550
|
+
this.rForm.patchValue({
|
|
551
|
+
id: value.questionId,
|
|
552
|
+
name: value.questionAllInfo.questionName,
|
|
553
|
+
title: value.questionAllInfo.questionTitle,
|
|
554
|
+
typeId: value.questionAllInfo.questionTypeId,
|
|
555
|
+
description: value.questionAllInfo.questionDescription,
|
|
556
|
+
isDisabled: value.questionAllInfo.isReadOnly,
|
|
557
|
+
isShow: value.questionAllInfo.isVisable
|
|
558
|
+
});
|
|
559
|
+
if (value.questionAllInfo.surveyAnswers[0]?.answerId != null && value.questionAllInfo.surveyAnswers[0]?.answerId != undefined) {
|
|
560
|
+
this.fCtrls.surveyAnswerId.setValue(value.questionAllInfo.surveyAnswers[0].answerId);
|
|
561
|
+
this.fCtrls.inputTypeId.setValue(value.questionAllInfo.surveyAnswers[0].inputTypeId);
|
|
562
|
+
}
|
|
563
|
+
if (value.isRequired == true) {
|
|
564
|
+
this.fCtrls.answer.addValidators([Validators.required]);
|
|
565
|
+
if (value.questionAllInfo.surveyAnswers[0].inputTypeId == InputTypeEnum.Number) {
|
|
566
|
+
if (value.questionAllInfo.surveyAnswers[0].inputMin != null) {
|
|
567
|
+
this.fCtrls.inputMin.setValue(value.questionAllInfo.surveyAnswers[0].inputMin);
|
|
568
|
+
this.fCtrls.answer.addValidators([Validators.min(value.questionAllInfo.surveyAnswers[0].inputMin)]);
|
|
569
|
+
}
|
|
570
|
+
if (value.questionAllInfo.surveyAnswers[0].inputMax != null) {
|
|
571
|
+
this.fCtrls.inputMax.setValue(value.questionAllInfo.surveyAnswers[0].inputMax);
|
|
572
|
+
this.fCtrls.answer.addValidators([Validators.max(value.questionAllInfo.surveyAnswers[0].inputMax)]);
|
|
573
|
+
}
|
|
574
|
+
if (value.questionAllInfo.surveyAnswers[0].inputMin != null || value.questionAllInfo.surveyAnswers[0].inputMax != null) {
|
|
575
|
+
this.fCtrls.inputTypeId.setValue(InputTypeEnum.Text);
|
|
576
|
+
}
|
|
425
577
|
}
|
|
426
|
-
if (value.surveyAnswers[0].
|
|
427
|
-
this.fCtrls.
|
|
428
|
-
this.fCtrls.answer.addValidators([Validators.max(value.surveyAnswers[0].inputMax)]);
|
|
578
|
+
else if (value.questionAllInfo.surveyAnswers[0].inputTypeId == InputTypeEnum.Email) {
|
|
579
|
+
this.fCtrls.answer.addValidators([Validators.email]);
|
|
429
580
|
}
|
|
430
|
-
if (value.surveyAnswers[0].
|
|
431
|
-
this.fCtrls.
|
|
581
|
+
else if (value.questionAllInfo.surveyAnswers[0].inputTypeId == InputTypeEnum.Phone) {
|
|
582
|
+
this.fCtrls.answer.addValidators([PhoneValidator]);
|
|
432
583
|
}
|
|
584
|
+
this.fCtrls.answer.updateValueAndValidity();
|
|
433
585
|
}
|
|
434
|
-
|
|
435
|
-
this.fCtrls.answer.addValidators([Validators.email]);
|
|
436
|
-
}
|
|
437
|
-
else if (value.surveyAnswers[0].inputTypeId == InputTypeEnum.Phone) {
|
|
438
|
-
this.fCtrls.answer.addValidators([PhoneValidator]);
|
|
439
|
-
}
|
|
440
|
-
this.fCtrls.answer.updateValueAndValidity();
|
|
586
|
+
this.toggleEnableAnswer(value.questionAllInfo.isReadOnly);
|
|
441
587
|
}
|
|
442
|
-
this.toggleEnableAnswer(value.isReadOnly);
|
|
443
588
|
}
|
|
444
589
|
set isDisabled(value) {
|
|
445
590
|
this.toggleEnableAnswer(value);
|
|
446
591
|
}
|
|
447
|
-
constructor(_formBuilder, _surveyLibService) {
|
|
592
|
+
constructor(_formBuilder, _surveyLibService, _Store) {
|
|
448
593
|
this._formBuilder = _formBuilder;
|
|
449
594
|
this._surveyLibService = _surveyLibService;
|
|
450
|
-
this.
|
|
595
|
+
this._Store = _Store;
|
|
451
596
|
this.isArabicLang = false;
|
|
452
|
-
this.isTextArea = false;
|
|
453
597
|
this.rForm = this._formBuilder.group({
|
|
454
598
|
id: [null],
|
|
455
599
|
name: [null],
|
|
@@ -466,7 +610,7 @@ class QuestionTextTemplateComponent {
|
|
|
466
610
|
});
|
|
467
611
|
}
|
|
468
612
|
ngOnInit() {
|
|
469
|
-
this.fCtrls.answer.valueChanges.pipe().pipe(debounceTime(200)).subscribe(value => {
|
|
613
|
+
this.fCtrls.answer.valueChanges.pipe().pipe(debounceTime(200), distinctUntilChanged()).subscribe(value => {
|
|
470
614
|
const formValue = this.rForm.value;
|
|
471
615
|
if (formValue.inputTypeId == InputTypeEnum.Email) {
|
|
472
616
|
const isRequired = this.fCtrls.answer.hasValidator(Validators.required);
|
|
@@ -482,25 +626,32 @@ class QuestionTextTemplateComponent {
|
|
|
482
626
|
}
|
|
483
627
|
setTimeout(() => {
|
|
484
628
|
const formValue = this.rForm.value;
|
|
485
|
-
this.
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
});
|
|
629
|
+
this._Store.dispatch(surveyActions.updateQuestionAnswer({
|
|
630
|
+
questionId: formValue.id,
|
|
631
|
+
answer: value,
|
|
632
|
+
isValid: this.fCtrls.answer.valid
|
|
633
|
+
}));
|
|
491
634
|
}, 100);
|
|
492
635
|
});
|
|
493
|
-
this.fCtrls.
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
636
|
+
this._Store.select(questionSelectors.pageQuestions).pipe(map(arr => arr.find(x => x.questionId == this.fCtrls.id.value)))
|
|
637
|
+
.pipe(filter(x => x != null), pairwise()).subscribe(value => {
|
|
638
|
+
const oldValue = value[0];
|
|
639
|
+
const newValue = value[1];
|
|
640
|
+
//updated answer
|
|
641
|
+
if (oldValue?.answerText != newValue?.answerText) {
|
|
642
|
+
this.fCtrls.answer.setValue(newValue?.answerText, { emitEvent: false });
|
|
643
|
+
}
|
|
644
|
+
//updated isDisabled
|
|
645
|
+
if (oldValue?.isDisabled != newValue?.isDisabled) {
|
|
646
|
+
this.fCtrls.isDisabled.setValue(newValue?.isDisabled);
|
|
647
|
+
}
|
|
648
|
+
//updated isShow
|
|
649
|
+
if (oldValue?.isShow != newValue?.isShow) {
|
|
650
|
+
this.fCtrls.isShow.setValue(newValue?.isShow);
|
|
651
|
+
if (newValue?.isShow == false) {
|
|
652
|
+
this.fCtrls.answer.setValue(null);
|
|
653
|
+
}
|
|
654
|
+
}
|
|
504
655
|
});
|
|
505
656
|
}
|
|
506
657
|
convertToFormControl(element) {
|
|
@@ -515,17 +666,13 @@ class QuestionTextTemplateComponent {
|
|
|
515
666
|
}
|
|
516
667
|
this.fCtrls.answer.updateValueAndValidity();
|
|
517
668
|
}
|
|
518
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionTextTemplateComponent, deps: [{ token: i1.FormBuilder }, { token: SurveyLibService }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
519
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", type: QuestionTextTemplateComponent, selector: "lib-question-text-template", inputs: { isArabicLang: "isArabicLang",
|
|
669
|
+
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 }); }
|
|
670
|
+
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 [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-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>", 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: i5.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: i5.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i5.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i5.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: i5.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: MaskedForMinMaxDirective, selector: "[libMaskedForMinMax]" }, { kind: "pipe", type: TextBoxTypeAttrPipe, name: "textBoxTypeAttr" }] }); }
|
|
520
671
|
}
|
|
521
672
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionTextTemplateComponent, decorators: [{
|
|
522
673
|
type: Component,
|
|
523
|
-
args: [{ selector: 'lib-question-text-template', template: "<div class=\"quastion\" [formGroup]=\"rForm\" [attr.id]=\"'question_'+fCtrls.id.value\"\n [ngClass]=\"{'invalid-question': fCtrls.answer.invalid , 'd-none':fCtrls.isShow.value != true}\">\n <h3 class=\"quastion-title \">\n <span [innerHTML]=\"surveyQuestion?.questionTitle\"></span>\n <span style=\"color: red;\" *ngIf=\"surveyQuestion.isRequired\">*</span>\n <p *ngIf=\"questionMinMaxIndicator\" class=\"text-danger\">\n <small >{{questionMinMaxIndicator}}</small>\n </p> \n </h3>\n <div class=\"text-quastion\">\n <ng-container *ngIf=\"isTextArea == false else textAreaTemplate\">\n <input class=\"form-control\" libMaskedForMinMax [attr.min]=\"fCtrls.inputMin.value\"\n [attr.max]=\"fCtrls.inputMax.value\" [formControl]=\"convertToFormControl(fCtrls.answer)\"\n [disabled]=\"isDisabled\" [attr.type]=\"fCtrls.inputTypeId.value | textBoxTypeAttr\">\n </ng-container>\n <ng-template #textAreaTemplate>\n <textarea class=\"form-control\" rows=\"2\" [formControl]=\"convertToFormControl(fCtrls.answer)\"\n [disabled]=\"isDisabled\"></textarea>\n </ng-template>\n </div>" }]
|
|
524
|
-
}], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: SurveyLibService }]; }, propDecorators: {
|
|
525
|
-
type: Output
|
|
526
|
-
}], isArabicLang: [{
|
|
527
|
-
type: Input
|
|
528
|
-
}], isTextArea: [{
|
|
674
|
+
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 [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-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>" }]
|
|
675
|
+
}], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: SurveyLibService }, { type: i3.Store }]; }, propDecorators: { isArabicLang: [{
|
|
529
676
|
type: Input
|
|
530
677
|
}], setQuestion: [{
|
|
531
678
|
type: Input
|
|
@@ -541,33 +688,35 @@ class QuestionRadioButtonTemplateComponent {
|
|
|
541
688
|
return QuestionTypeEnum;
|
|
542
689
|
}
|
|
543
690
|
set setQuestion(value) {
|
|
544
|
-
this.surveyQuestion
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
691
|
+
if (!this.surveyQuestion) {
|
|
692
|
+
this.surveyQuestion = value.questionAllInfo;
|
|
693
|
+
this.rForm.patchValue({
|
|
694
|
+
id: value.questionId,
|
|
695
|
+
name: value.questionAllInfo.questionName,
|
|
696
|
+
title: value.questionAllInfo.questionTitle,
|
|
697
|
+
typeId: value.questionAllInfo.questionTypeId,
|
|
698
|
+
description: value.questionAllInfo.questionDescription,
|
|
699
|
+
isDisabled: value.questionAllInfo.isReadOnly,
|
|
700
|
+
isShow: value.questionAllInfo.isVisable
|
|
701
|
+
});
|
|
702
|
+
value.questionAllInfo.surveyAnswers.forEach(surveryAnswer => {
|
|
703
|
+
this.fCtrls.answerArray.push(this._formBuilder.group({
|
|
704
|
+
id: [surveryAnswer.answerId],
|
|
705
|
+
title: [surveryAnswer.answerTitle],
|
|
706
|
+
isSelected: [false]
|
|
707
|
+
}));
|
|
708
|
+
});
|
|
709
|
+
if (value.isRequired == true) {
|
|
710
|
+
this.fCtrls.answer.addValidators([Validators.required]);
|
|
711
|
+
this.fCtrls.answer.updateValueAndValidity();
|
|
712
|
+
}
|
|
564
713
|
}
|
|
565
714
|
}
|
|
566
|
-
constructor(_formBuilder, _surveyLibService) {
|
|
715
|
+
constructor(_formBuilder, _surveyLibService, _Store) {
|
|
567
716
|
this._formBuilder = _formBuilder;
|
|
568
717
|
this._surveyLibService = _surveyLibService;
|
|
718
|
+
this._Store = _Store;
|
|
569
719
|
this.elemId = v4();
|
|
570
|
-
this.emitter = new EventEmitter();
|
|
571
720
|
this.rForm = this._formBuilder.group({
|
|
572
721
|
id: [null],
|
|
573
722
|
name: [null],
|
|
@@ -582,29 +731,36 @@ class QuestionRadioButtonTemplateComponent {
|
|
|
582
731
|
}
|
|
583
732
|
ngOnInit() {
|
|
584
733
|
this.fCtrls.answer.valueChanges.pipe().pipe(debounceTime(200)).subscribe(value => {
|
|
585
|
-
console.log(value);
|
|
586
734
|
const formValue = this.rForm.value;
|
|
587
|
-
this.
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
});
|
|
735
|
+
this._Store.dispatch(surveyActions.updateQuestionAnswer({
|
|
736
|
+
questionId: formValue.id,
|
|
737
|
+
answer: value,
|
|
738
|
+
isValid: this.fCtrls.answer.valid
|
|
739
|
+
}));
|
|
592
740
|
});
|
|
593
|
-
this.fCtrls.
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
this.fCtrls.answerArray.
|
|
741
|
+
this._Store.select(questionSelectors.pageQuestions).pipe(map(arr => arr.find(x => x.questionId == this.fCtrls.id.value)))
|
|
742
|
+
.pipe(filter(x => x != null), pairwise()).subscribe(value => {
|
|
743
|
+
const oldValue = value[0];
|
|
744
|
+
const newValue = value[1];
|
|
745
|
+
//updated answer
|
|
746
|
+
if (oldValue?.answerId != newValue?.answerId) {
|
|
747
|
+
this.fCtrls.answer.setValue(newValue?.answerId, { emitEvent: false });
|
|
748
|
+
const groupIndex = this.fCtrls.answerArray.value.findIndex(x => x.id == newValue?.answerId);
|
|
749
|
+
if (groupIndex > -1) {
|
|
750
|
+
this.fCtrls.answerArray.at(groupIndex).controls.isSelected.setValue(true);
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
//updated isDisabled
|
|
754
|
+
if (oldValue?.isDisabled != newValue?.isDisabled) {
|
|
755
|
+
this.fCtrls.isDisabled.setValue(newValue?.isDisabled);
|
|
756
|
+
}
|
|
757
|
+
//updated isShow
|
|
758
|
+
if (oldValue?.isShow != newValue?.isShow) {
|
|
759
|
+
this.fCtrls.isShow.setValue(newValue?.isShow);
|
|
760
|
+
if (newValue?.isShow == false) {
|
|
761
|
+
this.fCtrls.answer.setValue(null);
|
|
762
|
+
}
|
|
601
763
|
}
|
|
602
|
-
});
|
|
603
|
-
this._surveyLibService.questionIsDisabledObsrv.pipe(filter(x => x.questionId == this.fCtrls.id.value)).subscribe(x => {
|
|
604
|
-
this.fCtrls.isDisabled.setValue(x.isDisabled);
|
|
605
|
-
});
|
|
606
|
-
this._surveyLibService.questionIsShowObsrv.pipe(filter(x => x.questionId == this.fCtrls.id.value)).subscribe(x => {
|
|
607
|
-
this.fCtrls.isShow.setValue(x.isShow);
|
|
608
764
|
});
|
|
609
765
|
}
|
|
610
766
|
onChangeAnswer(item) {
|
|
@@ -613,15 +769,13 @@ class QuestionRadioButtonTemplateComponent {
|
|
|
613
769
|
convertToFormControl(element) {
|
|
614
770
|
return element;
|
|
615
771
|
}
|
|
616
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionRadioButtonTemplateComponent, deps: [{ token: i1.FormBuilder }, { token: SurveyLibService }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
617
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", type: QuestionRadioButtonTemplateComponent, selector: "lib-question-radio-button-template", inputs: { setQuestion: "setQuestion" },
|
|
772
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionRadioButtonTemplateComponent, deps: [{ token: i1.FormBuilder }, { token: SurveyLibService }, { token: i3.Store }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
773
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", type: QuestionRadioButtonTemplateComponent, selector: "lib-question-radio-button-template", inputs: { setQuestion: "setQuestion" }, ngImport: i0, template: "<div class=\"quastion\" [attr.id]=\"'question_'+fCtrls.id.value\" [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 </h3>\r\n <div class=\"radio-button-quastion\">\r\n <div class=\"form-check form-check-radio form-check-inline\" \r\n *ngFor=\"let item of fCtrls.answerArray.controls;let i = index\">\r\n <input class=\"form-check-input\" type=\"radio\" (change)=\"onChangeAnswer(item.value)\" [disabled]=\"fCtrls.isDisabled.value\"\r\n name=\"{{elemId}}__radio-btn-option\" id=\"{{elemId}}__radio-btn_{{i}}\" [checked]=\"item.value.isSelected == true? true : null\">\r\n <label class=\"form-check-label\" for=\"{{elemId}}__radio-btn_{{i}}\" [innerHTML]=\"item.value.title\"></label>\r\n </div>\r\n </div>\r\n</div>\r\n", styles: [""], dependencies: [{ kind: "directive", type: i4.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] }); }
|
|
618
774
|
}
|
|
619
775
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionRadioButtonTemplateComponent, decorators: [{
|
|
620
776
|
type: Component,
|
|
621
|
-
args: [{ selector: 'lib-question-radio-button-template', template: "<div class=\"quastion\" [attr.id]=\"'question_'+fCtrls.id.value\" [ngClass]=\"{'invalid-question': fCtrls.answer.invalid , 'd-none':fCtrls.isShow.value != true}\">\n <h3 class=\"quastion-title \">\n <span [innerHTML]=\"surveyQuestion?.questionTitle\"></span>\n <span style=\"color: red;\" *ngIf=\"surveyQuestion.isRequired\">*</span>\n </h3>\n <div class=\"radio-button-quastion\">\n <div class=\"form-check form-check-radio form-check-inline\" \n *ngFor=\"let item of fCtrls.answerArray.controls;let i = index\">\n <input class=\"form-check-input\" type=\"radio\" (change)=\"onChangeAnswer(item.value)\" [disabled]=\"fCtrls.isDisabled.value\"\n name=\"{{elemId}}__radio-btn-option\" id=\"{{elemId}}__radio-btn_{{i}}\" [checked]=\"item.value.isSelected == true? true : null\">\n <label class=\"form-check-label\" for=\"{{elemId}}__radio-btn_{{i}}\" [innerHTML]=\"item.value.title\"></label>\n </div>\n </div>\n</div>\n" }]
|
|
622
|
-
}], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: SurveyLibService }]; }, propDecorators: {
|
|
623
|
-
type: Output
|
|
624
|
-
}], setQuestion: [{
|
|
777
|
+
args: [{ selector: 'lib-question-radio-button-template', template: "<div class=\"quastion\" [attr.id]=\"'question_'+fCtrls.id.value\" [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 </h3>\r\n <div class=\"radio-button-quastion\">\r\n <div class=\"form-check form-check-radio form-check-inline\" \r\n *ngFor=\"let item of fCtrls.answerArray.controls;let i = index\">\r\n <input class=\"form-check-input\" type=\"radio\" (change)=\"onChangeAnswer(item.value)\" [disabled]=\"fCtrls.isDisabled.value\"\r\n name=\"{{elemId}}__radio-btn-option\" id=\"{{elemId}}__radio-btn_{{i}}\" [checked]=\"item.value.isSelected == true? true : null\">\r\n <label class=\"form-check-label\" for=\"{{elemId}}__radio-btn_{{i}}\" [innerHTML]=\"item.value.title\"></label>\r\n </div>\r\n </div>\r\n</div>\r\n" }]
|
|
778
|
+
}], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: SurveyLibService }, { type: i3.Store }]; }, propDecorators: { setQuestion: [{
|
|
625
779
|
type: Input
|
|
626
780
|
}] } });
|
|
627
781
|
|
|
@@ -633,33 +787,35 @@ class QuestionCheckBoxTemplateComponent {
|
|
|
633
787
|
return QuestionTypeEnum;
|
|
634
788
|
}
|
|
635
789
|
set setQuestion(value) {
|
|
636
|
-
this.surveyQuestion
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
790
|
+
if (!this.surveyQuestion) {
|
|
791
|
+
this.surveyQuestion = value.questionAllInfo;
|
|
792
|
+
this.rForm.patchValue({
|
|
793
|
+
id: value.questionId,
|
|
794
|
+
name: value.questionAllInfo.questionName,
|
|
795
|
+
title: value.questionAllInfo.questionTitle,
|
|
796
|
+
typeId: value.questionAllInfo.questionTypeId,
|
|
797
|
+
description: value.questionAllInfo.questionDescription,
|
|
798
|
+
isDisabled: value.questionAllInfo.isReadOnly,
|
|
799
|
+
isShow: value.questionAllInfo.isVisable
|
|
800
|
+
});
|
|
801
|
+
value.questionAllInfo.surveyAnswers.forEach(surveryAnswer => {
|
|
802
|
+
this.fCtrls.answerArray.push(this._formBuilder.group({
|
|
803
|
+
id: [surveryAnswer.answerId],
|
|
804
|
+
title: [surveryAnswer.answerTitle],
|
|
805
|
+
isSelected: [false]
|
|
806
|
+
}));
|
|
807
|
+
});
|
|
808
|
+
if (value.isRequired == true) {
|
|
809
|
+
this.fCtrls.answer.addValidators([Validators.required]);
|
|
810
|
+
this.fCtrls.answer.updateValueAndValidity();
|
|
811
|
+
}
|
|
656
812
|
}
|
|
657
813
|
}
|
|
658
|
-
constructor(_formBuilder, _surveyLibService) {
|
|
814
|
+
constructor(_formBuilder, _surveyLibService, _Store) {
|
|
659
815
|
this._formBuilder = _formBuilder;
|
|
660
816
|
this._surveyLibService = _surveyLibService;
|
|
817
|
+
this._Store = _Store;
|
|
661
818
|
this.elemId = v4();
|
|
662
|
-
this.emitter = new EventEmitter();
|
|
663
819
|
this.rForm = this._formBuilder.group({
|
|
664
820
|
id: [null],
|
|
665
821
|
name: [null],
|
|
@@ -675,31 +831,38 @@ class QuestionCheckBoxTemplateComponent {
|
|
|
675
831
|
ngOnInit() {
|
|
676
832
|
this.fCtrls.answer.valueChanges.pipe().pipe(debounceTime(200)).subscribe(value => {
|
|
677
833
|
const formValue = this.rForm.value;
|
|
678
|
-
this.
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
});
|
|
834
|
+
this._Store.dispatch(surveyActions.updateQuestionAnswer({
|
|
835
|
+
questionId: formValue.id,
|
|
836
|
+
answer: value,
|
|
837
|
+
isValid: this.fCtrls.answer.valid
|
|
838
|
+
}));
|
|
683
839
|
});
|
|
684
|
-
this.fCtrls.
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
840
|
+
this._Store.select(questionSelectors.pageQuestions).pipe(map(arr => arr.find(x => x.questionId == this.fCtrls.id.value)))
|
|
841
|
+
.pipe(filter(x => x != null), pairwise()).subscribe(value => {
|
|
842
|
+
const oldValue = value[0];
|
|
843
|
+
const newValue = value[1];
|
|
844
|
+
//updated answer
|
|
845
|
+
if (oldValue?.answerIdArr != newValue?.answerIdArr) {
|
|
846
|
+
const distinctArray = newValue?.answerIdArr.filter((n, i) => newValue?.answerIdArr.indexOf(n) === i);
|
|
847
|
+
this.fCtrls.answer.setValue(distinctArray, { emitEvent: false });
|
|
848
|
+
newValue?.answerIdArr.forEach(answerId => {
|
|
849
|
+
const groupIndex = this.fCtrls.answerArray.value.findIndex(x => x.id == answerId);
|
|
850
|
+
if (groupIndex > -1) {
|
|
851
|
+
this.fCtrls.answerArray.at(groupIndex).controls.isSelected.setValue(true);
|
|
852
|
+
}
|
|
853
|
+
});
|
|
854
|
+
}
|
|
855
|
+
//updated isDisabled
|
|
856
|
+
if (oldValue?.isDisabled != newValue?.isDisabled) {
|
|
857
|
+
this.fCtrls.isDisabled.setValue(newValue?.isDisabled);
|
|
858
|
+
}
|
|
859
|
+
//updated isShow
|
|
860
|
+
if (oldValue?.isShow != newValue?.isShow) {
|
|
861
|
+
this.fCtrls.isShow.setValue(newValue?.isShow);
|
|
862
|
+
if (newValue?.isShow == false) {
|
|
863
|
+
this.fCtrls.answer.setValue(null);
|
|
695
864
|
}
|
|
696
|
-
}
|
|
697
|
-
});
|
|
698
|
-
this._surveyLibService.questionIsDisabledObsrv.pipe(filter(x => x.questionId == this.fCtrls.id.value)).subscribe(x => {
|
|
699
|
-
this.fCtrls.isDisabled.setValue(x.isDisabled);
|
|
700
|
-
});
|
|
701
|
-
this._surveyLibService.questionIsShowObsrv.pipe(filter(x => x.questionId == this.fCtrls.id.value)).subscribe(x => {
|
|
702
|
-
this.fCtrls.isShow.setValue(x.isShow);
|
|
865
|
+
}
|
|
703
866
|
});
|
|
704
867
|
}
|
|
705
868
|
onChangeAnswer(item, event) {
|
|
@@ -716,15 +879,13 @@ class QuestionCheckBoxTemplateComponent {
|
|
|
716
879
|
convertToFormControl(element) {
|
|
717
880
|
return element;
|
|
718
881
|
}
|
|
719
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionCheckBoxTemplateComponent, deps: [{ token: i1.FormBuilder }, { token: SurveyLibService }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
720
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", type: QuestionCheckBoxTemplateComponent, selector: "lib-question-check-box-template", inputs: { setQuestion: "setQuestion" },
|
|
882
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionCheckBoxTemplateComponent, deps: [{ token: i1.FormBuilder }, { token: SurveyLibService }, { token: i3.Store }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
883
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", type: QuestionCheckBoxTemplateComponent, selector: "lib-question-check-box-template", inputs: { setQuestion: "setQuestion" }, ngImport: i0, template: "<div class=\"quastion\" [attr.id]=\"'question_'+fCtrls.id.value\" [ngClass]=\"{'invalid-question': fCtrls.answer.invalid , 'd-none':fCtrls.isShow.value != true}\">\r\n <h3 class=\"quastion-title \">\r\n <span [innerHTML]=\"fCtrls.title.value\"></span>\r\n <span style=\"color: red;\" *ngIf=\"surveyQuestion.isRequired\">*</span>\r\n </h3>\r\n\r\n <div class=\"checkbox-button-quastion\">\r\n <div class=\"form-check check-box-form-check\" *ngFor=\"let item of fCtrls.answerArray.controls ;let i = index\">\r\n <input type=\"checkbox\" class=\"form-check-input\" id=\"{{elemId}}__checkbox_{{i}}\" [disabled]=\"fCtrls.isDisabled.value\"\r\n (change)=\"onChangeAnswer(item.value ,$event)\" [checked]=\"item.value.isSelected == true? true : null\">\r\n <label class=\"form-check-label \" for=\"{{elemId}}__checkbox_{{i}}\" [innerHTML]=\"item.value.title\"></label>\r\n </div>\r\n </div>\r\n</div>\r\n", styles: [""], dependencies: [{ kind: "directive", type: i4.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] }); }
|
|
721
884
|
}
|
|
722
885
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionCheckBoxTemplateComponent, decorators: [{
|
|
723
886
|
type: Component,
|
|
724
|
-
args: [{ selector: 'lib-question-check-box-template', template: "<div class=\"quastion\" [attr.id]=\"'question_'+fCtrls.id.value\" [ngClass]=\"{'invalid-question': fCtrls.answer.invalid , 'd-none':fCtrls.isShow.value != true}\">\n <h3 class=\"quastion-title \">\n <span [innerHTML]=\"fCtrls.title.value\"></span>\n <span style=\"color: red;\" *ngIf=\"surveyQuestion.isRequired\">*</span>\n </h3>\n\n <div class=\"checkbox-button-quastion\">\n <div class=\"form-check check-box-form-check\" *ngFor=\"let item of fCtrls.answerArray.controls ;let i = index\">\n <input type=\"checkbox\" class=\"form-check-input\" id=\"{{elemId}}__checkbox_{{i}}\" [disabled]=\"fCtrls.isDisabled.value\"\n (change)=\"onChangeAnswer(item.value ,$event)\" [checked]=\"item.value.isSelected == true? true : null\">\n <label class=\"form-check-label \" for=\"{{elemId}}__checkbox_{{i}}\" [innerHTML]=\"item.value.title\"></label>\n </div>\n </div>\n</div>\n" }]
|
|
725
|
-
}], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: SurveyLibService }]; }, propDecorators: {
|
|
726
|
-
type: Output
|
|
727
|
-
}], setQuestion: [{
|
|
887
|
+
args: [{ selector: 'lib-question-check-box-template', template: "<div class=\"quastion\" [attr.id]=\"'question_'+fCtrls.id.value\" [ngClass]=\"{'invalid-question': fCtrls.answer.invalid , 'd-none':fCtrls.isShow.value != true}\">\r\n <h3 class=\"quastion-title \">\r\n <span [innerHTML]=\"fCtrls.title.value\"></span>\r\n <span style=\"color: red;\" *ngIf=\"surveyQuestion.isRequired\">*</span>\r\n </h3>\r\n\r\n <div class=\"checkbox-button-quastion\">\r\n <div class=\"form-check check-box-form-check\" *ngFor=\"let item of fCtrls.answerArray.controls ;let i = index\">\r\n <input type=\"checkbox\" class=\"form-check-input\" id=\"{{elemId}}__checkbox_{{i}}\" [disabled]=\"fCtrls.isDisabled.value\"\r\n (change)=\"onChangeAnswer(item.value ,$event)\" [checked]=\"item.value.isSelected == true? true : null\">\r\n <label class=\"form-check-label \" for=\"{{elemId}}__checkbox_{{i}}\" [innerHTML]=\"item.value.title\"></label>\r\n </div>\r\n </div>\r\n</div>\r\n" }]
|
|
888
|
+
}], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: SurveyLibService }, { type: i3.Store }]; }, propDecorators: { setQuestion: [{
|
|
728
889
|
type: Input
|
|
729
890
|
}] } });
|
|
730
891
|
|
|
@@ -736,24 +897,27 @@ class QuestionDropdownTemplateComponent {
|
|
|
736
897
|
return QuestionTypeEnum;
|
|
737
898
|
}
|
|
738
899
|
set setQuestion(value) {
|
|
739
|
-
this.surveyQuestion
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
900
|
+
if (!this.surveyQuestion) {
|
|
901
|
+
this.surveyQuestion = value.questionAllInfo;
|
|
902
|
+
this.rForm.patchValue({
|
|
903
|
+
id: value.questionId,
|
|
904
|
+
name: value.questionAllInfo.questionName,
|
|
905
|
+
title: value.questionAllInfo.questionTitle,
|
|
906
|
+
typeId: value.questionAllInfo.questionTypeId,
|
|
907
|
+
description: value.questionAllInfo.questionDescription,
|
|
908
|
+
isDisabled: value.questionAllInfo.isReadOnly,
|
|
909
|
+
isShow: value.questionAllInfo.isVisable
|
|
910
|
+
});
|
|
911
|
+
if (value.isRequired == true) {
|
|
912
|
+
this.fCtrls.answer.addValidators([Validators.required]);
|
|
913
|
+
this.fCtrls.answer.updateValueAndValidity();
|
|
914
|
+
}
|
|
752
915
|
}
|
|
753
916
|
}
|
|
754
|
-
constructor(_formBuilder, _surveyLibService) {
|
|
917
|
+
constructor(_formBuilder, _surveyLibService, _Store) {
|
|
755
918
|
this._formBuilder = _formBuilder;
|
|
756
919
|
this._surveyLibService = _surveyLibService;
|
|
920
|
+
this._Store = _Store;
|
|
757
921
|
this.emitter = new EventEmitter();
|
|
758
922
|
this.rForm = this._formBuilder.group({
|
|
759
923
|
id: [null],
|
|
@@ -767,38 +931,50 @@ class QuestionDropdownTemplateComponent {
|
|
|
767
931
|
});
|
|
768
932
|
}
|
|
769
933
|
ngOnInit() {
|
|
770
|
-
this.fCtrls.answer.valueChanges.pipe().pipe(debounceTime(200)).subscribe(value => {
|
|
934
|
+
this.fCtrls.answer.valueChanges.pipe().pipe(debounceTime(200), distinctUntilChanged()).subscribe(value => {
|
|
771
935
|
const formValue = this.rForm.value;
|
|
936
|
+
this._Store.dispatch(surveyActions.updateQuestionAnswer({
|
|
937
|
+
questionId: formValue.id,
|
|
938
|
+
answer: value,
|
|
939
|
+
isValid: this.fCtrls.answer.valid
|
|
940
|
+
}));
|
|
772
941
|
this.emitter.emit({
|
|
773
942
|
QuestionId: formValue.id,
|
|
774
943
|
IsValid: this.fCtrls.answer.valid,
|
|
775
944
|
Answer: value
|
|
776
945
|
});
|
|
777
946
|
});
|
|
778
|
-
this.fCtrls.
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
947
|
+
this._Store.select(questionSelectors.pageQuestions).pipe(map(arr => arr.find(x => x.questionId == this.fCtrls.id.value)))
|
|
948
|
+
.pipe(filter(x => x != null), pairwise()).subscribe(value => {
|
|
949
|
+
const oldValue = value[0];
|
|
950
|
+
const newValue = value[1];
|
|
951
|
+
//updated answer
|
|
952
|
+
if (oldValue?.answerId != newValue?.answerId) {
|
|
953
|
+
this.fCtrls.answer.setValue(newValue?.answerId, { emitEvent: false });
|
|
954
|
+
}
|
|
955
|
+
//updated isDisabled
|
|
956
|
+
if (oldValue?.isDisabled != newValue?.isDisabled) {
|
|
957
|
+
this.fCtrls.isDisabled.setValue(newValue?.isDisabled);
|
|
958
|
+
}
|
|
959
|
+
//updated isShow
|
|
960
|
+
if (oldValue?.isShow != newValue?.isShow) {
|
|
961
|
+
this.fCtrls.isShow.setValue(newValue?.isShow);
|
|
962
|
+
if (newValue?.isShow == false) {
|
|
963
|
+
this.fCtrls.answer.setValue(null);
|
|
964
|
+
}
|
|
965
|
+
}
|
|
790
966
|
});
|
|
791
967
|
}
|
|
792
968
|
convertToFormControl(element) {
|
|
793
969
|
return element;
|
|
794
970
|
}
|
|
795
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionDropdownTemplateComponent, deps: [{ token: i1.FormBuilder }, { token: SurveyLibService }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
796
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", type: QuestionDropdownTemplateComponent, selector: "lib-question-dropdown-template", inputs: { setQuestion: "setQuestion" }, outputs: { emitter: "emitter" }, ngImport: i0, template: "<div class=\"quastion\" [attr.id]=\"'question_'+fCtrls.id.value\" [ngClass]=\"{'invalid-question': fCtrls.answer.invalid , 'd-none':fCtrls.isShow.value != true}\">\n <h3 class=\"quastion-title \">\n <span [innerHTML]=\"fCtrls.title.value\"></span>\n <span style=\"color: red;\" *ngIf=\"surveyQuestion
|
|
971
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionDropdownTemplateComponent, deps: [{ token: i1.FormBuilder }, { token: SurveyLibService }, { token: i3.Store }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
972
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", type: QuestionDropdownTemplateComponent, selector: "lib-question-dropdown-template", inputs: { setQuestion: "setQuestion" }, outputs: { emitter: "emitter" }, ngImport: i0, template: "<div class=\"quastion\" [attr.id]=\"'question_'+fCtrls.id.value\" [ngClass]=\"{'invalid-question': fCtrls.answer.invalid , 'd-none':fCtrls.isShow.value != true}\">\r\n <h3 class=\"quastion-title \">\r\n <span [innerHTML]=\"fCtrls.title.value\"></span>\r\n <span style=\"color: red;\" *ngIf=\"surveyQuestion?.isRequired\">*</span>\r\n </h3>\r\n <div class=\"text-quastion text-quastion__dropdown\">\r\n <ng-select [items]=\"surveyQuestion?.surveyAnswers\" bindValue=\"answerId\" bindLabel=\"answerTitle\" class=\"form-control\"\r\n [formControl]=\"convertToFormControl(fCtrls.answer)\" [disabled]=\"fCtrls.isDisabled.value\" [multiple]=\"false\">\r\n </ng-select>\r\n </div>\r\n</div>\r\n", styles: [".text-quastion .form-control{padding:10px}\n"], 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: i5.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i5.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: i6.NgSelectComponent, selector: "ng-select", inputs: ["bindLabel", "bindValue", "markFirst", "placeholder", "notFoundText", "typeToSearchText", "addTagText", "loadingText", "clearAllText", "appearance", "dropdownPosition", "appendTo", "loading", "closeOnSelect", "hideSelected", "selectOnTab", "openOnEnter", "maxSelectedItems", "groupBy", "groupValue", "bufferAmount", "virtualScroll", "selectableGroup", "selectableGroupAsModel", "searchFn", "trackByFn", "clearOnBackspace", "labelForId", "inputAttrs", "tabIndex", "readonly", "searchWhileComposing", "minTermLength", "editableSearchTerm", "keyDownFn", "typeahead", "multiple", "addTag", "searchable", "clearable", "isOpen", "items", "compareWith", "clearSearchOnAdd", "deselectOnClick"], outputs: ["blur", "focus", "change", "open", "close", "search", "clear", "add", "remove", "scroll", "scrollToEnd"] }] }); }
|
|
797
973
|
}
|
|
798
974
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionDropdownTemplateComponent, decorators: [{
|
|
799
975
|
type: Component,
|
|
800
|
-
args: [{ selector: 'lib-question-dropdown-template', template: "<div class=\"quastion\" [attr.id]=\"'question_'+fCtrls.id.value\" [ngClass]=\"{'invalid-question': fCtrls.answer.invalid , 'd-none':fCtrls.isShow.value != true}\">\n <h3 class=\"quastion-title \">\n <span [innerHTML]=\"fCtrls.title.value\"></span>\n <span style=\"color: red;\" *ngIf=\"surveyQuestion
|
|
801
|
-
}], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: SurveyLibService }]; }, propDecorators: { emitter: [{
|
|
976
|
+
args: [{ selector: 'lib-question-dropdown-template', template: "<div class=\"quastion\" [attr.id]=\"'question_'+fCtrls.id.value\" [ngClass]=\"{'invalid-question': fCtrls.answer.invalid , 'd-none':fCtrls.isShow.value != true}\">\r\n <h3 class=\"quastion-title \">\r\n <span [innerHTML]=\"fCtrls.title.value\"></span>\r\n <span style=\"color: red;\" *ngIf=\"surveyQuestion?.isRequired\">*</span>\r\n </h3>\r\n <div class=\"text-quastion text-quastion__dropdown\">\r\n <ng-select [items]=\"surveyQuestion?.surveyAnswers\" bindValue=\"answerId\" bindLabel=\"answerTitle\" class=\"form-control\"\r\n [formControl]=\"convertToFormControl(fCtrls.answer)\" [disabled]=\"fCtrls.isDisabled.value\" [multiple]=\"false\">\r\n </ng-select>\r\n </div>\r\n</div>\r\n", styles: [".text-quastion .form-control{padding:10px}\n"] }]
|
|
977
|
+
}], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: SurveyLibService }, { type: i3.Store }]; }, propDecorators: { emitter: [{
|
|
802
978
|
type: Output
|
|
803
979
|
}], setQuestion: [{
|
|
804
980
|
type: Input
|
|
@@ -812,39 +988,41 @@ class QuestionMatrixTemplateComponent {
|
|
|
812
988
|
return QuestionTypeEnum;
|
|
813
989
|
}
|
|
814
990
|
set setQuestion(value) {
|
|
815
|
-
this.surveyQuestion
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
value.surveySubQuestions.forEach(x => {
|
|
823
|
-
var group = this._formBuilder.group({
|
|
824
|
-
subQuestionId: [x.questionId],
|
|
825
|
-
questionTitle: [x.questionTitle],
|
|
826
|
-
answer: [null],
|
|
991
|
+
if (!this.surveyQuestion) {
|
|
992
|
+
this.surveyQuestion = value.questionAllInfo;
|
|
993
|
+
this.rForm.patchValue({
|
|
994
|
+
id: value.questionId,
|
|
995
|
+
typeId: value.questionAllInfo.questionTypeId,
|
|
996
|
+
isDisabled: value.questionAllInfo.isReadOnly,
|
|
997
|
+
isShow: value.questionAllInfo.isVisable
|
|
827
998
|
});
|
|
828
|
-
|
|
829
|
-
group.
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
const formValue = this.rForm.value;
|
|
834
|
-
this.emitter.emit({
|
|
835
|
-
QuestionId: group.value.subQuestionId,
|
|
836
|
-
Answer: group.value.answer,
|
|
837
|
-
IsValid: group.controls.answer.valid
|
|
999
|
+
value.questionAllInfo.surveySubQuestions.forEach(x => {
|
|
1000
|
+
var group = this._formBuilder.group({
|
|
1001
|
+
subQuestionId: [x.questionId],
|
|
1002
|
+
questionTitle: [x.questionTitle],
|
|
1003
|
+
answer: [null],
|
|
838
1004
|
});
|
|
1005
|
+
if (value.isRequired == true) {
|
|
1006
|
+
group.controls.answer.addValidators([Validators.required]);
|
|
1007
|
+
group.controls.answer.updateValueAndValidity();
|
|
1008
|
+
}
|
|
1009
|
+
group.controls.answer.valueChanges.pipe().pipe(debounceTime(200)).subscribe(value => {
|
|
1010
|
+
const formValue = this.rForm.value;
|
|
1011
|
+
this._Store.dispatch(surveyActions.updateQuestionAnswer({
|
|
1012
|
+
questionId: group.value.subQuestionId,
|
|
1013
|
+
answer: group.value.answer,
|
|
1014
|
+
isValid: group.controls.answer.valid
|
|
1015
|
+
}));
|
|
1016
|
+
});
|
|
1017
|
+
this.fCtrls.subQuestionArray.push(group);
|
|
839
1018
|
});
|
|
840
|
-
|
|
841
|
-
});
|
|
1019
|
+
}
|
|
842
1020
|
}
|
|
843
|
-
constructor(_formBuilder, _surveyLibService) {
|
|
1021
|
+
constructor(_formBuilder, _surveyLibService, _Store) {
|
|
844
1022
|
this._formBuilder = _formBuilder;
|
|
845
1023
|
this._surveyLibService = _surveyLibService;
|
|
1024
|
+
this._Store = _Store;
|
|
846
1025
|
this.elemId = v4();
|
|
847
|
-
this.emitter = new EventEmitter();
|
|
848
1026
|
this.rForm = this._formBuilder.group({
|
|
849
1027
|
id: [null],
|
|
850
1028
|
typeId: [null],
|
|
@@ -854,46 +1032,53 @@ class QuestionMatrixTemplateComponent {
|
|
|
854
1032
|
});
|
|
855
1033
|
}
|
|
856
1034
|
ngOnInit() {
|
|
857
|
-
this.
|
|
858
|
-
.pipe(
|
|
859
|
-
|
|
860
|
-
|
|
1035
|
+
this._Store.select(questionSelectors.pageQuestions).pipe(map(arr => arr.find(x => x.questionId == this.fCtrls.id.value)))
|
|
1036
|
+
.pipe(filter(x => x != null), pairwise()).subscribe(value => {
|
|
1037
|
+
const oldValue = value[0];
|
|
1038
|
+
const newValue = value[1];
|
|
1039
|
+
//updated isDisabled
|
|
1040
|
+
if (oldValue?.isDisabled != newValue?.isDisabled) {
|
|
1041
|
+
this.fCtrls.isDisabled.setValue(newValue?.isDisabled);
|
|
1042
|
+
}
|
|
1043
|
+
//updated isShow
|
|
1044
|
+
if (oldValue?.isShow != newValue?.isShow) {
|
|
1045
|
+
this.fCtrls.isShow.setValue(newValue?.isShow);
|
|
1046
|
+
// if (newValue?.isShow == false) {
|
|
1047
|
+
// this.fCtrls.answer.setValue(null);
|
|
1048
|
+
// }
|
|
1049
|
+
}
|
|
1050
|
+
});
|
|
1051
|
+
this._Store.select(questionSelectors.pageQuestions).pipe(map(arr => arr.filter(x => x.parentQuestionId == this.fCtrls.id.value)))
|
|
1052
|
+
.pipe(filter(x => x.length > 0)).subscribe(questions => {
|
|
1053
|
+
//Update Answers
|
|
861
1054
|
this.fCtrls.subQuestionArray.controls.forEach(group => {
|
|
862
|
-
var
|
|
863
|
-
if (
|
|
864
|
-
group.controls.answer.setValue(
|
|
1055
|
+
var question = questions.find(x => x.questionId == group.value.subQuestionId);
|
|
1056
|
+
if (question != null) {
|
|
1057
|
+
group.controls.answer.setValue(question.answerId, { emitEvent: false });
|
|
865
1058
|
}
|
|
866
1059
|
});
|
|
867
1060
|
});
|
|
868
|
-
this._surveyLibService.questionIsDisabledObsrv.pipe(filter(x => x.questionId == this.fCtrls.id.value)).subscribe(x => {
|
|
869
|
-
this.fCtrls.isDisabled.setValue(x.isDisabled);
|
|
870
|
-
});
|
|
871
|
-
this._surveyLibService.questionIsShowObsrv.pipe(filter(x => x.questionId == this.fCtrls.id.value)).subscribe(x => {
|
|
872
|
-
this.fCtrls.isShow.setValue(x.isShow);
|
|
873
|
-
});
|
|
874
1061
|
}
|
|
875
1062
|
onChangeAnswer(question, answer) {
|
|
876
1063
|
const index = this.fCtrls.subQuestionArray.value.findIndex(x => x.subQuestionId == question.subQuestionId);
|
|
877
1064
|
var subQuestionGroup = this.fCtrls.subQuestionArray.controls[index];
|
|
878
1065
|
subQuestionGroup.controls.answer.setValue(answer.answerId);
|
|
879
|
-
this.emitter.emit({
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
});
|
|
1066
|
+
// this.emitter.emit({
|
|
1067
|
+
// QuestionId: subQuestionGroup.value.subQuestionId,
|
|
1068
|
+
// Answer: subQuestionGroup.value.answer,
|
|
1069
|
+
// IsValid: subQuestionGroup.controls.answer.valid
|
|
1070
|
+
// });
|
|
884
1071
|
}
|
|
885
1072
|
convertToFormControl(element) {
|
|
886
1073
|
return element;
|
|
887
1074
|
}
|
|
888
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionMatrixTemplateComponent, deps: [{ token: i1.FormBuilder }, { token: SurveyLibService }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
889
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", type: QuestionMatrixTemplateComponent, selector: "lib-question-matrix-template", inputs: { setQuestion: "setQuestion" },
|
|
1075
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionMatrixTemplateComponent, deps: [{ token: i1.FormBuilder }, { token: SurveyLibService }, { token: i3.Store }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1076
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", type: QuestionMatrixTemplateComponent, selector: "lib-question-matrix-template", inputs: { setQuestion: "setQuestion" }, ngImport: i0, template: "<div class=\"quastion\" [attr.id]=\"'question_'+fCtrls.id.value\" style=\" border-collapse: collapse;\"\r\n[ngClass]=\"{'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 </h3>\r\n <div class=\"matrix-question\" [formGroup]=\"rForm\">\r\n <div class=\"matrix-table\" formArrayName=\"subQuestionArray\">\r\n <div class=\"matrix-head-row\">\r\n <div class=\"matrix-col\">\r\n </div>\r\n <div class=\"matrix-col\" *ngFor=\"let answers of surveyQuestion?.surveyAnswers\" >\r\n <span [innerHTML]=\"answers.answerTitle\"></span>\r\n </div>\r\n </div>\r\n\r\n <div class=\"matrix-row\" [attr.id]=\"'question_'+questionGroup.value.subQuestionId\"\r\n *ngFor=\"let questionGroup of fCtrls.subQuestionArray.controls ;let subQuestionIndex = index\"\r\n [ngClass]=\"{'invalid-question': questionGroup.controls.answer.invalid}\">\r\n <div class=\"matrix-col matrix-sub-quastion\" [innerHTML]=\"questionGroup.value.questionTitle\">\r\n </div>\r\n <div class=\"matrix-col answer__container\" *ngFor=\"let answer of surveyQuestion?.surveyAnswers;let answerIndex = index\">\r\n <div class=\"form-check form-check-radio form-check-inline\">\r\n <input class=\"form-check-input\" type=\"radio\" name=\"{{elemId}}__radio-btn-option_{{subQuestionIndex}}\"\r\n id=\"{{elemId}}__radio-btn_{{subQuestionIndex}}_{{answerIndex}}\" (change)=\"onChangeAnswer(questionGroup.value ,answer)\"\r\n value=\"{{answer.answerId}}\" [checked]=\"answer.answerId == questionGroup.value.answer\">\r\n <label class=\"form-check-label d-inline d-lg-none\" [innerHTML]=\"answer.answerTitle\"\r\n for=\"{{elemId}}__radio-btn_{{subQuestionIndex}}_{{answerIndex}}\"> </label>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n </div>\r\n\r\n </div>\r\n</div>", styles: ["@media (max-width: 767px){.quastion .quastion-title{position:sticky;top:150px;z-index:1000;padding:10px 20px;background-color:#4c3d8f;color:#fff;font-size:16px;box-shadow:4px 5px 5px #0000004d;border-radius:10px;-webkit-border-radius:10px;-moz-border-radius:10px;-ms-border-radius:10px;-o-border-radius:10px}.quastion .quastion-title:last-of-type(){position:static;z-index:initial}.quastion .matrix-question .matrix-table .matrix-row .matrix-col{width:100%!important}.matrix-table .matrix-row .matrix-col .form-check{flex-direction:row}.matrix-head-row{display:none!important}.answer__container.matrix-col{padding:5px 15px!important}.answer__container.matrix-col .form-check-radio .form-check-label{padding-right:15px!important}}\n"], dependencies: [{ kind: "directive", type: i4.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i5.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i5.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i5.FormArrayName, selector: "[formArrayName]", inputs: ["formArrayName"] }] }); }
|
|
890
1077
|
}
|
|
891
1078
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionMatrixTemplateComponent, decorators: [{
|
|
892
1079
|
type: Component,
|
|
893
|
-
args: [{ selector: 'lib-question-matrix-template', template: "<div class=\"quastion\" [attr.id]=\"'question_'+fCtrls.id.value\" style=\" border-collapse: collapse;\"\n[ngClass]=\"{'d-none':fCtrls.isShow.value != true}\">\n <h3 class=\"quastion-title \">\n <span [innerHTML]=\"surveyQuestion?.questionTitle\"></span>\n <span style=\"color: red;\" *ngIf=\"surveyQuestion.isRequired\">*</span>\n </h3>\n <div class=\"matrix-question\" [formGroup]=\"rForm\">\n <div class=\"matrix-table\" formArrayName=\"subQuestionArray\">\n <div class=\"matrix-head-row\">\n <div class=\"matrix-col\">\n </div>\n <div class=\"matrix-col\" *ngFor=\"let answers of surveyQuestion?.surveyAnswers\" >\n <span [innerHTML]=\"answers.answerTitle\"></span>\n </div>\n </div>\n\n <div class=\"matrix-row\" [attr.id]=\"'question_'+questionGroup.value.subQuestionId\"\n *ngFor=\"let questionGroup of fCtrls.subQuestionArray.controls ;let subQuestionIndex = index\"\n [ngClass]=\"{'invalid-question': questionGroup.controls.answer.invalid}\">\n <div class=\"matrix-col matrix-sub-quastion\" [innerHTML]=\"questionGroup.value.questionTitle\">\n </div>\n <div class=\"matrix-col answer__container\" *ngFor=\"let answer of surveyQuestion?.surveyAnswers;let answerIndex = index\">\n <div class=\"form-check form-check-radio form-check-inline\">\n <input class=\"form-check-input\" type=\"radio\" name=\"{{elemId}}__radio-btn-option_{{subQuestionIndex}}\"\n id=\"{{elemId}}__radio-btn_{{subQuestionIndex}}_{{answerIndex}}\" (change)=\"onChangeAnswer(questionGroup.value ,answer)\"\n value=\"{{answer.answerId}}\" [checked]=\"answer.answerId == questionGroup.value.answer\">\n <label class=\"form-check-label d-inline d-lg-none\" [innerHTML]=\"answer.answerTitle\"\n for=\"{{elemId}}__radio-btn_{{subQuestionIndex}}_{{answerIndex}}\"> </label>\n </div>\n </div>\n </div>\n\n </div>\n\n </div>\n</div>", styles: ["@media (max-width: 767px){.quastion .quastion-title{position:sticky;top:150px;z-index:1000;padding:10px 20px;background-color:#4c3d8f;color:#fff;font-size:16px;box-shadow:4px 5px 5px #0000004d;border-radius:10px;-webkit-border-radius:10px;-moz-border-radius:10px;-ms-border-radius:10px;-o-border-radius:10px}.quastion .quastion-title:last-of-type(){position:static;z-index:initial}.quastion .matrix-question .matrix-table .matrix-row .matrix-col{width:100%!important}.matrix-table .matrix-row .matrix-col .form-check{flex-direction:row}.matrix-head-row{display:none!important}.answer__container.matrix-col{padding:5px 15px!important}.answer__container.matrix-col .form-check-radio .form-check-label{padding-right:15px!important}}\n"] }]
|
|
894
|
-
}], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: SurveyLibService }]; }, propDecorators: {
|
|
895
|
-
type: Output
|
|
896
|
-
}], setQuestion: [{
|
|
1080
|
+
args: [{ selector: 'lib-question-matrix-template', template: "<div class=\"quastion\" [attr.id]=\"'question_'+fCtrls.id.value\" style=\" border-collapse: collapse;\"\r\n[ngClass]=\"{'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 </h3>\r\n <div class=\"matrix-question\" [formGroup]=\"rForm\">\r\n <div class=\"matrix-table\" formArrayName=\"subQuestionArray\">\r\n <div class=\"matrix-head-row\">\r\n <div class=\"matrix-col\">\r\n </div>\r\n <div class=\"matrix-col\" *ngFor=\"let answers of surveyQuestion?.surveyAnswers\" >\r\n <span [innerHTML]=\"answers.answerTitle\"></span>\r\n </div>\r\n </div>\r\n\r\n <div class=\"matrix-row\" [attr.id]=\"'question_'+questionGroup.value.subQuestionId\"\r\n *ngFor=\"let questionGroup of fCtrls.subQuestionArray.controls ;let subQuestionIndex = index\"\r\n [ngClass]=\"{'invalid-question': questionGroup.controls.answer.invalid}\">\r\n <div class=\"matrix-col matrix-sub-quastion\" [innerHTML]=\"questionGroup.value.questionTitle\">\r\n </div>\r\n <div class=\"matrix-col answer__container\" *ngFor=\"let answer of surveyQuestion?.surveyAnswers;let answerIndex = index\">\r\n <div class=\"form-check form-check-radio form-check-inline\">\r\n <input class=\"form-check-input\" type=\"radio\" name=\"{{elemId}}__radio-btn-option_{{subQuestionIndex}}\"\r\n id=\"{{elemId}}__radio-btn_{{subQuestionIndex}}_{{answerIndex}}\" (change)=\"onChangeAnswer(questionGroup.value ,answer)\"\r\n value=\"{{answer.answerId}}\" [checked]=\"answer.answerId == questionGroup.value.answer\">\r\n <label class=\"form-check-label d-inline d-lg-none\" [innerHTML]=\"answer.answerTitle\"\r\n for=\"{{elemId}}__radio-btn_{{subQuestionIndex}}_{{answerIndex}}\"> </label>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n </div>\r\n\r\n </div>\r\n</div>", styles: ["@media (max-width: 767px){.quastion .quastion-title{position:sticky;top:150px;z-index:1000;padding:10px 20px;background-color:#4c3d8f;color:#fff;font-size:16px;box-shadow:4px 5px 5px #0000004d;border-radius:10px;-webkit-border-radius:10px;-moz-border-radius:10px;-ms-border-radius:10px;-o-border-radius:10px}.quastion .quastion-title:last-of-type(){position:static;z-index:initial}.quastion .matrix-question .matrix-table .matrix-row .matrix-col{width:100%!important}.matrix-table .matrix-row .matrix-col .form-check{flex-direction:row}.matrix-head-row{display:none!important}.answer__container.matrix-col{padding:5px 15px!important}.answer__container.matrix-col .form-check-radio .form-check-label{padding-right:15px!important}}\n"] }]
|
|
1081
|
+
}], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: SurveyLibService }, { type: i3.Store }]; }, propDecorators: { setQuestion: [{
|
|
897
1082
|
type: Input
|
|
898
1083
|
}] } });
|
|
899
1084
|
|
|
@@ -905,34 +1090,35 @@ class QuestionBooleanTemplateComponent {
|
|
|
905
1090
|
return QuestionTypeEnum;
|
|
906
1091
|
}
|
|
907
1092
|
set setQuestion(value) {
|
|
908
|
-
this.surveyQuestion
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
1093
|
+
if (!this.surveyQuestion) {
|
|
1094
|
+
this.surveyQuestion = value.questionAllInfo;
|
|
1095
|
+
this.rForm.patchValue({
|
|
1096
|
+
id: value.questionId,
|
|
1097
|
+
name: value.questionAllInfo.questionName,
|
|
1098
|
+
title: value.questionAllInfo.questionTitle,
|
|
1099
|
+
typeId: value.questionAllInfo.questionTypeId,
|
|
1100
|
+
description: value.questionAllInfo.questionDescription,
|
|
1101
|
+
isDisabled: value.questionAllInfo.isReadOnly,
|
|
1102
|
+
isShow: value.questionAllInfo.isVisable
|
|
1103
|
+
});
|
|
1104
|
+
value.questionAllInfo.surveyAnswers.forEach(surveryAnswer => {
|
|
1105
|
+
this.fCtrls.answerArray.push(this._formBuilder.group({
|
|
1106
|
+
id: [surveryAnswer.answerId],
|
|
1107
|
+
title: [surveryAnswer.answerTitle],
|
|
1108
|
+
isSelected: [false]
|
|
1109
|
+
}));
|
|
1110
|
+
});
|
|
1111
|
+
if (value.isRequired == true) {
|
|
1112
|
+
this.fCtrls.answer.addValidators([Validators.required]);
|
|
1113
|
+
this.fCtrls.answer.updateValueAndValidity();
|
|
1114
|
+
}
|
|
929
1115
|
}
|
|
930
1116
|
}
|
|
931
|
-
constructor(_formBuilder, _surveyLibService) {
|
|
1117
|
+
constructor(_formBuilder, _surveyLibService, _Store) {
|
|
932
1118
|
this._formBuilder = _formBuilder;
|
|
933
1119
|
this._surveyLibService = _surveyLibService;
|
|
1120
|
+
this._Store = _Store;
|
|
934
1121
|
this.elemId = v4();
|
|
935
|
-
this.emitter = new EventEmitter();
|
|
936
1122
|
this.rForm = this._formBuilder.group({
|
|
937
1123
|
id: [null],
|
|
938
1124
|
name: [null],
|
|
@@ -946,30 +1132,33 @@ class QuestionBooleanTemplateComponent {
|
|
|
946
1132
|
});
|
|
947
1133
|
}
|
|
948
1134
|
ngOnInit() {
|
|
949
|
-
this.fCtrls.answer.valueChanges.pipe().pipe(debounceTime(200)).subscribe(value => {
|
|
1135
|
+
this.fCtrls.answer.valueChanges.pipe().pipe(debounceTime(200), distinctUntilChanged()).subscribe(value => {
|
|
950
1136
|
const formValue = this.rForm.value;
|
|
951
|
-
this.
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
});
|
|
1137
|
+
this._Store.dispatch(surveyActions.updateQuestionAnswer({
|
|
1138
|
+
questionId: formValue.id,
|
|
1139
|
+
answer: value,
|
|
1140
|
+
isValid: this.fCtrls.answer.valid
|
|
1141
|
+
}));
|
|
956
1142
|
});
|
|
957
|
-
this.fCtrls.
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
1143
|
+
this._Store.select(questionSelectors.pageQuestions).pipe(map(arr => arr.find(x => x.questionId == this.fCtrls.id.value)))
|
|
1144
|
+
.pipe(filter(x => x != null), pairwise()).subscribe(value => {
|
|
1145
|
+
const oldValue = value[0];
|
|
1146
|
+
const newValue = value[1];
|
|
1147
|
+
//updated answer
|
|
1148
|
+
if (oldValue?.answerId != newValue?.answerId) {
|
|
1149
|
+
this.fCtrls.answer.setValue(newValue?.answerId, { emitEvent: false });
|
|
1150
|
+
}
|
|
1151
|
+
//updated isDisabled
|
|
1152
|
+
if (oldValue?.isDisabled != newValue?.isDisabled) {
|
|
1153
|
+
this.fCtrls.isDisabled.setValue(newValue?.isDisabled);
|
|
1154
|
+
}
|
|
1155
|
+
//updated isShow
|
|
1156
|
+
if (oldValue?.isShow != newValue?.isShow) {
|
|
1157
|
+
this.fCtrls.isShow.setValue(newValue?.isShow);
|
|
1158
|
+
if (newValue?.isShow == false) {
|
|
1159
|
+
this.fCtrls.answer.setValue(null);
|
|
1160
|
+
}
|
|
966
1161
|
}
|
|
967
|
-
});
|
|
968
|
-
this._surveyLibService.questionIsDisabledObsrv.pipe(filter(x => x.questionId == this.fCtrls.id.value)).subscribe(x => {
|
|
969
|
-
this.fCtrls.isDisabled.setValue(x.isDisabled);
|
|
970
|
-
});
|
|
971
|
-
this._surveyLibService.questionIsShowObsrv.pipe(filter(x => x.questionId == this.fCtrls.id.value)).subscribe(x => {
|
|
972
|
-
this.fCtrls.isShow.setValue(x.isShow);
|
|
973
1162
|
});
|
|
974
1163
|
}
|
|
975
1164
|
onChangeAnswer(item) {
|
|
@@ -978,15 +1167,13 @@ class QuestionBooleanTemplateComponent {
|
|
|
978
1167
|
convertToFormControl(element) {
|
|
979
1168
|
return element;
|
|
980
1169
|
}
|
|
981
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionBooleanTemplateComponent, deps: [{ token: i1.FormBuilder }, { token: SurveyLibService }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
982
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", type: QuestionBooleanTemplateComponent, selector: "lib-question-boolean-template", inputs: { setQuestion: "setQuestion" },
|
|
1170
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionBooleanTemplateComponent, deps: [{ token: i1.FormBuilder }, { token: SurveyLibService }, { token: i3.Store }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1171
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", type: QuestionBooleanTemplateComponent, selector: "lib-question-boolean-template", inputs: { setQuestion: "setQuestion" }, ngImport: i0, template: "<div class=\"quastion\" [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]=\"fCtrls.title.value\"></span>\r\n <span style=\"color: red;\" *ngIf=\"surveyQuestion.isRequired\">*</span>\r\n </h3>\r\n <div class=\"radio-button-quastion\">\r\n <div class=\"form-check form-check-radio form-check-inline\"\r\n *ngFor=\"let item of fCtrls.answerArray.controls ;let i = index\">\r\n <input class=\"form-check-input\" type=\"radio\" (change)=\"onChangeAnswer(item.value)\"\r\n [disabled]=\"fCtrls.isDisabled.value\" name=\"{{elemId}}__radio-btn-option\"\r\n id=\"{{elemId}}__radio-btn_{{i}}\" [checked]=\"item.value.isSelected == true? true : null\">\r\n <label class=\"form-check-label\" for=\"{{elemId}}__radio-btn_{{i}}\">{{item.value.title}}</label>\r\n </div>\r\n </div>\r\n</div>", styles: [""], dependencies: [{ kind: "directive", type: i4.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] }); }
|
|
983
1172
|
}
|
|
984
1173
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionBooleanTemplateComponent, decorators: [{
|
|
985
1174
|
type: Component,
|
|
986
|
-
args: [{ selector: 'lib-question-boolean-template', template: "<div class=\"quastion\" [attr.id]=\"'question_'+fCtrls.id.value\"\n [ngClass]=\"{'invalid-question': fCtrls.answer.invalid , 'd-none':fCtrls.isShow.value != true}\">\n <h3 class=\"quastion-title \">\n <span [innerHTML]=\"fCtrls.title.value\"></span>\n <span style=\"color: red;\" *ngIf=\"surveyQuestion.isRequired\">*</span>\n </h3>\n <div class=\"radio-button-quastion\">\n <div class=\"form-check form-check-radio form-check-inline\"\n *ngFor=\"let item of fCtrls.answerArray.controls ;let i = index\">\n <input class=\"form-check-input\" type=\"radio\" (change)=\"onChangeAnswer(item.value)\"\n [disabled]=\"fCtrls.isDisabled.value\" name=\"{{elemId}}__radio-btn-option\"\n id=\"{{elemId}}__radio-btn_{{i}}\" [checked]=\"item.value.isSelected == true? true : null\">\n <label class=\"form-check-label\" for=\"{{elemId}}__radio-btn_{{i}}\">{{item.value.title}}</label>\n </div>\n </div>\n</div>" }]
|
|
987
|
-
}], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: SurveyLibService }]; }, propDecorators: {
|
|
988
|
-
type: Output
|
|
989
|
-
}], setQuestion: [{
|
|
1175
|
+
args: [{ selector: 'lib-question-boolean-template', template: "<div class=\"quastion\" [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]=\"fCtrls.title.value\"></span>\r\n <span style=\"color: red;\" *ngIf=\"surveyQuestion.isRequired\">*</span>\r\n </h3>\r\n <div class=\"radio-button-quastion\">\r\n <div class=\"form-check form-check-radio form-check-inline\"\r\n *ngFor=\"let item of fCtrls.answerArray.controls ;let i = index\">\r\n <input class=\"form-check-input\" type=\"radio\" (change)=\"onChangeAnswer(item.value)\"\r\n [disabled]=\"fCtrls.isDisabled.value\" name=\"{{elemId}}__radio-btn-option\"\r\n id=\"{{elemId}}__radio-btn_{{i}}\" [checked]=\"item.value.isSelected == true? true : null\">\r\n <label class=\"form-check-label\" for=\"{{elemId}}__radio-btn_{{i}}\">{{item.value.title}}</label>\r\n </div>\r\n </div>\r\n</div>" }]
|
|
1176
|
+
}], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: SurveyLibService }, { type: i3.Store }]; }, propDecorators: { setQuestion: [{
|
|
990
1177
|
type: Input
|
|
991
1178
|
}] } });
|
|
992
1179
|
|
|
@@ -998,33 +1185,35 @@ class QuestionDropdownMultiTemplateComponent {
|
|
|
998
1185
|
return QuestionTypeEnum;
|
|
999
1186
|
}
|
|
1000
1187
|
set setQuestion(value) {
|
|
1001
|
-
this.surveyQuestion
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1188
|
+
if (!this.surveyQuestion) {
|
|
1189
|
+
this.surveyQuestion = value.questionAllInfo;
|
|
1190
|
+
this.rForm.patchValue({
|
|
1191
|
+
id: value.questionId,
|
|
1192
|
+
name: value.questionAllInfo.questionName,
|
|
1193
|
+
title: value.questionAllInfo.questionTitle,
|
|
1194
|
+
typeId: value.questionAllInfo.questionTypeId,
|
|
1195
|
+
description: value.questionAllInfo.questionDescription,
|
|
1196
|
+
isDisabled: value.questionAllInfo.isReadOnly,
|
|
1197
|
+
isShow: value.questionAllInfo.isVisable
|
|
1198
|
+
});
|
|
1199
|
+
value.questionAllInfo.surveyAnswers.forEach(surveryAnswer => {
|
|
1200
|
+
this.fCtrls.answerArray.push(this._formBuilder.group({
|
|
1201
|
+
id: [surveryAnswer.answerId],
|
|
1202
|
+
title: [surveryAnswer.answerTitle],
|
|
1203
|
+
isSelected: [false]
|
|
1204
|
+
}));
|
|
1205
|
+
});
|
|
1206
|
+
if (value.isRequired == true) {
|
|
1207
|
+
this.fCtrls.answer.addValidators([Validators$1.required]);
|
|
1208
|
+
this.fCtrls.answer.updateValueAndValidity();
|
|
1209
|
+
}
|
|
1021
1210
|
}
|
|
1022
1211
|
}
|
|
1023
|
-
constructor(_formBuilder, _surveyLibService) {
|
|
1212
|
+
constructor(_formBuilder, _surveyLibService, _Store) {
|
|
1024
1213
|
this._formBuilder = _formBuilder;
|
|
1025
1214
|
this._surveyLibService = _surveyLibService;
|
|
1215
|
+
this._Store = _Store;
|
|
1026
1216
|
this.elemId = v4();
|
|
1027
|
-
this.emitter = new EventEmitter();
|
|
1028
1217
|
this.rForm = this._formBuilder.group({
|
|
1029
1218
|
id: [null],
|
|
1030
1219
|
name: [null],
|
|
@@ -1040,39 +1229,44 @@ class QuestionDropdownMultiTemplateComponent {
|
|
|
1040
1229
|
ngOnInit() {
|
|
1041
1230
|
this.fCtrls.answer.valueChanges.pipe().pipe(debounceTime(200)).subscribe(value => {
|
|
1042
1231
|
const formValue = this.rForm.value;
|
|
1043
|
-
this.
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
});
|
|
1048
|
-
});
|
|
1049
|
-
this.fCtrls.answer.setValue(null);
|
|
1050
|
-
this._surveyLibService.surveyAnswersObsrv
|
|
1051
|
-
.pipe(map(x => x.defaultAnswers.filter(x => x.QuestionId == this.fCtrls.id.value)))
|
|
1052
|
-
.pipe(filter(x => x.length > 0)).pipe(map(x => x.at(0)))
|
|
1053
|
-
.subscribe(answer => {
|
|
1054
|
-
const distinctArray = answer.AnswerIdArr.filter((n, i) => answer.AnswerIdArr.indexOf(n) === i);
|
|
1055
|
-
this.fCtrls.answer.setValue(distinctArray);
|
|
1056
|
-
});
|
|
1057
|
-
this._surveyLibService.questionIsDisabledObsrv.pipe(filter(x => x.questionId == this.fCtrls.id.value)).subscribe(x => {
|
|
1058
|
-
this.fCtrls.isDisabled.setValue(x.isDisabled);
|
|
1232
|
+
this._Store.dispatch(surveyActions.updateQuestionAnswer({
|
|
1233
|
+
questionId: formValue.id,
|
|
1234
|
+
answer: value,
|
|
1235
|
+
isValid: this.fCtrls.answer.valid
|
|
1236
|
+
}));
|
|
1059
1237
|
});
|
|
1060
|
-
this.
|
|
1061
|
-
|
|
1238
|
+
this._Store.select(questionSelectors.pageQuestions).pipe(map(arr => arr.find(x => x.questionId == this.fCtrls.id.value)))
|
|
1239
|
+
.pipe(filter(x => x != null), pairwise()).subscribe(value => {
|
|
1240
|
+
const oldValue = value[0];
|
|
1241
|
+
const newValue = value[1];
|
|
1242
|
+
//updated answer
|
|
1243
|
+
if (oldValue?.answerIdArr != newValue?.answerIdArr) {
|
|
1244
|
+
const distinctArray = newValue?.answerIdArr.filter((n, i) => newValue?.answerIdArr.indexOf(n) === i);
|
|
1245
|
+
this.fCtrls.answer.setValue(distinctArray, { emitEvent: false });
|
|
1246
|
+
}
|
|
1247
|
+
//updated isDisabled
|
|
1248
|
+
if (oldValue?.isDisabled != newValue?.isDisabled) {
|
|
1249
|
+
this.fCtrls.isDisabled.setValue(newValue?.isDisabled);
|
|
1250
|
+
}
|
|
1251
|
+
//updated isShow
|
|
1252
|
+
if (oldValue?.isShow != newValue?.isShow) {
|
|
1253
|
+
this.fCtrls.isShow.setValue(newValue?.isShow);
|
|
1254
|
+
if (newValue?.isShow == false) {
|
|
1255
|
+
this.fCtrls.answer.setValue(null);
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1062
1258
|
});
|
|
1063
1259
|
}
|
|
1064
1260
|
convertToFormControl(element) {
|
|
1065
1261
|
return element;
|
|
1066
1262
|
}
|
|
1067
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionDropdownMultiTemplateComponent, deps: [{ token: i1.FormBuilder }, { token: SurveyLibService }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1068
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", type: QuestionDropdownMultiTemplateComponent, selector: "lib-question-dropdown-multi-template", inputs: { setQuestion: "setQuestion" },
|
|
1263
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionDropdownMultiTemplateComponent, deps: [{ token: i1.FormBuilder }, { token: SurveyLibService }, { token: i3.Store }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1264
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", type: QuestionDropdownMultiTemplateComponent, selector: "lib-question-dropdown-multi-template", inputs: { setQuestion: "setQuestion" }, ngImport: i0, template: "<div class=\"quastion\" [attr.id]=\"'question_'+fCtrls.id.value\" [ngClass]=\"{'invalid-question': fCtrls.answer.invalid , 'd-none':fCtrls.isShow.value != true}\">\r\n <h3 class=\"quastion-title \">\r\n <span [innerHTML]=\"fCtrls.title.value\"></span>\r\n <span style=\"color: red;\" *ngIf=\"surveyQuestion.isRequired\">*</span>\r\n </h3>\r\n <div class=\"text-quastion text-quastion__dropdown\">\r\n <ng-select [items]=\"this.fCtrls.answerArray.value\" bindValue=\"id\" bindLabel=\"title\" class=\"form-control\"\r\n [formControl]=\"convertToFormControl(fCtrls.answer)\" [disabled]=\"fCtrls.isDisabled.value\" [multiple]=\"true\">\r\n </ng-select>\r\n </div>\r\n</div>\r\n", styles: [".text-quastion .form-control{padding:10px}\n"], 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: i5.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i5.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: i6.NgSelectComponent, selector: "ng-select", inputs: ["bindLabel", "bindValue", "markFirst", "placeholder", "notFoundText", "typeToSearchText", "addTagText", "loadingText", "clearAllText", "appearance", "dropdownPosition", "appendTo", "loading", "closeOnSelect", "hideSelected", "selectOnTab", "openOnEnter", "maxSelectedItems", "groupBy", "groupValue", "bufferAmount", "virtualScroll", "selectableGroup", "selectableGroupAsModel", "searchFn", "trackByFn", "clearOnBackspace", "labelForId", "inputAttrs", "tabIndex", "readonly", "searchWhileComposing", "minTermLength", "editableSearchTerm", "keyDownFn", "typeahead", "multiple", "addTag", "searchable", "clearable", "isOpen", "items", "compareWith", "clearSearchOnAdd", "deselectOnClick"], outputs: ["blur", "focus", "change", "open", "close", "search", "clear", "add", "remove", "scroll", "scrollToEnd"] }] }); }
|
|
1069
1265
|
}
|
|
1070
1266
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionDropdownMultiTemplateComponent, decorators: [{
|
|
1071
1267
|
type: Component,
|
|
1072
|
-
args: [{ selector: 'lib-question-dropdown-multi-template', template: "<div class=\"quastion\" [attr.id]=\"'question_'+fCtrls.id.value\" [ngClass]=\"{'invalid-question': fCtrls.answer.invalid , 'd-none':fCtrls.isShow.value != true}\">\n <h3 class=\"quastion-title \">\n <span [innerHTML]=\"fCtrls.title.value\"></span>\n <span style=\"color: red;\" *ngIf=\"surveyQuestion.isRequired\">*</span>\n </h3>\n <div class=\"text-quastion text-quastion__dropdown\">\n <ng-select [items]=\"this.fCtrls.answerArray.value\" bindValue=\"id\" bindLabel=\"title\" class=\"form-control\"\n [formControl]=\"convertToFormControl(fCtrls.answer)\" [disabled]=\"fCtrls.isDisabled.value\" [multiple]=\"true\">\n </ng-select>\n </div>\n</div>\n", styles: [".text-quastion .form-control{padding:10px}\n"] }]
|
|
1073
|
-
}], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: SurveyLibService }]; }, propDecorators: {
|
|
1074
|
-
type: Output
|
|
1075
|
-
}], setQuestion: [{
|
|
1268
|
+
args: [{ selector: 'lib-question-dropdown-multi-template', template: "<div class=\"quastion\" [attr.id]=\"'question_'+fCtrls.id.value\" [ngClass]=\"{'invalid-question': fCtrls.answer.invalid , 'd-none':fCtrls.isShow.value != true}\">\r\n <h3 class=\"quastion-title \">\r\n <span [innerHTML]=\"fCtrls.title.value\"></span>\r\n <span style=\"color: red;\" *ngIf=\"surveyQuestion.isRequired\">*</span>\r\n </h3>\r\n <div class=\"text-quastion text-quastion__dropdown\">\r\n <ng-select [items]=\"this.fCtrls.answerArray.value\" bindValue=\"id\" bindLabel=\"title\" class=\"form-control\"\r\n [formControl]=\"convertToFormControl(fCtrls.answer)\" [disabled]=\"fCtrls.isDisabled.value\" [multiple]=\"true\">\r\n </ng-select>\r\n </div>\r\n</div>\r\n", styles: [".text-quastion .form-control{padding:10px}\n"] }]
|
|
1269
|
+
}], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: SurveyLibService }, { type: i3.Store }]; }, propDecorators: { setQuestion: [{
|
|
1076
1270
|
type: Input
|
|
1077
1271
|
}] } });
|
|
1078
1272
|
|
|
@@ -1101,6 +1295,23 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImpor
|
|
|
1101
1295
|
args: [LibConfigService]
|
|
1102
1296
|
}] }]; } });
|
|
1103
1297
|
|
|
1298
|
+
class FindQuestionPipe {
|
|
1299
|
+
transform(arr, questionId) {
|
|
1300
|
+
if (arr) {
|
|
1301
|
+
return arr.find(x => x.questionId == questionId);
|
|
1302
|
+
}
|
|
1303
|
+
return null;
|
|
1304
|
+
}
|
|
1305
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: FindQuestionPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
1306
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "16.1.7", ngImport: i0, type: FindQuestionPipe, name: "findQuestion" }); }
|
|
1307
|
+
}
|
|
1308
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: FindQuestionPipe, decorators: [{
|
|
1309
|
+
type: Pipe,
|
|
1310
|
+
args: [{
|
|
1311
|
+
name: 'findQuestion'
|
|
1312
|
+
}]
|
|
1313
|
+
}] });
|
|
1314
|
+
|
|
1104
1315
|
class QuestionCascadeTemplateComponent {
|
|
1105
1316
|
get fCtrls() {
|
|
1106
1317
|
return this.rForm.controls;
|
|
@@ -1112,15 +1323,19 @@ class QuestionCascadeTemplateComponent {
|
|
|
1112
1323
|
return this.fCtrls.questionArr;
|
|
1113
1324
|
}
|
|
1114
1325
|
set setQuestion(value) {
|
|
1115
|
-
this.
|
|
1326
|
+
if (this.surveyQuestionArr?.length == 0) {
|
|
1327
|
+
this.setQuestions(value.questionAllInfo);
|
|
1328
|
+
}
|
|
1116
1329
|
}
|
|
1117
|
-
constructor(_formBuilder, _surveyLibService, _ApiService) {
|
|
1330
|
+
constructor(_formBuilder, _surveyLibService, _ApiService, _Store) {
|
|
1118
1331
|
this._formBuilder = _formBuilder;
|
|
1119
1332
|
this._surveyLibService = _surveyLibService;
|
|
1120
1333
|
this._ApiService = _ApiService;
|
|
1334
|
+
this._Store = _Store;
|
|
1121
1335
|
this.surveyQuestionArr = [];
|
|
1122
|
-
this.
|
|
1123
|
-
this.
|
|
1336
|
+
this.pageQuestions$ = this._Store.select(questionSelectors.pageQuestions);
|
|
1337
|
+
this.pageId = null;
|
|
1338
|
+
this.questionGroupId = null;
|
|
1124
1339
|
this.isPre = false;
|
|
1125
1340
|
this.surveyLanguageId = null;
|
|
1126
1341
|
this.applicantKey = null;
|
|
@@ -1129,9 +1344,9 @@ class QuestionCascadeTemplateComponent {
|
|
|
1129
1344
|
});
|
|
1130
1345
|
}
|
|
1131
1346
|
ngOnInit() {
|
|
1132
|
-
this.fCtrls.questionArr.statusChanges.subscribe(v => {
|
|
1133
|
-
|
|
1134
|
-
})
|
|
1347
|
+
// this.fCtrls.questionArr.statusChanges.subscribe(v => {
|
|
1348
|
+
// console.log(v);
|
|
1349
|
+
// })
|
|
1135
1350
|
}
|
|
1136
1351
|
onUpdateAnswer(model) {
|
|
1137
1352
|
if (this.surveyQuestionArr.length > 1) {
|
|
@@ -1144,7 +1359,7 @@ class QuestionCascadeTemplateComponent {
|
|
|
1144
1359
|
for (let index = 0; index < sortDeletedArr.length; index++) {
|
|
1145
1360
|
const elementIndex = sortDeletedArr[index];
|
|
1146
1361
|
const questionId = this.surveyQuestionArr[elementIndex].questionId;
|
|
1147
|
-
this.
|
|
1362
|
+
this._Store.dispatch(surveyActions.removeQuestion({ questionId: questionId }));
|
|
1148
1363
|
this.surveyQuestionArr = this.surveyQuestionArr.filter(x => x.questionId != questionId);
|
|
1149
1364
|
this.questionFormArray.removeAt(elementIndex);
|
|
1150
1365
|
}
|
|
@@ -1157,12 +1372,29 @@ class QuestionCascadeTemplateComponent {
|
|
|
1157
1372
|
surveyLanguageId: this.surveyLanguageId
|
|
1158
1373
|
}).subscribe(res => {
|
|
1159
1374
|
if (res.errors.filter(x => x.code == 17).length == 0) {
|
|
1375
|
+
this._Store.dispatch(surveyActions.addQuestion({ question: {
|
|
1376
|
+
surveyPageId: this.pageId,
|
|
1377
|
+
questionId: res.questionId,
|
|
1378
|
+
questionType: res.questionTypeId,
|
|
1379
|
+
inputTypeId: res.surveyAnswers[0].inputTypeId,
|
|
1380
|
+
isMatrixGroup: false,
|
|
1381
|
+
answerId: null,
|
|
1382
|
+
answerIdArr: null,
|
|
1383
|
+
answerText: null,
|
|
1384
|
+
isRequired: res.isRequired,
|
|
1385
|
+
isValid: null,
|
|
1386
|
+
isDisabled: res.isReadOnly,
|
|
1387
|
+
isShow: res.isVisable,
|
|
1388
|
+
isDisabled_default: res.isReadOnly,
|
|
1389
|
+
isShow_default: res.isVisable,
|
|
1390
|
+
questionGroupId: this.questionGroupId,
|
|
1391
|
+
parentQuestionId: model.QuestionId,
|
|
1392
|
+
questionAllInfo: res
|
|
1393
|
+
} }));
|
|
1160
1394
|
this.setQuestions(res);
|
|
1161
|
-
this._surveyLibService.setAddQuestion(res, this.pageIndex);
|
|
1162
1395
|
}
|
|
1163
1396
|
});
|
|
1164
1397
|
}
|
|
1165
|
-
this.emitter.emit(model);
|
|
1166
1398
|
}
|
|
1167
1399
|
identify(index, item) {
|
|
1168
1400
|
return item.id;
|
|
@@ -1179,16 +1411,17 @@ class QuestionCascadeTemplateComponent {
|
|
|
1179
1411
|
group.controls.answer.updateValueAndValidity();
|
|
1180
1412
|
}
|
|
1181
1413
|
this.fCtrls.questionArr.push(group);
|
|
1414
|
+
console.log(this.fCtrls.questionArr.value);
|
|
1182
1415
|
}
|
|
1183
|
-
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 }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1184
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", type: QuestionCascadeTemplateComponent, selector: "lib-question-cascade-template", inputs: {
|
|
1416
|
+
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 }); }
|
|
1417
|
+
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.value ; trackBy:identify ; let i = index\">\r\n <lib-question-dropdown-template #questionDropdownTemplate [setQuestion]=\"(pageQuestions$ |async) |findQuestion :item.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" }] }); }
|
|
1185
1418
|
}
|
|
1186
1419
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionCascadeTemplateComponent, decorators: [{
|
|
1187
1420
|
type: Component,
|
|
1188
|
-
args: [{ selector: 'lib-question-cascade-template', template: "<ng-container *ngFor=\"let item of questionFormArray.value ; trackBy:identify ; let i = index\">\n
|
|
1189
|
-
}], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: SurveyLibService }, { type: ApiService }]; }, propDecorators: {
|
|
1190
|
-
type:
|
|
1191
|
-
}],
|
|
1421
|
+
args: [{ selector: 'lib-question-cascade-template', template: "<ng-container *ngFor=\"let item of questionFormArray.value ; trackBy:identify ; let i = index\">\r\n <lib-question-dropdown-template #questionDropdownTemplate [setQuestion]=\"(pageQuestions$ |async) |findQuestion :item.id \"\r\n (emitter)=\"onUpdateAnswer($event)\" >\r\n </lib-question-dropdown-template> \r\n</ng-container>" }]
|
|
1422
|
+
}], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: SurveyLibService }, { type: ApiService }, { type: i3.Store }]; }, propDecorators: { pageId: [{
|
|
1423
|
+
type: Input
|
|
1424
|
+
}], questionGroupId: [{
|
|
1192
1425
|
type: Input
|
|
1193
1426
|
}], isPre: [{
|
|
1194
1427
|
type: Input
|
|
@@ -1200,6 +1433,20 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImpor
|
|
|
1200
1433
|
type: Input
|
|
1201
1434
|
}] } });
|
|
1202
1435
|
|
|
1436
|
+
class FilterQuestionPipe {
|
|
1437
|
+
transform(arr, questionGroupId) {
|
|
1438
|
+
return arr.filter(x => x.questionGroupId == questionGroupId && x.parentQuestionId == null);
|
|
1439
|
+
}
|
|
1440
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: FilterQuestionPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
1441
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "16.1.7", ngImport: i0, type: FilterQuestionPipe, name: "filterQuestion" }); }
|
|
1442
|
+
}
|
|
1443
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: FilterQuestionPipe, decorators: [{
|
|
1444
|
+
type: Pipe,
|
|
1445
|
+
args: [{
|
|
1446
|
+
name: 'filterQuestion'
|
|
1447
|
+
}]
|
|
1448
|
+
}] });
|
|
1449
|
+
|
|
1203
1450
|
class SurveryLibComponent {
|
|
1204
1451
|
get fCtrls() {
|
|
1205
1452
|
return this.rForm.controls;
|
|
@@ -1207,55 +1454,25 @@ class SurveryLibComponent {
|
|
|
1207
1454
|
get questionTypeEnum() {
|
|
1208
1455
|
return QuestionTypeEnum;
|
|
1209
1456
|
}
|
|
1210
|
-
get isFirstPage() {
|
|
1211
|
-
if (this.showedSurveyPages.length > 0) {
|
|
1212
|
-
return this.showedSurveyPages.findIndex(x => x == this.fCtrls.currentPageIndex.value) == 0;
|
|
1213
|
-
}
|
|
1214
|
-
return true;
|
|
1215
|
-
}
|
|
1216
|
-
get isLastPage() {
|
|
1217
|
-
return this.showedSurveyPages.findIndex(x => x == this.fCtrls.currentPageIndex.value) == (this.showedSurveyPages.length - 1);
|
|
1218
|
-
}
|
|
1219
|
-
get showedSurveyPages() {
|
|
1220
|
-
var pageArr = [];
|
|
1221
|
-
for (let index = 0; index < this.fCtrls.questionArray.value.length; index++) {
|
|
1222
|
-
const question = this.fCtrls.questionArray.value[index];
|
|
1223
|
-
if (question.isShow == true) {
|
|
1224
|
-
if (question.questionType != this.questionTypeEnum.Matrix) {
|
|
1225
|
-
pageArr.push(question.surveyPageIndex);
|
|
1226
|
-
}
|
|
1227
|
-
else if (question.questionType == this.questionTypeEnum.Matrix && question.isMatrixGroup == true) {
|
|
1228
|
-
pageArr.push(question.surveyPageIndex);
|
|
1229
|
-
}
|
|
1230
|
-
}
|
|
1231
|
-
}
|
|
1232
|
-
const distinctArray = pageArr.filter((n, i) => pageArr.indexOf(n) === i);
|
|
1233
|
-
return distinctArray.sort((a, b) => a - b);
|
|
1234
|
-
}
|
|
1235
|
-
get curruntShowedSurveyPages() {
|
|
1236
|
-
return this.showedSurveyPages.findIndex(x => x == this.fCtrls.currentPageIndex.value) + 1;
|
|
1237
|
-
}
|
|
1238
1457
|
get surveyResult() {
|
|
1239
1458
|
return {
|
|
1240
|
-
currentPageIndex: this.fCtrls.
|
|
1241
|
-
answers: this.
|
|
1242
|
-
return {
|
|
1243
|
-
SurveyPageIndex: x.surveyPageIndex,
|
|
1244
|
-
QuestionId: x.questionId,
|
|
1245
|
-
QuestionType: x.questionType,
|
|
1246
|
-
AnswerId: x.answerId,
|
|
1247
|
-
AnswerText: x.answerText,
|
|
1248
|
-
AnswerIdArr: x.answerIdArr
|
|
1249
|
-
};
|
|
1250
|
-
})
|
|
1459
|
+
currentPageIndex: this.fCtrls.currentPageId.value,
|
|
1460
|
+
answers: this.questionAnswerArr
|
|
1251
1461
|
};
|
|
1252
1462
|
}
|
|
1253
|
-
constructor(_surveyLibService, _formBuilder, _checkRuleExpsUsecase) {
|
|
1463
|
+
constructor(_surveyLibService, _Store, _formBuilder, _checkRuleExpsUsecase) {
|
|
1254
1464
|
this._surveyLibService = _surveyLibService;
|
|
1465
|
+
this._Store = _Store;
|
|
1255
1466
|
this._formBuilder = _formBuilder;
|
|
1256
1467
|
this._checkRuleExpsUsecase = _checkRuleExpsUsecase;
|
|
1257
1468
|
this.surveryLibraryDivId = v4();
|
|
1258
1469
|
this.reloadDefaultAnswerId = v4();
|
|
1470
|
+
this.questionAnswerArr = [];
|
|
1471
|
+
this.pageQuestionGroups$ = this._Store.select(questionGroupSelectors.pageQuestionGroups);
|
|
1472
|
+
this.pageQuestions$ = this._Store.select(questionSelectors.pageQuestions);
|
|
1473
|
+
this.isFirstPage$ = this._Store.select(surveySelectors.isFirstPage);
|
|
1474
|
+
this.isLastPage$ = this._Store.select(surveySelectors.isLastPage);
|
|
1475
|
+
this.curruntShowedSurveyPages$ = this._Store.select(surveySelectors.selectedPageIndex).pipe(map(x => x + 1));
|
|
1259
1476
|
this.isPre = false;
|
|
1260
1477
|
this.surveyLanguageId = null;
|
|
1261
1478
|
this.applicantKey = null;
|
|
@@ -1263,119 +1480,59 @@ class SurveryLibComponent {
|
|
|
1263
1480
|
this.surveyResultEmit = new EventEmitter();
|
|
1264
1481
|
this.selectLanguageEmit = new EventEmitter();
|
|
1265
1482
|
this.rForm = this._formBuilder.group({
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1483
|
+
currentPageId: new FormControl(0),
|
|
1484
|
+
showedSurveyPages: new FormControl([])
|
|
1485
|
+
});
|
|
1486
|
+
this._Store.select(questionSelectors.questionAnswers).subscribe(arr => {
|
|
1487
|
+
this.questionAnswerArr = arr;
|
|
1269
1488
|
});
|
|
1270
1489
|
}
|
|
1271
1490
|
ngAfterViewInit() {
|
|
1272
1491
|
}
|
|
1492
|
+
questionIdentify(index, item) {
|
|
1493
|
+
return item.questionId;
|
|
1494
|
+
}
|
|
1273
1495
|
ngOnInit() {
|
|
1274
|
-
this.
|
|
1275
|
-
this.fCtrls.
|
|
1276
|
-
this.fCtrls.ruleQuestionArray.clear();
|
|
1277
|
-
this.surveyData = null;
|
|
1278
|
-
if (survey != null) {
|
|
1279
|
-
this.surveyData = survey;
|
|
1280
|
-
this.loadQuestions(survey);
|
|
1281
|
-
}
|
|
1496
|
+
this._Store.select(surveySelectors.selectedPageId).subscribe(value => {
|
|
1497
|
+
this.fCtrls.currentPageId.setValue(value);
|
|
1282
1498
|
});
|
|
1283
|
-
this.
|
|
1284
|
-
this.
|
|
1285
|
-
});
|
|
1286
|
-
this._surveyLibService.removeQuestionObsrv.subscribe(res => {
|
|
1287
|
-
const index = this.fCtrls.questionArray.value.findIndex(x => x.questionId == res.questionId);
|
|
1288
|
-
this.fCtrls.questionArray.removeAt(index);
|
|
1499
|
+
this._Store.select(surveySelectors.showedSurveyPages).subscribe(value => {
|
|
1500
|
+
this.fCtrls.showedSurveyPages.setValue(value);
|
|
1289
1501
|
});
|
|
1290
1502
|
}
|
|
1291
1503
|
onPaggingNext() {
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1504
|
+
this._Store.select(questionSelectors.pageQuestions).pipe(take(1)).subscribe(arr => {
|
|
1505
|
+
var invalidRecords = this.haveInValidateQuestions(arr);
|
|
1506
|
+
if (invalidRecords.length == 0) {
|
|
1507
|
+
const nextPageId = this.getNextShowedPage();
|
|
1508
|
+
if (nextPageId != null) {
|
|
1509
|
+
this._Store.dispatch(surveyActions.updatePageId({ pageId: nextPageId }));
|
|
1510
|
+
$('html, body').animate({
|
|
1511
|
+
scrollTop: $(`#survery-card-${this.surveryLibraryDivId}`).offset().top - 30
|
|
1512
|
+
}, 300);
|
|
1513
|
+
}
|
|
1514
|
+
else {
|
|
1515
|
+
this.surveyResultEmit.emit(this.questionAnswerArr);
|
|
1516
|
+
}
|
|
1303
1517
|
}
|
|
1304
1518
|
else {
|
|
1305
|
-
var
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
QuestionType: x.questionType,
|
|
1310
|
-
AnswerId: x.answerId,
|
|
1311
|
-
AnswerText: x.answerText,
|
|
1312
|
-
AnswerIdArr: x.answerIdArr
|
|
1313
|
-
};
|
|
1314
|
-
});
|
|
1315
|
-
this.surveyResultEmit.emit(questionArr);
|
|
1519
|
+
var firstQuestion = $('.invalid-question')[0];
|
|
1520
|
+
$('html, body').animate({
|
|
1521
|
+
scrollTop: $(firstQuestion).offset().top - 250
|
|
1522
|
+
}, 300);
|
|
1316
1523
|
}
|
|
1317
|
-
}
|
|
1318
|
-
else {
|
|
1319
|
-
var firstQuestion = invalidRecords[0];
|
|
1320
|
-
$('html, body').animate({
|
|
1321
|
-
scrollTop: $(`#question_${firstQuestion.questionId}`).offset().top - 120
|
|
1322
|
-
}, 2000);
|
|
1323
|
-
}
|
|
1324
|
-
}
|
|
1325
|
-
onPaggingBack() {
|
|
1326
|
-
const prevPageIndex = this.getPrevShowedPage();
|
|
1327
|
-
if (prevPageIndex != null) {
|
|
1328
|
-
this.fCtrls.currentPageIndex.setValue(prevPageIndex);
|
|
1329
|
-
}
|
|
1330
|
-
}
|
|
1331
|
-
onUpdateAnswers(model) {
|
|
1332
|
-
model.forEach(elem => {
|
|
1333
|
-
this.onUpdateAnswer(elem);
|
|
1334
1524
|
});
|
|
1335
1525
|
}
|
|
1336
|
-
|
|
1337
|
-
const
|
|
1338
|
-
if (
|
|
1339
|
-
|
|
1340
|
-
questionGroup.controls.isValid.setValue(model.IsValid);
|
|
1341
|
-
if (questionGroup.value.questionType == this.questionTypeEnum.TextInput) {
|
|
1342
|
-
questionGroup.patchValue({
|
|
1343
|
-
answerId: model.SurveyAnswerId,
|
|
1344
|
-
answerText: model.Answer
|
|
1345
|
-
});
|
|
1346
|
-
}
|
|
1347
|
-
else if (questionGroup.value.questionType == this.questionTypeEnum.CheckBox || questionGroup.value.questionType == this.questionTypeEnum.DropDownMulti) {
|
|
1348
|
-
questionGroup.controls.answerIdArr.setValue(model.Answer);
|
|
1349
|
-
}
|
|
1350
|
-
else {
|
|
1351
|
-
questionGroup.controls.answerId.setValue(model.Answer);
|
|
1352
|
-
}
|
|
1353
|
-
if (this.fCtrls.ruleQuestionArray.value.findIndex(x => x.questionId == model.QuestionId) > -1) {
|
|
1354
|
-
this.checkRules(questionGroup.value.questionId);
|
|
1355
|
-
}
|
|
1526
|
+
onPaggingBack() {
|
|
1527
|
+
const prevPageId = this.getPrevShowedPage();
|
|
1528
|
+
if (prevPageId != null) {
|
|
1529
|
+
this._Store.dispatch(surveyActions.updatePageId({ pageId: prevPageId }));
|
|
1356
1530
|
}
|
|
1357
1531
|
}
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
page.surveyQuestionGroups.forEach(group => {
|
|
1361
|
-
group.surveyQuestions.forEach(question => {
|
|
1362
|
-
this.addQuestionGroup(question, pageIndex);
|
|
1363
|
-
});
|
|
1364
|
-
});
|
|
1365
|
-
});
|
|
1366
|
-
survey.surveyRules.forEach(rule => {
|
|
1367
|
-
rule.ruleExps.forEach(ruleExp => {
|
|
1368
|
-
this.fCtrls.ruleQuestionArray.push(this._formBuilder.group({
|
|
1369
|
-
questionId: ruleExp.questionId,
|
|
1370
|
-
ruleId: rule.ruleId
|
|
1371
|
-
}));
|
|
1372
|
-
});
|
|
1373
|
-
});
|
|
1374
|
-
}
|
|
1375
|
-
haveInValidateQuestions() {
|
|
1376
|
-
const currentPageIndex = this.fCtrls.currentPageIndex.value;
|
|
1532
|
+
haveInValidateQuestions(questionArr) {
|
|
1533
|
+
const formValue = this.rForm.value;
|
|
1377
1534
|
var invalidRecords = [];
|
|
1378
|
-
var arr =
|
|
1535
|
+
var arr = questionArr.filter(x => x.isDisabled == false && x.isShow == true);
|
|
1379
1536
|
arr.map(x => {
|
|
1380
1537
|
if (x.isRequired == true && x.isValid != true && x.isMatrixGroup != true) {
|
|
1381
1538
|
invalidRecords.push(x);
|
|
@@ -1389,159 +1546,38 @@ class SurveryLibComponent {
|
|
|
1389
1546
|
}
|
|
1390
1547
|
});
|
|
1391
1548
|
if (invalidRecords.length > 0) {
|
|
1392
|
-
$(`#survey-page_${
|
|
1549
|
+
$(`#survey-page_${formValue.currentPageId}`).addClass('survey-page_submitted');
|
|
1550
|
+
}
|
|
1551
|
+
else {
|
|
1552
|
+
$(`#survey-page_${formValue.currentPageId}`).removeClass('survey-page_submitted');
|
|
1393
1553
|
}
|
|
1394
1554
|
return invalidRecords;
|
|
1395
1555
|
}
|
|
1396
|
-
checkRules(questionId) {
|
|
1397
|
-
var selectedRuleIdArr = this.rForm.value.ruleQuestionArray.filter(x => x.questionId == questionId).map(x => Number(x.ruleId));
|
|
1398
|
-
var arr = this.surveyData.surveyRules.filter(x => selectedRuleIdArr.find(c => c == x.ruleId) != null);
|
|
1399
|
-
arr.forEach(rule => {
|
|
1400
|
-
this._checkRuleExpsUsecase.execute({
|
|
1401
|
-
ruleExps: rule.ruleExps,
|
|
1402
|
-
questions: this.fCtrls.questionArray.value,
|
|
1403
|
-
currentPageIndex: this.fCtrls.currentPageIndex.value
|
|
1404
|
-
}).subscribe(result => {
|
|
1405
|
-
var isPassed = result.exprestionResultArr.filter(x => x == false).length == 0;
|
|
1406
|
-
if (isPassed) {
|
|
1407
|
-
rule.ruleResultQuestions.forEach(resultQuestion => {
|
|
1408
|
-
const index = this.fCtrls.questionArray.value.findIndex(x => x.questionId == resultQuestion.questionId);
|
|
1409
|
-
var questionGroup = this.fCtrls.questionArray.at(index);
|
|
1410
|
-
if (rule.logicActionId == LogicActionEnum.Show) {
|
|
1411
|
-
questionGroup.controls.isShow.setValue(true);
|
|
1412
|
-
this._surveyLibService.setQuestionIsShow(questionGroup.value.questionId, true);
|
|
1413
|
-
}
|
|
1414
|
-
else if (rule.logicActionId == LogicActionEnum.Hide) {
|
|
1415
|
-
questionGroup.controls.isShow.setValue(false);
|
|
1416
|
-
this._surveyLibService.setQuestionIsShow(questionGroup.value.questionId, false);
|
|
1417
|
-
}
|
|
1418
|
-
else if (rule.logicActionId == LogicActionEnum.Enable) {
|
|
1419
|
-
questionGroup.controls.isDisabled.setValue(false);
|
|
1420
|
-
this._surveyLibService.setQuestionIsDisabled(questionGroup.value.questionId, false);
|
|
1421
|
-
}
|
|
1422
|
-
else if (rule.logicActionId == LogicActionEnum.Disable) {
|
|
1423
|
-
questionGroup.controls.isDisabled.setValue(true);
|
|
1424
|
-
this._surveyLibService.setQuestionIsDisabled(questionGroup.value.questionId, true);
|
|
1425
|
-
}
|
|
1426
|
-
else if (rule.logicActionId == LogicActionEnum.SetAnswer) {
|
|
1427
|
-
}
|
|
1428
|
-
if (questionGroup.value.questionType == QuestionTypeEnum.Matrix && questionGroup.value.isMatrixGroup == true) {
|
|
1429
|
-
var subQuestions = this.fCtrls.questionArray.value.filter(x => x.surveyPageIndex == questionGroup.value.surveyPageIndex && x.isMatrixGroup == false);
|
|
1430
|
-
subQuestions.forEach(subQuestion => {
|
|
1431
|
-
const index = this.fCtrls.questionArray.value.findIndex(x => x.questionId == subQuestion.questionId);
|
|
1432
|
-
var subQuestionGroup = this.fCtrls.questionArray.at(index);
|
|
1433
|
-
subQuestionGroup.patchValue({
|
|
1434
|
-
isShow: questionGroup.value.isShow,
|
|
1435
|
-
isDisabled: questionGroup.value.isDisabled
|
|
1436
|
-
});
|
|
1437
|
-
this._surveyLibService.setQuestionIsDisabled(subQuestion.questionId, subQuestion.isDisabled);
|
|
1438
|
-
this._surveyLibService.setQuestionIsShow(subQuestion.questionId, subQuestion.isShow);
|
|
1439
|
-
});
|
|
1440
|
-
}
|
|
1441
|
-
});
|
|
1442
|
-
}
|
|
1443
|
-
else {
|
|
1444
|
-
rule.ruleResultQuestions.forEach(resultQuestion => {
|
|
1445
|
-
const index = this.fCtrls.questionArray.value.findIndex(x => x.questionId == resultQuestion.questionId);
|
|
1446
|
-
var questionGroup = this.fCtrls.questionArray.at(index);
|
|
1447
|
-
questionGroup.patchValue({
|
|
1448
|
-
isShow: questionGroup.value.isShow_default,
|
|
1449
|
-
isDisabled: questionGroup.value.isDisabled_default
|
|
1450
|
-
});
|
|
1451
|
-
this._surveyLibService.setQuestionIsDisabled(questionGroup.value.questionId, questionGroup.value.isDisabled_default);
|
|
1452
|
-
this._surveyLibService.setQuestionIsShow(questionGroup.value.questionId, questionGroup.value.isShow_default);
|
|
1453
|
-
});
|
|
1454
|
-
}
|
|
1455
|
-
});
|
|
1456
|
-
});
|
|
1457
|
-
}
|
|
1458
1556
|
getNextShowedPage() {
|
|
1459
|
-
|
|
1460
|
-
var showedPages =
|
|
1461
|
-
var nextShowedPages = showedPages.filter(x => x >
|
|
1557
|
+
const formValue = this.rForm.value;
|
|
1558
|
+
var showedPages = formValue.showedSurveyPages;
|
|
1559
|
+
var nextShowedPages = showedPages.filter(x => x > formValue.currentPageId);
|
|
1462
1560
|
if (nextShowedPages.length > 0) {
|
|
1463
1561
|
return nextShowedPages[0];
|
|
1464
1562
|
}
|
|
1465
1563
|
return null;
|
|
1466
1564
|
}
|
|
1467
1565
|
getPrevShowedPage() {
|
|
1468
|
-
|
|
1469
|
-
var showedPages =
|
|
1470
|
-
var prevShowedPages = showedPages.filter(x => x <
|
|
1566
|
+
const formValue = this.rForm.value;
|
|
1567
|
+
var showedPages = formValue.showedSurveyPages;
|
|
1568
|
+
var prevShowedPages = showedPages.filter(x => x < formValue.currentPageId);
|
|
1471
1569
|
if (prevShowedPages.length > 0) {
|
|
1472
1570
|
return prevShowedPages[prevShowedPages.length - 1];
|
|
1473
1571
|
}
|
|
1474
1572
|
return null;
|
|
1475
1573
|
}
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
this.fCtrls.questionArray.push(this._formBuilder.group({
|
|
1479
|
-
surveyPageIndex: pageIndex,
|
|
1480
|
-
questionId: [question.questionId],
|
|
1481
|
-
questionType: [question.questionTypeId],
|
|
1482
|
-
inputTypeId: [question.surveyAnswers[0].inputTypeId],
|
|
1483
|
-
isMatrixGroup: [false],
|
|
1484
|
-
answerId: [null],
|
|
1485
|
-
answerIdArr: [null],
|
|
1486
|
-
answerText: [null],
|
|
1487
|
-
isRequired: [question.isRequired],
|
|
1488
|
-
isValid: [null],
|
|
1489
|
-
isDisabled: [question.isReadOnly],
|
|
1490
|
-
isShow: [question.isVisable],
|
|
1491
|
-
isDisabled_default: [question.isReadOnly],
|
|
1492
|
-
isShow_default: [question.isVisable]
|
|
1493
|
-
}));
|
|
1494
|
-
}
|
|
1495
|
-
else {
|
|
1496
|
-
this.fCtrls.questionArray.push(this._formBuilder.group({
|
|
1497
|
-
surveyPageIndex: pageIndex,
|
|
1498
|
-
questionId: [question.questionId],
|
|
1499
|
-
questionType: [question.questionTypeId],
|
|
1500
|
-
inputTypeId: [question.surveyAnswers[0].inputTypeId],
|
|
1501
|
-
isMatrixGroup: [true],
|
|
1502
|
-
answerId: [null],
|
|
1503
|
-
answerIdArr: [null],
|
|
1504
|
-
answerText: [null],
|
|
1505
|
-
isRequired: [question.isRequired],
|
|
1506
|
-
isValid: [null],
|
|
1507
|
-
isDisabled: [question.isReadOnly],
|
|
1508
|
-
isShow: [question.isVisable],
|
|
1509
|
-
isDisabled_default: [question.isReadOnly],
|
|
1510
|
-
isShow_default: [question.isVisable],
|
|
1511
|
-
}));
|
|
1512
|
-
question.surveySubQuestions.forEach(subQuestion => {
|
|
1513
|
-
this.fCtrls.questionArray.push(this._formBuilder.group({
|
|
1514
|
-
surveyPageIndex: pageIndex,
|
|
1515
|
-
questionId: [subQuestion.questionId],
|
|
1516
|
-
questionType: [question.questionTypeId],
|
|
1517
|
-
inputTypeId: [question.surveyAnswers[0].inputTypeId],
|
|
1518
|
-
isMatrixGroup: [false],
|
|
1519
|
-
answerId: [null],
|
|
1520
|
-
answerIdArr: [null],
|
|
1521
|
-
answerText: [null],
|
|
1522
|
-
isRequired: [question.isRequired],
|
|
1523
|
-
isValid: [null],
|
|
1524
|
-
isDisabled: [question.isReadOnly],
|
|
1525
|
-
isShow: [question.isVisable],
|
|
1526
|
-
isDisabled_default: [question.isReadOnly],
|
|
1527
|
-
isShow_default: [question.isVisable]
|
|
1528
|
-
}));
|
|
1529
|
-
});
|
|
1530
|
-
}
|
|
1531
|
-
}
|
|
1532
|
-
loadQuestionUpdates(pageIndex) {
|
|
1533
|
-
this.fCtrls.questionArray.value.filter(x => x.surveyPageIndex == pageIndex).forEach(question => {
|
|
1534
|
-
this._surveyLibService.setQuestionIsShow(question.questionId, question.isShow);
|
|
1535
|
-
this._surveyLibService.setQuestionIsDisabled(question.questionId, question.isDisabled);
|
|
1536
|
-
});
|
|
1537
|
-
}
|
|
1538
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: SurveryLibComponent, deps: [{ token: SurveyLibService }, { token: i1.FormBuilder }, { token: CheckRuleExpsUsecase }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1539
|
-
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 *ngFor=\"let surveyPage of surveyData?.surveyPages; let surveyPageIndex = index\"\r\n [attr.id]=\"'survey-page_'+surveyPageIndex\" [ngClass]=\"{'d-none': surveyPageIndex != fCtrls.currentPageIndex.value}\">\r\n <ng-container *ngFor=\"let item of surveyPage.surveyQuestionGroups\">\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 *ngFor=\"let question of item.surveyQuestions\">\r\n <lib-question-boolean-template #questionBooleanTemplate [setQuestion]=\"question\"\r\n (emitter)=\"onUpdateAnswer($event)\" *ngIf=\"question.questionTypeId == questionTypeEnum.Boolean\">\r\n </lib-question-boolean-template>\r\n\r\n <lib-question-text-template #questionTextTemplate [setQuestion]=\"question\"\r\n (emitter)=\"onUpdateAnswer($event)\" *ngIf=\"question.questionTypeId == questionTypeEnum.TextInput\"\r\n [isTextArea]=\"question.isAdvanceTextArea\" [isArabicLang]=\"isArabicLang\"></lib-question-text-template>\r\n\r\n <lib-question-radio-button-template #questionRadioButtonTemplate [setQuestion]=\"question\"\r\n (emitter)=\"onUpdateAnswer($event)\" *ngIf=\"question.questionTypeId == questionTypeEnum.RadioButton\">\r\n </lib-question-radio-button-template>\r\n\r\n <lib-question-dropdown-template #questionDropdownTemplate [setQuestion]=\"question\"\r\n (emitter)=\"onUpdateAnswer($event)\"\r\n *ngIf=\"question.questionTypeId == questionTypeEnum.DropDown\"></lib-question-dropdown-template>\r\n\r\n <lib-question-dropdown-multi-template [setQuestion]=\"question\" (emitter)=\"onUpdateAnswer($event)\"\r\n *ngIf=\"question.questionTypeId == questionTypeEnum.DropDownMulti\">\r\n </lib-question-dropdown-multi-template>\r\n\r\n <lib-question-check-box-template #questionCheckBoxTemplate [setQuestion]=\"question\"\r\n (emitter)=\"onUpdateAnswer($event)\" *ngIf=\"question.questionTypeId == questionTypeEnum.CheckBox\">\r\n </lib-question-check-box-template>\r\n\r\n <lib-question-matrix-template #questionMatrixTemplate [setQuestion]=\"question\"\r\n (emitter)=\"onUpdateAnswer($event)\" *ngIf=\"question.questionTypeId == questionTypeEnum.Matrix\">\r\n </lib-question-matrix-template>\r\n\r\n <lib-question-cascade-template #questionCascadeTemplate [setQuestion]=\"question\"\r\n (emitter)=\"onUpdateAnswer($event)\" *ngIf=\"question.questionTypeId == questionTypeEnum.Cascade\"\r\n [applicantKey]=\"applicantKey\" [isPre]=\"isPre\" [surveyLanguageId]=\"surveyLanguageId\"\r\n [pageIndex]=\"surveyPageIndex\"></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=\"surveyData != null\">\r\n <div class=\"container\" style=\" justify-content: start;\">\r\n <div class=\"survay-pagination fw-bold\">\r\n <span>{{curruntShowedSurveyPages}}</span>\r\n <span class=\"ms-2 me-2\">{{isArabicLang ? '\u0645\u0646' : 'of'}} </span>\r\n <span>{{showedSurveyPages?.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: i3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: QuestionTextTemplateComponent, selector: "lib-question-text-template", inputs: ["isArabicLang", "isTextArea", "setQuestion", "isDisabled"], outputs: ["emitter"] }, { kind: "component", type: QuestionRadioButtonTemplateComponent, selector: "lib-question-radio-button-template", inputs: ["setQuestion"], outputs: ["emitter"] }, { kind: "component", type: QuestionCheckBoxTemplateComponent, selector: "lib-question-check-box-template", inputs: ["setQuestion"], outputs: ["emitter"] }, { kind: "component", type: QuestionDropdownTemplateComponent, selector: "lib-question-dropdown-template", inputs: ["setQuestion"], outputs: ["emitter"] }, { kind: "component", type: QuestionMatrixTemplateComponent, selector: "lib-question-matrix-template", inputs: ["setQuestion"], outputs: ["emitter"] }, { kind: "component", type: QuestionBooleanTemplateComponent, selector: "lib-question-boolean-template", inputs: ["setQuestion"], outputs: ["emitter"] }, { kind: "component", type: QuestionDropdownMultiTemplateComponent, selector: "lib-question-dropdown-multi-template", inputs: ["setQuestion"], outputs: ["emitter"] }, { kind: "component", type: QuestionCascadeTemplateComponent, selector: "lib-question-cascade-template", inputs: ["pageIndex", "isPre", "surveyLanguageId", "applicantKey", "setQuestion"], outputs: ["emitter"] }] }); }
|
|
1574
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: SurveryLibComponent, deps: [{ token: SurveyLibService }, { token: i3.Store }, { token: i5.FormBuilder }, { token: CheckRuleExpsUsecase }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1575
|
+
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-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: "pipe", type: i4.AsyncPipe, name: "async" }, { kind: "pipe", type: FilterQuestionPipe, name: "filterQuestion" }] }); }
|
|
1540
1576
|
}
|
|
1541
1577
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: SurveryLibComponent, decorators: [{
|
|
1542
1578
|
type: Component,
|
|
1543
|
-
args: [{ selector: 'lib-survery-lib', template: "<div id=\"survery-card-{{surveryLibraryDivId}}\" class=\"survay-card\">\r\n <div
|
|
1544
|
-
}], ctorParameters: function () { return [{ type: SurveyLibService }, { type:
|
|
1579
|
+
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-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"] }]
|
|
1580
|
+
}], ctorParameters: function () { return [{ type: SurveyLibService }, { type: i3.Store }, { type: i5.FormBuilder }, { type: CheckRuleExpsUsecase }]; }, propDecorators: { isPre: [{
|
|
1545
1581
|
type: Input
|
|
1546
1582
|
}], surveyLanguageId: [{
|
|
1547
1583
|
type: Input
|
|
@@ -1555,20 +1591,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImpor
|
|
|
1555
1591
|
type: Output
|
|
1556
1592
|
}] } });
|
|
1557
1593
|
|
|
1558
|
-
class FilterQuestionPipe {
|
|
1559
|
-
transform(value, questionArr) {
|
|
1560
|
-
return questionArr.find(x => x.questionId == value.questionId);
|
|
1561
|
-
}
|
|
1562
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: FilterQuestionPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
1563
|
-
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "16.1.7", ngImport: i0, type: FilterQuestionPipe, name: "filterQuestion" }); }
|
|
1564
|
-
}
|
|
1565
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: FilterQuestionPipe, decorators: [{
|
|
1566
|
-
type: Pipe,
|
|
1567
|
-
args: [{
|
|
1568
|
-
name: 'filterQuestion'
|
|
1569
|
-
}]
|
|
1570
|
-
}] });
|
|
1571
|
-
|
|
1572
1594
|
class DefaultQuestionAnswerPipe {
|
|
1573
1595
|
transform(value, questionId, reloadId) {
|
|
1574
1596
|
if (value != null) {
|
|
@@ -1603,13 +1625,109 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImpor
|
|
|
1603
1625
|
}]
|
|
1604
1626
|
}] });
|
|
1605
1627
|
|
|
1628
|
+
const { selectAll, selectIds } = questionAdapter.getSelectors();
|
|
1629
|
+
const initialSurveyState = {
|
|
1630
|
+
selectedPageId: null,
|
|
1631
|
+
questionGroupArr: questionGroupAdapter.getInitialState(),
|
|
1632
|
+
questionArr: questionAdapter.getInitialState(),
|
|
1633
|
+
ruleArr: ruleAdapter.getInitialState()
|
|
1634
|
+
};
|
|
1635
|
+
const _surveyReducer = createReducer(initialSurveyState, on(surveyActions.loadSurvey, (state, props) => {
|
|
1636
|
+
return {
|
|
1637
|
+
...state,
|
|
1638
|
+
questionArr: questionAdapter.setAll(props.questionArr, state.questionArr),
|
|
1639
|
+
questionGroupArr: questionGroupAdapter.setAll(props.questionGroupArr, state.questionGroupArr),
|
|
1640
|
+
ruleArr: ruleAdapter.setAll(props.ruleArr, state.ruleArr),
|
|
1641
|
+
selectedPageId: props.selectedPageId
|
|
1642
|
+
};
|
|
1643
|
+
}), on(surveyActions.addQuestion, (state, props) => {
|
|
1644
|
+
return {
|
|
1645
|
+
...state,
|
|
1646
|
+
questionArr: questionAdapter.addOne(props.question, state.questionArr)
|
|
1647
|
+
};
|
|
1648
|
+
}), on(surveyActions.updateQuestionAnswer, (state, props) => {
|
|
1649
|
+
const question = selectAll(state.questionArr).find(x => x.questionId == props.questionId);
|
|
1650
|
+
if (question) {
|
|
1651
|
+
var updateModel;
|
|
1652
|
+
if (question.questionType == QuestionTypeEnum.TextInput) {
|
|
1653
|
+
updateModel = {
|
|
1654
|
+
id: props.questionId,
|
|
1655
|
+
changes: {
|
|
1656
|
+
answerId: question.questionAllInfo.surveyAnswers[0].answerId,
|
|
1657
|
+
answerText: props.answer,
|
|
1658
|
+
isValid: props.isValid
|
|
1659
|
+
}
|
|
1660
|
+
};
|
|
1661
|
+
}
|
|
1662
|
+
else if (question.questionType == QuestionTypeEnum.CheckBox || question.questionType == QuestionTypeEnum.DropDownMulti) {
|
|
1663
|
+
updateModel = {
|
|
1664
|
+
id: props.questionId,
|
|
1665
|
+
changes: {
|
|
1666
|
+
answerIdArr: props.answer,
|
|
1667
|
+
isValid: props.isValid
|
|
1668
|
+
}
|
|
1669
|
+
};
|
|
1670
|
+
}
|
|
1671
|
+
else {
|
|
1672
|
+
updateModel = {
|
|
1673
|
+
id: props.questionId,
|
|
1674
|
+
changes: {
|
|
1675
|
+
answerId: props.answer,
|
|
1676
|
+
isValid: props.isValid
|
|
1677
|
+
}
|
|
1678
|
+
};
|
|
1679
|
+
}
|
|
1680
|
+
return {
|
|
1681
|
+
...state,
|
|
1682
|
+
questionArr: questionAdapter.updateOne(updateModel, state.questionArr)
|
|
1683
|
+
};
|
|
1684
|
+
}
|
|
1685
|
+
return {
|
|
1686
|
+
...state
|
|
1687
|
+
};
|
|
1688
|
+
}), on(surveyActions.updateQuestionShow, (state, props) => {
|
|
1689
|
+
return {
|
|
1690
|
+
...state,
|
|
1691
|
+
questionArr: questionAdapter.updateOne({
|
|
1692
|
+
id: props.questionId,
|
|
1693
|
+
changes: {
|
|
1694
|
+
isShow: props.isShow
|
|
1695
|
+
}
|
|
1696
|
+
}, state.questionArr)
|
|
1697
|
+
};
|
|
1698
|
+
}), on(surveyActions.updateQuestionDisable, (state, props) => {
|
|
1699
|
+
const question = selectAll(state.questionArr).find(x => x.questionId == props.questionId);
|
|
1700
|
+
return {
|
|
1701
|
+
...state,
|
|
1702
|
+
questionArr: questionAdapter.updateOne({
|
|
1703
|
+
id: props.questionId,
|
|
1704
|
+
changes: {
|
|
1705
|
+
isDisabled: props.isDisabled
|
|
1706
|
+
}
|
|
1707
|
+
}, state.questionArr)
|
|
1708
|
+
};
|
|
1709
|
+
}), on(surveyActions.removeQuestion, (state, props) => {
|
|
1710
|
+
return {
|
|
1711
|
+
...state,
|
|
1712
|
+
questionArr: questionAdapter.removeOne(props.questionId, state.questionArr)
|
|
1713
|
+
};
|
|
1714
|
+
}), on(surveyActions.updatePageId, (state, props) => {
|
|
1715
|
+
return {
|
|
1716
|
+
...state,
|
|
1717
|
+
selectedPageId: props.pageId
|
|
1718
|
+
};
|
|
1719
|
+
}));
|
|
1720
|
+
function surveyReducer(state, action) {
|
|
1721
|
+
return _surveyReducer(state, action);
|
|
1722
|
+
}
|
|
1723
|
+
|
|
1606
1724
|
class SurveryLibModule {
|
|
1607
1725
|
static forRoot(config) {
|
|
1608
1726
|
return {
|
|
1609
1727
|
ngModule: SurveryLibModule,
|
|
1610
1728
|
providers: [
|
|
1611
1729
|
{ provide: LibConfigService, useValue: config }
|
|
1612
|
-
]
|
|
1730
|
+
],
|
|
1613
1731
|
};
|
|
1614
1732
|
}
|
|
1615
1733
|
static forChild() {
|
|
@@ -1631,8 +1749,12 @@ class SurveryLibModule {
|
|
|
1631
1749
|
DefaultQuestionAnswersPipe,
|
|
1632
1750
|
TextBoxTypeAttrPipe,
|
|
1633
1751
|
QuestionCascadeTemplateComponent,
|
|
1634
|
-
MaskedForMinMaxDirective
|
|
1635
|
-
|
|
1752
|
+
MaskedForMinMaxDirective,
|
|
1753
|
+
FindQuestionPipe], imports: [CommonModule, HttpClientModule, ReactiveFormsModule, FormsModule, NgsFormsModule, NgSelectModule, i3.StoreFeatureModule, i2.EffectsFeatureModule], exports: [SurveryLibComponent,
|
|
1754
|
+
StoreModule] }); }
|
|
1755
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: SurveryLibModule, imports: [CommonModule, HttpClientModule, ReactiveFormsModule, FormsModule, NgsFormsModule, NgSelectModule,
|
|
1756
|
+
StoreModule.forFeature('survey-lib', surveyReducer),
|
|
1757
|
+
EffectsModule.forFeature([]), StoreModule] }); }
|
|
1636
1758
|
}
|
|
1637
1759
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: SurveryLibModule, decorators: [{
|
|
1638
1760
|
type: NgModule,
|
|
@@ -1651,13 +1773,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImpor
|
|
|
1651
1773
|
DefaultQuestionAnswersPipe,
|
|
1652
1774
|
TextBoxTypeAttrPipe,
|
|
1653
1775
|
QuestionCascadeTemplateComponent,
|
|
1654
|
-
MaskedForMinMaxDirective
|
|
1776
|
+
MaskedForMinMaxDirective,
|
|
1777
|
+
FindQuestionPipe
|
|
1655
1778
|
],
|
|
1656
1779
|
imports: [
|
|
1657
|
-
CommonModule, HttpClientModule, ReactiveFormsModule, FormsModule, NgsFormsModule, NgSelectModule
|
|
1780
|
+
CommonModule, HttpClientModule, ReactiveFormsModule, FormsModule, NgsFormsModule, NgSelectModule,
|
|
1781
|
+
StoreModule.forFeature('survey-lib', surveyReducer),
|
|
1782
|
+
EffectsModule.forFeature([])
|
|
1658
1783
|
],
|
|
1659
1784
|
exports: [
|
|
1660
|
-
SurveryLibComponent
|
|
1785
|
+
SurveryLibComponent,
|
|
1786
|
+
StoreModule
|
|
1661
1787
|
]
|
|
1662
1788
|
}]
|
|
1663
1789
|
}] });
|