survery-lib 0.0.5 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2022/lib/components/question-boolean-template/question-boolean-template.component.mjs +11 -3
- package/esm2022/lib/components/question-check-box-template/question-check-box-template.component.mjs +13 -5
- package/esm2022/lib/components/question-dropdown-template/question-dropdown-template.component.mjs +11 -3
- package/esm2022/lib/components/question-matrix-template/question-matrix-template.component.mjs +15 -5
- package/esm2022/lib/components/question-radio-button-template/question-radio-button-template.component.mjs +11 -3
- package/esm2022/lib/components/question-text-template/question-text-template.component.mjs +22 -3
- package/esm2022/lib/pipes/filter-question.pipe.mjs +16 -0
- package/esm2022/lib/survery-lib.component.mjs +121 -27
- package/esm2022/lib/survery-lib.module.mjs +6 -3
- package/esm2022/lib/usecases/base/use-case.mjs +2 -0
- package/esm2022/lib/usecases/check-rule-exps.usecase.mjs +154 -0
- package/esm2022/shared/dtos/rule-exp.dto.mjs +1 -1
- package/esm2022/shared/enums/Logic-Property.enum.mjs +14 -0
- package/esm2022/shared/enums/logic-action.enum.mjs +9 -0
- package/esm2022/shared/enums/operator.enum.mjs +6 -0
- package/esm2022/shared/form-interfaces/survery-lib.form-interface.mjs +1 -1
- package/fesm2022/survery-lib.mjs +391 -45
- package/fesm2022/survery-lib.mjs.map +1 -1
- package/lib/components/question-boolean-template/question-boolean-template.component.d.ts +3 -1
- package/lib/components/question-check-box-template/question-check-box-template.component.d.ts +3 -1
- package/lib/components/question-dropdown-template/question-dropdown-template.component.d.ts +3 -1
- package/lib/components/question-matrix-template/question-matrix-template.component.d.ts +3 -1
- package/lib/components/question-radio-button-template/question-radio-button-template.component.d.ts +3 -1
- package/lib/components/question-text-template/question-text-template.component.d.ts +4 -1
- package/lib/pipes/filter-question.pipe.d.ts +9 -0
- package/lib/survery-lib.component.d.ts +6 -4
- package/lib/survery-lib.module.d.ts +6 -5
- package/lib/usecases/base/use-case.d.ts +7 -0
- package/lib/usecases/check-rule-exps.usecase.d.ts +21 -0
- package/package.json +1 -1
- package/shared/dtos/rule-exp.dto.d.ts +4 -2
- package/shared/enums/Logic-Property.enum.d.ts +12 -0
- package/shared/enums/logic-action.enum.d.ts +7 -0
- package/shared/enums/operator.enum.d.ts +4 -0
- package/shared/form-interfaces/survery-lib.form-interface.d.ts +17 -4
package/fesm2022/survery-lib.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Injectable, EventEmitter, Component, Output, Input, NgModule } from '@angular/core';
|
|
3
|
-
import { Subject, BehaviorSubject, debounceTime, distinctUntilChanged
|
|
2
|
+
import { Injectable, EventEmitter, Component, Output, Input, Pipe, NgModule } from '@angular/core';
|
|
3
|
+
import { Subject, of, BehaviorSubject, debounceTime, distinctUntilChanged } from 'rxjs';
|
|
4
4
|
import * as i1 from '@ng-stack/forms';
|
|
5
5
|
import { NgsFormsModule } from '@ng-stack/forms';
|
|
6
6
|
import * as i3 from '@angular/common';
|
|
@@ -20,6 +20,15 @@ var QuestionTypeEnum;
|
|
|
20
20
|
QuestionTypeEnum[QuestionTypeEnum["Matrix"] = 6] = "Matrix";
|
|
21
21
|
})(QuestionTypeEnum || (QuestionTypeEnum = {}));
|
|
22
22
|
|
|
23
|
+
var LogicActionEnum;
|
|
24
|
+
(function (LogicActionEnum) {
|
|
25
|
+
LogicActionEnum[LogicActionEnum["Show"] = 1] = "Show";
|
|
26
|
+
LogicActionEnum[LogicActionEnum["Hide"] = 2] = "Hide";
|
|
27
|
+
LogicActionEnum[LogicActionEnum["Enable"] = 3] = "Enable";
|
|
28
|
+
LogicActionEnum[LogicActionEnum["Disable"] = 4] = "Disable";
|
|
29
|
+
LogicActionEnum[LogicActionEnum["SetAnswer"] = 5] = "SetAnswer";
|
|
30
|
+
})(LogicActionEnum || (LogicActionEnum = {}));
|
|
31
|
+
|
|
23
32
|
class SurveyLibService {
|
|
24
33
|
get surveyDataObsrv() {
|
|
25
34
|
return this.surveyDataSubject.asObservable();
|
|
@@ -40,6 +49,174 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImpor
|
|
|
40
49
|
}]
|
|
41
50
|
}], ctorParameters: function () { return []; } });
|
|
42
51
|
|
|
52
|
+
var LogicPropertyEnum;
|
|
53
|
+
(function (LogicPropertyEnum) {
|
|
54
|
+
LogicPropertyEnum[LogicPropertyEnum["GreaterThan"] = 1] = "GreaterThan";
|
|
55
|
+
LogicPropertyEnum[LogicPropertyEnum["GreaterThanOrEqual"] = 2] = "GreaterThanOrEqual";
|
|
56
|
+
LogicPropertyEnum[LogicPropertyEnum["LessThan"] = 3] = "LessThan";
|
|
57
|
+
LogicPropertyEnum[LogicPropertyEnum["LessThanOrEqual"] = 4] = "LessThanOrEqual";
|
|
58
|
+
LogicPropertyEnum[LogicPropertyEnum["Equal"] = 5] = "Equal";
|
|
59
|
+
LogicPropertyEnum[LogicPropertyEnum["NotEqual"] = 6] = "NotEqual";
|
|
60
|
+
LogicPropertyEnum[LogicPropertyEnum["IsEmpty"] = 9] = "IsEmpty";
|
|
61
|
+
LogicPropertyEnum[LogicPropertyEnum["IsNotEmpty"] = 10] = "IsNotEmpty";
|
|
62
|
+
LogicPropertyEnum[LogicPropertyEnum["AnyOf"] = 11] = "AnyOf";
|
|
63
|
+
LogicPropertyEnum[LogicPropertyEnum["Then"] = 12] = "Then";
|
|
64
|
+
})(LogicPropertyEnum || (LogicPropertyEnum = {}));
|
|
65
|
+
|
|
66
|
+
var OperatorEnum;
|
|
67
|
+
(function (OperatorEnum) {
|
|
68
|
+
OperatorEnum[OperatorEnum["Or"] = 7] = "Or";
|
|
69
|
+
OperatorEnum[OperatorEnum["And"] = 8] = "And";
|
|
70
|
+
})(OperatorEnum || (OperatorEnum = {}));
|
|
71
|
+
|
|
72
|
+
class CheckRuleExpsUsecase {
|
|
73
|
+
constructor() {
|
|
74
|
+
}
|
|
75
|
+
execute(params) {
|
|
76
|
+
var useCaseResult = {
|
|
77
|
+
exprestionResultArr: []
|
|
78
|
+
};
|
|
79
|
+
params.ruleExps.forEach(ruleExp => {
|
|
80
|
+
const index = params.questions.findIndex(x => x.questionId == ruleExp.questionId);
|
|
81
|
+
var questionGroupValue = params.questions.at(index);
|
|
82
|
+
var result;
|
|
83
|
+
if (questionGroupValue.questionType == QuestionTypeEnum.TextInput) {
|
|
84
|
+
result = this.checkRuleExpForAnswerText(ruleExp, questionGroupValue.answerText);
|
|
85
|
+
}
|
|
86
|
+
else if (questionGroupValue.questionType == QuestionTypeEnum.CheckBox) {
|
|
87
|
+
result = this.checkRuleExpForAnswerIdArr(ruleExp, questionGroupValue.answerIdArr);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
result = this.checkRuleExpForAnswerId(ruleExp, questionGroupValue.answerId);
|
|
91
|
+
}
|
|
92
|
+
var answers = ruleExp.ruleExpAnswers.map(x => x.answerId + '-' + x.answerTitle);
|
|
93
|
+
console.log(`Question ${questionGroupValue.questionId} type ${QuestionTypeEnum[questionGroupValue.questionType]} --- ${result == true ? 'passed' : 'not passed'} ---`, ` answers (${answers.join(' , ')}) logic (${LogicPropertyEnum[ruleExp.logicPropertyId]}) operator (${OperatorEnum[ruleExp.opporator]})`);
|
|
94
|
+
useCaseResult.exprestionResultArr.push(result);
|
|
95
|
+
});
|
|
96
|
+
return of(useCaseResult);
|
|
97
|
+
}
|
|
98
|
+
checkRuleExpForAnswerId(ruleExp, answerId) {
|
|
99
|
+
var ruleExpResultArr = [];
|
|
100
|
+
if (ruleExp.logicPropertyId == LogicPropertyEnum.GreaterThan) {
|
|
101
|
+
ruleExp.ruleExpAnswers.forEach(answer => {
|
|
102
|
+
var result = answerId > answer.answerId;
|
|
103
|
+
ruleExpResultArr.push(result);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
else if (ruleExp.logicPropertyId == LogicPropertyEnum.GreaterThanOrEqual) {
|
|
107
|
+
ruleExp.ruleExpAnswers.forEach(answer => {
|
|
108
|
+
var result = answerId >= answer.answerId;
|
|
109
|
+
ruleExpResultArr.push(result);
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
else if (ruleExp.logicPropertyId == LogicPropertyEnum.LessThan) {
|
|
113
|
+
ruleExp.ruleExpAnswers.forEach(answer => {
|
|
114
|
+
var result = answerId < answer.answerId;
|
|
115
|
+
ruleExpResultArr.push(result);
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
else if (ruleExp.logicPropertyId == LogicPropertyEnum.LessThanOrEqual) {
|
|
119
|
+
ruleExp.ruleExpAnswers.forEach(answer => {
|
|
120
|
+
var result = answerId <= answer.answerId;
|
|
121
|
+
ruleExpResultArr.push(result);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
else if (ruleExp.logicPropertyId == LogicPropertyEnum.Equal) {
|
|
125
|
+
ruleExp.ruleExpAnswers.forEach(answer => {
|
|
126
|
+
var result = answerId == answer.answerId;
|
|
127
|
+
ruleExpResultArr.push(result);
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
else if (ruleExp.logicPropertyId == LogicPropertyEnum.NotEqual) {
|
|
131
|
+
ruleExp.ruleExpAnswers.forEach(answer => {
|
|
132
|
+
var result = answerId != answer.answerId;
|
|
133
|
+
ruleExpResultArr.push(result);
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
else if (ruleExp.logicPropertyId == LogicPropertyEnum.IsEmpty) {
|
|
137
|
+
var result = answerId == null;
|
|
138
|
+
ruleExpResultArr.push(result);
|
|
139
|
+
}
|
|
140
|
+
else if (ruleExp.logicPropertyId == LogicPropertyEnum.IsNotEmpty) {
|
|
141
|
+
var result = answerId != null;
|
|
142
|
+
ruleExpResultArr.push(result);
|
|
143
|
+
}
|
|
144
|
+
else if (ruleExp.logicPropertyId == LogicPropertyEnum.AnyOf) {
|
|
145
|
+
var answerIdArr = ruleExp.ruleExpAnswers.map(x => x.answerId);
|
|
146
|
+
var result = answerIdArr.findIndex(x => x == answerId) > -1;
|
|
147
|
+
ruleExpResultArr.push(result);
|
|
148
|
+
}
|
|
149
|
+
else if (ruleExp.logicPropertyId == LogicPropertyEnum.Then) {
|
|
150
|
+
var answerIdArr = ruleExp.ruleExpAnswers.map(x => x.answerId);
|
|
151
|
+
var result = answerIdArr.findIndex(x => x == answerId) == -1;
|
|
152
|
+
ruleExpResultArr.push(result);
|
|
153
|
+
}
|
|
154
|
+
if (ruleExpResultArr.length == 0) {
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
else if (ruleExp.ruleExpAnswers.length == 1) {
|
|
158
|
+
return ruleExpResultArr.filter(x => x == true).length > 0;
|
|
159
|
+
}
|
|
160
|
+
else if (ruleExp.opporator == OperatorEnum.Or) {
|
|
161
|
+
return ruleExpResultArr.filter(x => x == true).length > 0;
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
return ruleExpResultArr.filter(x => x == false).length == 0;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
checkRuleExpForAnswerIdArr(ruleExp, answerIdArr) {
|
|
168
|
+
var ruleExpResultArr = [];
|
|
169
|
+
answerIdArr?.forEach(answer => {
|
|
170
|
+
var isResult = this.checkRuleExpForAnswerId(ruleExp, answer);
|
|
171
|
+
ruleExpResultArr.push(isResult);
|
|
172
|
+
});
|
|
173
|
+
if (ruleExpResultArr.length == 0) {
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
else if (ruleExp.ruleExpAnswers.length == 1) {
|
|
177
|
+
return ruleExpResultArr.filter(x => x == true).length > 0;
|
|
178
|
+
}
|
|
179
|
+
else if (ruleExp.opporator == OperatorEnum.Or) {
|
|
180
|
+
return ruleExpResultArr.filter(x => x == true).length > 0;
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
return ruleExpResultArr.filter(x => x == false).length == 0;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
checkRuleExpForAnswerText(ruleExp, answer) {
|
|
187
|
+
var ruleExpResultArr = [];
|
|
188
|
+
if (ruleExp.logicPropertyId == LogicPropertyEnum.IsEmpty) {
|
|
189
|
+
var result = answer == null || answer == '';
|
|
190
|
+
ruleExpResultArr.push(result);
|
|
191
|
+
}
|
|
192
|
+
else if (ruleExp.logicPropertyId == LogicPropertyEnum.IsNotEmpty) {
|
|
193
|
+
var result = answer != null && answer != '';
|
|
194
|
+
ruleExpResultArr.push(result);
|
|
195
|
+
}
|
|
196
|
+
if (ruleExp.ruleExpAnswers.length == 1) {
|
|
197
|
+
return ruleExpResultArr.filter(x => x == true).length > 0;
|
|
198
|
+
}
|
|
199
|
+
else if (ruleExp.opporator == OperatorEnum.Or) {
|
|
200
|
+
return ruleExpResultArr.filter(x => x == true).length > 0;
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
return ruleExpResultArr.filter(x => x == false).length == 0;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: CheckRuleExpsUsecase, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
207
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: CheckRuleExpsUsecase, providedIn: 'root' }); }
|
|
208
|
+
}
|
|
209
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: CheckRuleExpsUsecase, decorators: [{
|
|
210
|
+
type: Injectable,
|
|
211
|
+
args: [{
|
|
212
|
+
providedIn: 'root'
|
|
213
|
+
}]
|
|
214
|
+
}], ctorParameters: function () { return []; } });
|
|
215
|
+
class CheckRulesUsecaseModel {
|
|
216
|
+
}
|
|
217
|
+
class CheckRulesUsecaseResult {
|
|
218
|
+
}
|
|
219
|
+
|
|
43
220
|
class SharedDataService {
|
|
44
221
|
get submitIdObsrv() {
|
|
45
222
|
return this.submitIdSubject.asObservable();
|
|
@@ -79,11 +256,17 @@ class QuestionTextTemplateComponent {
|
|
|
79
256
|
this.fCtrls.answer.addValidators([Validators.required]);
|
|
80
257
|
this.fCtrls.answer.updateValueAndValidity();
|
|
81
258
|
}
|
|
259
|
+
this.isShow = value.isVisable;
|
|
260
|
+
this.toggleEnableAnswer(value.isReadOnly);
|
|
261
|
+
}
|
|
262
|
+
set isDisabled(value) {
|
|
263
|
+
this.toggleEnableAnswer(value);
|
|
82
264
|
}
|
|
83
265
|
constructor(_formBuilder, _sharedDataService) {
|
|
84
266
|
this._formBuilder = _formBuilder;
|
|
85
267
|
this._sharedDataService = _sharedDataService;
|
|
86
268
|
this.emitter = new EventEmitter();
|
|
269
|
+
this.isShow = true;
|
|
87
270
|
this.rForm = this._formBuilder.group({
|
|
88
271
|
id: [null],
|
|
89
272
|
name: [null],
|
|
@@ -114,18 +297,31 @@ class QuestionTextTemplateComponent {
|
|
|
114
297
|
convertToFormControl(element) {
|
|
115
298
|
return element;
|
|
116
299
|
}
|
|
300
|
+
toggleEnableAnswer(isReadOnly) {
|
|
301
|
+
if (isReadOnly == true) {
|
|
302
|
+
this.fCtrls.answer.disable();
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
this.fCtrls.answer.enable();
|
|
306
|
+
}
|
|
307
|
+
this.fCtrls.answer.updateValueAndValidity();
|
|
308
|
+
}
|
|
117
309
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionTextTemplateComponent, deps: [{ token: i1.FormBuilder }, { token: SharedDataService }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
118
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", type: QuestionTextTemplateComponent, selector: "lib-question-text-template", inputs: { isTextArea: "isTextArea", setQuestion: "setQuestion" }, outputs: { emitter: "emitter" }, ngImport: i0, template: "<div class=\"quastion\" [formGroup]=\"rForm\" [attr.id]=\"'question_'+fCtrls.id.value\"\n [ngClass]=\"{'invalid-question': fCtrls.answer.invalid}\">\n <h3 class=\"quastion-title \">\n {{fCtrls.title.value}}\n </h3>\n <div class=\"text-quastion\">\n <input class=\"form-control\" type=\"text\" [formControl]=\"convertToFormControl(fCtrls.answer)\"\n
|
|
310
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", type: QuestionTextTemplateComponent, selector: "lib-question-text-template", inputs: { isShow: "isShow", isTextArea: "isTextArea", setQuestion: "setQuestion", isDisabled: "isDisabled" }, outputs: { emitter: "emitter" }, ngImport: i0, template: "<div class=\"quastion\" [formGroup]=\"rForm\" [attr.id]=\"'question_'+fCtrls.id.value\"\n [ngClass]=\"{'invalid-question': fCtrls.answer.invalid , 'd-none':isShow != true}\">\n <h3 class=\"quastion-title \">\n {{fCtrls.title.value}}\n </h3>\n <div class=\"text-quastion\">\n <input class=\"form-control\" type=\"text\" [formControl]=\"convertToFormControl(fCtrls.answer)\"\n [disabled]=\"isDisabled\" *ngIf=\"isTextArea == false else textAreaTemplate\">\n <ng-template #textAreaTemplate>\n <textarea class=\"form-control\" rows=\"5\" [formControl]=\"convertToFormControl(fCtrls.answer)\"\n [disabled]=\"isDisabled\" ></textarea>\n </ng-template>\n </div>", styles: [""], dependencies: [{ kind: "directive", type: i3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i4.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: i4.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i4.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i4.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: i4.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }] }); }
|
|
119
311
|
}
|
|
120
312
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionTextTemplateComponent, decorators: [{
|
|
121
313
|
type: Component,
|
|
122
|
-
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}\">\n <h3 class=\"quastion-title \">\n {{fCtrls.title.value}}\n </h3>\n <div class=\"text-quastion\">\n <input class=\"form-control\" type=\"text\" [formControl]=\"convertToFormControl(fCtrls.answer)\"\n
|
|
314
|
+
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':isShow != true}\">\n <h3 class=\"quastion-title \">\n {{fCtrls.title.value}}\n </h3>\n <div class=\"text-quastion\">\n <input class=\"form-control\" type=\"text\" [formControl]=\"convertToFormControl(fCtrls.answer)\"\n [disabled]=\"isDisabled\" *ngIf=\"isTextArea == false else textAreaTemplate\">\n <ng-template #textAreaTemplate>\n <textarea class=\"form-control\" rows=\"5\" [formControl]=\"convertToFormControl(fCtrls.answer)\"\n [disabled]=\"isDisabled\" ></textarea>\n </ng-template>\n </div>" }]
|
|
123
315
|
}], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: SharedDataService }]; }, propDecorators: { emitter: [{
|
|
124
316
|
type: Output
|
|
317
|
+
}], isShow: [{
|
|
318
|
+
type: Input
|
|
125
319
|
}], isTextArea: [{
|
|
126
320
|
type: Input
|
|
127
321
|
}], setQuestion: [{
|
|
128
322
|
type: Input
|
|
323
|
+
}], isDisabled: [{
|
|
324
|
+
type: Input
|
|
129
325
|
}] } });
|
|
130
326
|
|
|
131
327
|
class QuestionRadioButtonTemplateComponent {
|
|
@@ -148,12 +344,16 @@ class QuestionRadioButtonTemplateComponent {
|
|
|
148
344
|
this.fCtrls.answer.addValidators([Validators.required]);
|
|
149
345
|
this.fCtrls.answer.updateValueAndValidity();
|
|
150
346
|
}
|
|
347
|
+
this.isShow = value.isVisable;
|
|
348
|
+
this.isDisabled = value.isReadOnly;
|
|
151
349
|
}
|
|
152
350
|
constructor(_formBuilder, _sharedDataService) {
|
|
153
351
|
this._formBuilder = _formBuilder;
|
|
154
352
|
this._sharedDataService = _sharedDataService;
|
|
155
353
|
this.elemId = v4();
|
|
156
354
|
this.emitter = new EventEmitter();
|
|
355
|
+
this.isShow = true;
|
|
356
|
+
this.isDisabled = false;
|
|
157
357
|
this.rForm = this._formBuilder.group({
|
|
158
358
|
id: [null],
|
|
159
359
|
name: [null],
|
|
@@ -188,13 +388,17 @@ class QuestionRadioButtonTemplateComponent {
|
|
|
188
388
|
return element;
|
|
189
389
|
}
|
|
190
390
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionRadioButtonTemplateComponent, deps: [{ token: i1.FormBuilder }, { token: SharedDataService }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
191
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", type: QuestionRadioButtonTemplateComponent, selector: "lib-question-radio-button-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}\">\n <h3 class=\"quastion-title \">\n {{fCtrls.title.value}}\n </h3>\n <div class=\"radio-button-quastion\">\n <div class=\"form-check form-check-radio form-check-inline\" \n *ngFor=\"let item of surveyQuestion?.surveyAnswers;let i = index\">\n <input class=\"form-check-input\" type=\"radio\" (change)=\"onChangeAnswer(item)\"\n name=\"{{elemId}}__radio-btn-option\" id=\"{{elemId}}__radio-btn_{{i}}\" value=\"{{item.answerId}}\">\n <label class=\"form-check-label\" for=\"{{elemId}}__radio-btn_{{i}}\">{{item.answerTitle}}</label>\n </div>\n </div>\n</div>\n", styles: [""], dependencies: [{ kind: "directive", type: i3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] }); }
|
|
391
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", type: QuestionRadioButtonTemplateComponent, selector: "lib-question-radio-button-template", inputs: { isShow: "isShow", isDisabled: "isDisabled", 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':isShow != true}\">\n <h3 class=\"quastion-title \">\n {{fCtrls.title.value}}\n </h3>\n <div class=\"radio-button-quastion\">\n <div class=\"form-check form-check-radio form-check-inline\" \n *ngFor=\"let item of surveyQuestion?.surveyAnswers;let i = index\">\n <input class=\"form-check-input\" type=\"radio\" (change)=\"onChangeAnswer(item)\" [disabled]=\"isDisabled\"\n name=\"{{elemId}}__radio-btn-option\" id=\"{{elemId}}__radio-btn_{{i}}\" value=\"{{item.answerId}}\">\n <label class=\"form-check-label\" for=\"{{elemId}}__radio-btn_{{i}}\">{{item.answerTitle}}</label>\n </div>\n </div>\n</div>\n", styles: [""], dependencies: [{ kind: "directive", type: i3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] }); }
|
|
192
392
|
}
|
|
193
393
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionRadioButtonTemplateComponent, decorators: [{
|
|
194
394
|
type: Component,
|
|
195
|
-
args: [{ selector: 'lib-question-radio-button-template', template: "<div class=\"quastion\" [attr.id]=\"'question_'+fCtrls.id.value\" [ngClass]=\"{'invalid-question': fCtrls.answer.invalid}\">\n <h3 class=\"quastion-title \">\n {{fCtrls.title.value}}\n </h3>\n <div class=\"radio-button-quastion\">\n <div class=\"form-check form-check-radio form-check-inline\" \n *ngFor=\"let item of surveyQuestion?.surveyAnswers;let i = index\">\n <input class=\"form-check-input\" type=\"radio\" (change)=\"onChangeAnswer(item)\"\n name=\"{{elemId}}__radio-btn-option\" id=\"{{elemId}}__radio-btn_{{i}}\" value=\"{{item.answerId}}\">\n <label class=\"form-check-label\" for=\"{{elemId}}__radio-btn_{{i}}\">{{item.answerTitle}}</label>\n </div>\n </div>\n</div>\n" }]
|
|
395
|
+
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':isShow != true}\">\n <h3 class=\"quastion-title \">\n {{fCtrls.title.value}}\n </h3>\n <div class=\"radio-button-quastion\">\n <div class=\"form-check form-check-radio form-check-inline\" \n *ngFor=\"let item of surveyQuestion?.surveyAnswers;let i = index\">\n <input class=\"form-check-input\" type=\"radio\" (change)=\"onChangeAnswer(item)\" [disabled]=\"isDisabled\"\n name=\"{{elemId}}__radio-btn-option\" id=\"{{elemId}}__radio-btn_{{i}}\" value=\"{{item.answerId}}\">\n <label class=\"form-check-label\" for=\"{{elemId}}__radio-btn_{{i}}\">{{item.answerTitle}}</label>\n </div>\n </div>\n</div>\n" }]
|
|
196
396
|
}], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: SharedDataService }]; }, propDecorators: { emitter: [{
|
|
197
397
|
type: Output
|
|
398
|
+
}], isShow: [{
|
|
399
|
+
type: Input
|
|
400
|
+
}], isDisabled: [{
|
|
401
|
+
type: Input
|
|
198
402
|
}], setQuestion: [{
|
|
199
403
|
type: Input
|
|
200
404
|
}] } });
|
|
@@ -219,12 +423,16 @@ class QuestionCheckBoxTemplateComponent {
|
|
|
219
423
|
this.fCtrls.answer.addValidators([Validators.required]);
|
|
220
424
|
this.fCtrls.answer.updateValueAndValidity();
|
|
221
425
|
}
|
|
426
|
+
this.isShow = value.isVisable;
|
|
427
|
+
this.isDisabled = value.isReadOnly;
|
|
222
428
|
}
|
|
223
429
|
constructor(_formBuilder, _sharedDataService) {
|
|
224
430
|
this._formBuilder = _formBuilder;
|
|
225
431
|
this._sharedDataService = _sharedDataService;
|
|
226
432
|
this.elemId = v4();
|
|
227
433
|
this.emitter = new EventEmitter();
|
|
434
|
+
this.isShow = true;
|
|
435
|
+
this.isDisabled = false;
|
|
228
436
|
this.rForm = this._formBuilder.group({
|
|
229
437
|
id: [null],
|
|
230
438
|
name: [null],
|
|
@@ -243,7 +451,7 @@ class QuestionCheckBoxTemplateComponent {
|
|
|
243
451
|
});
|
|
244
452
|
}
|
|
245
453
|
ngOnInit() {
|
|
246
|
-
this.fCtrls.answer.valueChanges.
|
|
454
|
+
this.fCtrls.answer.valueChanges.subscribe(value => {
|
|
247
455
|
const formValue = this.rForm.value;
|
|
248
456
|
this.emitter.emit({
|
|
249
457
|
QuestionId: formValue.id,
|
|
@@ -260,20 +468,24 @@ class QuestionCheckBoxTemplateComponent {
|
|
|
260
468
|
else {
|
|
261
469
|
answerArr = answerArr.filter(x => x != item.answerId);
|
|
262
470
|
}
|
|
263
|
-
answerArr = answerArr.length == 0 ?
|
|
471
|
+
answerArr = answerArr.length == 0 ? [] : answerArr;
|
|
264
472
|
this.fCtrls.answer.setValue(answerArr);
|
|
265
473
|
}
|
|
266
474
|
convertToFormControl(element) {
|
|
267
475
|
return element;
|
|
268
476
|
}
|
|
269
477
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionCheckBoxTemplateComponent, deps: [{ token: i1.FormBuilder }, { token: SharedDataService }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
270
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", type: QuestionCheckBoxTemplateComponent, selector: "lib-question-check-box-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}\">\n <h3 class=\"quastion-title \">\n {{fCtrls.title.value}}\n </h3>\n\n <div class=\"checkbox-button-quastion\">\n <div class=\"form-check check-box-form-check\" *ngFor=\"let item of surveyQuestion?.surveyAnswers;let i = index\">\n <input type=\"checkbox\" class=\"form-check-input\" id=\"{{elemId}}__checkbox_{{i}}\"
|
|
478
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", type: QuestionCheckBoxTemplateComponent, selector: "lib-question-check-box-template", inputs: { isShow: "isShow", isDisabled: "isDisabled", 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':isShow != true}\">\n <h3 class=\"quastion-title \">\n {{fCtrls.title.value}}\n </h3>\n\n <div class=\"checkbox-button-quastion\">\n <div class=\"form-check check-box-form-check\" *ngFor=\"let item of surveyQuestion?.surveyAnswers;let i = index\">\n <input type=\"checkbox\" class=\"form-check-input\" id=\"{{elemId}}__checkbox_{{i}}\" [disabled]=\"isDisabled\"\n (change)=\"onChangeAnswer(item,$event)\">\n <label class=\"form-check-label \" for=\"{{elemId}}__checkbox_{{i}}\">{{item.answerTitle}}</label>\n </div>\n </div>\n</div>\n", styles: [""], dependencies: [{ kind: "directive", type: i3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] }); }
|
|
271
479
|
}
|
|
272
480
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionCheckBoxTemplateComponent, decorators: [{
|
|
273
481
|
type: Component,
|
|
274
|
-
args: [{ selector: 'lib-question-check-box-template', template: "<div class=\"quastion\" [attr.id]=\"'question_'+fCtrls.id.value\" [ngClass]=\"{'invalid-question': fCtrls.answer.invalid}\">\n <h3 class=\"quastion-title \">\n {{fCtrls.title.value}}\n </h3>\n\n <div class=\"checkbox-button-quastion\">\n <div class=\"form-check check-box-form-check\" *ngFor=\"let item of surveyQuestion?.surveyAnswers;let i = index\">\n <input type=\"checkbox\" class=\"form-check-input\" id=\"{{elemId}}__checkbox_{{i}}\"
|
|
482
|
+
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':isShow != true}\">\n <h3 class=\"quastion-title \">\n {{fCtrls.title.value}}\n </h3>\n\n <div class=\"checkbox-button-quastion\">\n <div class=\"form-check check-box-form-check\" *ngFor=\"let item of surveyQuestion?.surveyAnswers;let i = index\">\n <input type=\"checkbox\" class=\"form-check-input\" id=\"{{elemId}}__checkbox_{{i}}\" [disabled]=\"isDisabled\"\n (change)=\"onChangeAnswer(item,$event)\">\n <label class=\"form-check-label \" for=\"{{elemId}}__checkbox_{{i}}\">{{item.answerTitle}}</label>\n </div>\n </div>\n</div>\n" }]
|
|
275
483
|
}], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: SharedDataService }]; }, propDecorators: { emitter: [{
|
|
276
484
|
type: Output
|
|
485
|
+
}], isShow: [{
|
|
486
|
+
type: Input
|
|
487
|
+
}], isDisabled: [{
|
|
488
|
+
type: Input
|
|
277
489
|
}], setQuestion: [{
|
|
278
490
|
type: Input
|
|
279
491
|
}] } });
|
|
@@ -298,11 +510,15 @@ class QuestionDropdownTemplateComponent {
|
|
|
298
510
|
this.fCtrls.answer.addValidators([Validators.required]);
|
|
299
511
|
this.fCtrls.answer.updateValueAndValidity();
|
|
300
512
|
}
|
|
513
|
+
this.isShow = value.isVisable;
|
|
514
|
+
this.isDisabled = value.isReadOnly;
|
|
301
515
|
}
|
|
302
516
|
constructor(_formBuilder, _sharedDataService) {
|
|
303
517
|
this._formBuilder = _formBuilder;
|
|
304
518
|
this._sharedDataService = _sharedDataService;
|
|
305
519
|
this.emitter = new EventEmitter();
|
|
520
|
+
this.isShow = true;
|
|
521
|
+
this.isDisabled = false;
|
|
306
522
|
this.rForm = this._formBuilder.group({
|
|
307
523
|
id: [null],
|
|
308
524
|
name: [null],
|
|
@@ -334,13 +550,17 @@ class QuestionDropdownTemplateComponent {
|
|
|
334
550
|
return element;
|
|
335
551
|
}
|
|
336
552
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionDropdownTemplateComponent, deps: [{ token: i1.FormBuilder }, { token: SharedDataService }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
337
|
-
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}\">\n <h3 class=\"quastion-title \">\n {{fCtrls.title.value}}\n </h3>\n <div class=\"text-quastion\">\n <select class=\"form-control\" [formControl]=\"convertToFormControl(fCtrls.answer)\">\n <option *ngFor=\"let item of surveyQuestion?.surveyAnswers\" [value]=\"item.answerId\">{{item.answerTitle}}</option>\n </select>\n </div>\n</div>\n", styles: [""], 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: i4.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i4.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i4.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i4.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i4.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }] }); }
|
|
553
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", type: QuestionDropdownTemplateComponent, selector: "lib-question-dropdown-template", inputs: { isShow: "isShow", isDisabled: "isDisabled", 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':isShow != true}\">\n <h3 class=\"quastion-title \">\n {{fCtrls.title.value}}\n </h3>\n <div class=\"text-quastion\">\n <select class=\"form-control\" [formControl]=\"convertToFormControl(fCtrls.answer)\" [disabled]=\"isDisabled\">\n <option *ngFor=\"let item of surveyQuestion?.surveyAnswers\" [value]=\"item.answerId\">{{item.answerTitle}}</option>\n </select>\n </div>\n</div>\n", styles: [""], 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: i4.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i4.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i4.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i4.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i4.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }] }); }
|
|
338
554
|
}
|
|
339
555
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionDropdownTemplateComponent, decorators: [{
|
|
340
556
|
type: Component,
|
|
341
|
-
args: [{ selector: 'lib-question-dropdown-template', template: "<div class=\"quastion\" [attr.id]=\"'question_'+fCtrls.id.value\" [ngClass]=\"{'invalid-question': fCtrls.answer.invalid}\">\n <h3 class=\"quastion-title \">\n {{fCtrls.title.value}}\n </h3>\n <div class=\"text-quastion\">\n <select class=\"form-control\" [formControl]=\"convertToFormControl(fCtrls.answer)\">\n <option *ngFor=\"let item of surveyQuestion?.surveyAnswers\" [value]=\"item.answerId\">{{item.answerTitle}}</option>\n </select>\n </div>\n</div>\n" }]
|
|
557
|
+
args: [{ selector: 'lib-question-dropdown-template', template: "<div class=\"quastion\" [attr.id]=\"'question_'+fCtrls.id.value\" [ngClass]=\"{'invalid-question': fCtrls.answer.invalid , 'd-none':isShow != true}\">\n <h3 class=\"quastion-title \">\n {{fCtrls.title.value}}\n </h3>\n <div class=\"text-quastion\">\n <select class=\"form-control\" [formControl]=\"convertToFormControl(fCtrls.answer)\" [disabled]=\"isDisabled\">\n <option *ngFor=\"let item of surveyQuestion?.surveyAnswers\" [value]=\"item.answerId\">{{item.answerTitle}}</option>\n </select>\n </div>\n</div>\n" }]
|
|
342
558
|
}], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: SharedDataService }]; }, propDecorators: { emitter: [{
|
|
343
559
|
type: Output
|
|
560
|
+
}], isShow: [{
|
|
561
|
+
type: Input
|
|
562
|
+
}], isDisabled: [{
|
|
563
|
+
type: Input
|
|
344
564
|
}], setQuestion: [{
|
|
345
565
|
type: Input
|
|
346
566
|
}] } });
|
|
@@ -370,11 +590,15 @@ class QuestionMatrixTemplateComponent {
|
|
|
370
590
|
}
|
|
371
591
|
this.fCtrls.subQuestionArray.push(group);
|
|
372
592
|
});
|
|
593
|
+
this.isShow = value.isVisable;
|
|
594
|
+
this.isDisabled = value.isReadOnly;
|
|
373
595
|
}
|
|
374
596
|
constructor(_formBuilder) {
|
|
375
597
|
this._formBuilder = _formBuilder;
|
|
376
598
|
this.elemId = v4();
|
|
377
599
|
this.emitter = new EventEmitter();
|
|
600
|
+
this.isShow = true;
|
|
601
|
+
this.isDisabled = false;
|
|
378
602
|
this.rForm = this._formBuilder.group({
|
|
379
603
|
id: [null],
|
|
380
604
|
typeId: [null],
|
|
@@ -385,9 +609,11 @@ class QuestionMatrixTemplateComponent {
|
|
|
385
609
|
const index = this.fCtrls.subQuestionArray.value.findIndex(x => x.subQuestionId == question.subQuestionId);
|
|
386
610
|
this.fCtrls.subQuestionArray.controls[index].controls.answer.setValue(answer.answerId);
|
|
387
611
|
var model = this.fCtrls.subQuestionArray.value.map(x => {
|
|
388
|
-
return {
|
|
612
|
+
return {
|
|
613
|
+
QuestionId: x.subQuestionId,
|
|
389
614
|
Answer: x.answer,
|
|
390
|
-
IsValid: this.fCtrls.subQuestionArray.controls[index].controls.answer.valid
|
|
615
|
+
IsValid: this.fCtrls.subQuestionArray.controls[index].controls.answer.valid
|
|
616
|
+
};
|
|
391
617
|
});
|
|
392
618
|
this.emitter.emit(model);
|
|
393
619
|
}
|
|
@@ -395,13 +621,17 @@ class QuestionMatrixTemplateComponent {
|
|
|
395
621
|
return element;
|
|
396
622
|
}
|
|
397
623
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionMatrixTemplateComponent, deps: [{ token: i1.FormBuilder }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
398
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", type: QuestionMatrixTemplateComponent, selector: "lib-question-matrix-template", inputs: { setQuestion: "setQuestion" }, outputs: { emitter: "emitter" }, ngImport: i0, template: "<div class=\"quastion\" [attr.id]=\"'question_'+fCtrls.id.value\" style=\" border-collapse: collapse;\">\n <h3 class=\"quastion-title \">\n {{surveyQuestion?.questionTitle}}\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 {{answers.answerTitle}}\n </div>\n </div>\n\n <div class=\"matrix-row\"\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\">\n {{questionGroup.value.questionTitle}}\n </div>\n <div class=\"matrix-col\" *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}}\">\n <label class=\"form-check-label d-md-inline d-lg-none\"\n for=\"{{elemId}}__radio-btn_{{subQuestionIndex}}_{{answerIndex}}\"> {{answer.answerTitle}}</label>\n </div>\n </div>\n </div>\n\n </div>\n\n </div>\n</div>", styles: [""], 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: i4.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i4.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i4.FormArrayName, selector: "[formArrayName]", inputs: ["formArrayName"] }] }); }
|
|
624
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", type: QuestionMatrixTemplateComponent, selector: "lib-question-matrix-template", inputs: { isShow: "isShow", isDisabled: "isDisabled", setQuestion: "setQuestion" }, outputs: { emitter: "emitter" }, ngImport: i0, template: "<div class=\"quastion\" [attr.id]=\"'question_'+fCtrls.id.value\" style=\" border-collapse: collapse;\"\n[ngClass]=\"{'d-none':isShow != true}\">\n <h3 class=\"quastion-title \">\n {{surveyQuestion?.questionTitle}}\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 {{answers.answerTitle}}\n </div>\n </div>\n\n <div class=\"matrix-row\"\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\">\n {{questionGroup.value.questionTitle}}\n </div>\n <div class=\"matrix-col\" *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}}\">\n <label class=\"form-check-label d-md-inline d-lg-none\"\n for=\"{{elemId}}__radio-btn_{{subQuestionIndex}}_{{answerIndex}}\"> {{answer.answerTitle}}</label>\n </div>\n </div>\n </div>\n\n </div>\n\n </div>\n</div>", styles: [""], 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: i4.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i4.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i4.FormArrayName, selector: "[formArrayName]", inputs: ["formArrayName"] }] }); }
|
|
399
625
|
}
|
|
400
626
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionMatrixTemplateComponent, decorators: [{
|
|
401
627
|
type: Component,
|
|
402
|
-
args: [{ selector: 'lib-question-matrix-template', template: "<div class=\"quastion\" [attr.id]=\"'question_'+fCtrls.id.value\" style=\" border-collapse: collapse;\">\n <h3 class=\"quastion-title \">\n {{surveyQuestion?.questionTitle}}\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 {{answers.answerTitle}}\n </div>\n </div>\n\n <div class=\"matrix-row\"\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\">\n {{questionGroup.value.questionTitle}}\n </div>\n <div class=\"matrix-col\" *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}}\">\n <label class=\"form-check-label d-md-inline d-lg-none\"\n for=\"{{elemId}}__radio-btn_{{subQuestionIndex}}_{{answerIndex}}\"> {{answer.answerTitle}}</label>\n </div>\n </div>\n </div>\n\n </div>\n\n </div>\n</div>" }]
|
|
628
|
+
args: [{ selector: 'lib-question-matrix-template', template: "<div class=\"quastion\" [attr.id]=\"'question_'+fCtrls.id.value\" style=\" border-collapse: collapse;\"\n[ngClass]=\"{'d-none':isShow != true}\">\n <h3 class=\"quastion-title \">\n {{surveyQuestion?.questionTitle}}\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 {{answers.answerTitle}}\n </div>\n </div>\n\n <div class=\"matrix-row\"\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\">\n {{questionGroup.value.questionTitle}}\n </div>\n <div class=\"matrix-col\" *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}}\">\n <label class=\"form-check-label d-md-inline d-lg-none\"\n for=\"{{elemId}}__radio-btn_{{subQuestionIndex}}_{{answerIndex}}\"> {{answer.answerTitle}}</label>\n </div>\n </div>\n </div>\n\n </div>\n\n </div>\n</div>" }]
|
|
403
629
|
}], ctorParameters: function () { return [{ type: i1.FormBuilder }]; }, propDecorators: { emitter: [{
|
|
404
630
|
type: Output
|
|
631
|
+
}], isShow: [{
|
|
632
|
+
type: Input
|
|
633
|
+
}], isDisabled: [{
|
|
634
|
+
type: Input
|
|
405
635
|
}], setQuestion: [{
|
|
406
636
|
type: Input
|
|
407
637
|
}] } });
|
|
@@ -426,12 +656,16 @@ class QuestionBooleanTemplateComponent {
|
|
|
426
656
|
this.fCtrls.answer.addValidators([Validators.required]);
|
|
427
657
|
this.fCtrls.answer.updateValueAndValidity();
|
|
428
658
|
}
|
|
659
|
+
this.isShow = value.isVisable;
|
|
660
|
+
this.isDisabled = value.isReadOnly;
|
|
429
661
|
}
|
|
430
662
|
constructor(_formBuilder, _sharedDataService) {
|
|
431
663
|
this._formBuilder = _formBuilder;
|
|
432
664
|
this._sharedDataService = _sharedDataService;
|
|
433
665
|
this.elemId = v4();
|
|
434
666
|
this.emitter = new EventEmitter();
|
|
667
|
+
this.isShow = true;
|
|
668
|
+
this.isDisabled = false;
|
|
435
669
|
this.rForm = this._formBuilder.group({
|
|
436
670
|
id: [null],
|
|
437
671
|
name: [null],
|
|
@@ -466,17 +700,35 @@ class QuestionBooleanTemplateComponent {
|
|
|
466
700
|
return element;
|
|
467
701
|
}
|
|
468
702
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionBooleanTemplateComponent, deps: [{ token: i1.FormBuilder }, { token: SharedDataService }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
469
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", type: QuestionBooleanTemplateComponent, selector: "lib-question-boolean-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}\">\n <h3 class=\"quastion-title \">\n {{fCtrls.title.value}}\n </h3>\n <div class=\"radio-button-quastion\">\n <div class=\"form-check form-check-radio form-check-inline\" \n *ngFor=\"let item of surveyQuestion?.surveyAnswers;let i = index\">\n <input class=\"form-check-input\" type=\"radio\" (change)=\"onChangeAnswer(item)\"\n name=\"{{elemId}}__radio-btn-option\" id=\"{{elemId}}__radio-btn_{{i}}\" value=\"{{item.answerId}}\">\n <label class=\"form-check-label\" for=\"{{elemId}}__radio-btn_{{i}}\">{{item.answerTitle}}</label>\n </div>\n </div>\n</div>\n", styles: [""], dependencies: [{ kind: "directive", type: i3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] }); }
|
|
703
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", type: QuestionBooleanTemplateComponent, selector: "lib-question-boolean-template", inputs: { isShow: "isShow", isDisabled: "isDisabled", 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':isShow != true}\">\n <h3 class=\"quastion-title \">\n {{fCtrls.title.value}}\n </h3>\n <div class=\"radio-button-quastion\">\n <div class=\"form-check form-check-radio form-check-inline\" \n *ngFor=\"let item of surveyQuestion?.surveyAnswers;let i = index\">\n <input class=\"form-check-input\" type=\"radio\" (change)=\"onChangeAnswer(item)\" [disabled]=\"isDisabled\"\n name=\"{{elemId}}__radio-btn-option\" id=\"{{elemId}}__radio-btn_{{i}}\" value=\"{{item.answerId}}\">\n <label class=\"form-check-label\" for=\"{{elemId}}__radio-btn_{{i}}\">{{item.answerTitle}}</label>\n </div>\n </div>\n</div>\n", styles: [""], dependencies: [{ kind: "directive", type: i3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] }); }
|
|
470
704
|
}
|
|
471
705
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionBooleanTemplateComponent, decorators: [{
|
|
472
706
|
type: Component,
|
|
473
|
-
args: [{ selector: 'lib-question-boolean-template', template: "<div class=\"quastion\" [attr.id]=\"'question_'+fCtrls.id.value\" [ngClass]=\"{'invalid-question': fCtrls.answer.invalid}\">\n <h3 class=\"quastion-title \">\n {{fCtrls.title.value}}\n </h3>\n <div class=\"radio-button-quastion\">\n <div class=\"form-check form-check-radio form-check-inline\" \n *ngFor=\"let item of surveyQuestion?.surveyAnswers;let i = index\">\n <input class=\"form-check-input\" type=\"radio\" (change)=\"onChangeAnswer(item)\"\n name=\"{{elemId}}__radio-btn-option\" id=\"{{elemId}}__radio-btn_{{i}}\" value=\"{{item.answerId}}\">\n <label class=\"form-check-label\" for=\"{{elemId}}__radio-btn_{{i}}\">{{item.answerTitle}}</label>\n </div>\n </div>\n</div>\n" }]
|
|
707
|
+
args: [{ selector: 'lib-question-boolean-template', template: "<div class=\"quastion\" [attr.id]=\"'question_'+fCtrls.id.value\" [ngClass]=\"{'invalid-question': fCtrls.answer.invalid , 'd-none':isShow != true}\">\n <h3 class=\"quastion-title \">\n {{fCtrls.title.value}}\n </h3>\n <div class=\"radio-button-quastion\">\n <div class=\"form-check form-check-radio form-check-inline\" \n *ngFor=\"let item of surveyQuestion?.surveyAnswers;let i = index\">\n <input class=\"form-check-input\" type=\"radio\" (change)=\"onChangeAnswer(item)\" [disabled]=\"isDisabled\"\n name=\"{{elemId}}__radio-btn-option\" id=\"{{elemId}}__radio-btn_{{i}}\" value=\"{{item.answerId}}\">\n <label class=\"form-check-label\" for=\"{{elemId}}__radio-btn_{{i}}\">{{item.answerTitle}}</label>\n </div>\n </div>\n</div>\n" }]
|
|
474
708
|
}], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: SharedDataService }]; }, propDecorators: { emitter: [{
|
|
475
709
|
type: Output
|
|
710
|
+
}], isShow: [{
|
|
711
|
+
type: Input
|
|
712
|
+
}], isDisabled: [{
|
|
713
|
+
type: Input
|
|
476
714
|
}], setQuestion: [{
|
|
477
715
|
type: Input
|
|
478
716
|
}] } });
|
|
479
717
|
|
|
718
|
+
class FilterQuestionPipe {
|
|
719
|
+
transform(value, questionArr) {
|
|
720
|
+
return questionArr.find(x => x.questionId == value.questionId);
|
|
721
|
+
}
|
|
722
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: FilterQuestionPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
723
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "16.1.7", ngImport: i0, type: FilterQuestionPipe, name: "filterQuestion" }); }
|
|
724
|
+
}
|
|
725
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: FilterQuestionPipe, decorators: [{
|
|
726
|
+
type: Pipe,
|
|
727
|
+
args: [{
|
|
728
|
+
name: 'filterQuestion'
|
|
729
|
+
}]
|
|
730
|
+
}] });
|
|
731
|
+
|
|
480
732
|
class SurveryLibComponent {
|
|
481
733
|
get fCtrls() {
|
|
482
734
|
return this.rForm.controls;
|
|
@@ -487,14 +739,15 @@ class SurveryLibComponent {
|
|
|
487
739
|
get isLastPage() {
|
|
488
740
|
return this.fCtrls.currentPageIndex.value == (this.surveyData?.surveyPages.length - 1);
|
|
489
741
|
}
|
|
490
|
-
constructor(_surveyLibService, _formBuilder,
|
|
742
|
+
constructor(_surveyLibService, _formBuilder, _checkRuleExpsUsecase) {
|
|
491
743
|
this._surveyLibService = _surveyLibService;
|
|
492
744
|
this._formBuilder = _formBuilder;
|
|
493
|
-
this.
|
|
745
|
+
this._checkRuleExpsUsecase = _checkRuleExpsUsecase;
|
|
494
746
|
this.surveyResultEmit = new EventEmitter();
|
|
495
747
|
this.rForm = this._formBuilder.group({
|
|
496
748
|
currentPageIndex: [0],
|
|
497
|
-
questionArray: this._formBuilder.array([])
|
|
749
|
+
questionArray: this._formBuilder.array([]),
|
|
750
|
+
ruleQuestionArray: this._formBuilder.array([])
|
|
498
751
|
});
|
|
499
752
|
}
|
|
500
753
|
ngOnInit() {
|
|
@@ -510,17 +763,20 @@ class SurveryLibComponent {
|
|
|
510
763
|
}
|
|
511
764
|
onPaggingNext() {
|
|
512
765
|
var isHaveInvalidRecords = this.haveInValidateQuestions();
|
|
513
|
-
if (isHaveInvalidRecords ==
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
766
|
+
if (isHaveInvalidRecords == false) {
|
|
767
|
+
var currentPageIndex = this.fCtrls.currentPageIndex.value;
|
|
768
|
+
if (currentPageIndex < (this.surveyData.surveyPages.length - 1)) {
|
|
769
|
+
currentPageIndex = Number(currentPageIndex) + 1;
|
|
770
|
+
this.fCtrls.currentPageIndex.setValue(currentPageIndex);
|
|
771
|
+
return of(null);
|
|
772
|
+
}
|
|
773
|
+
else {
|
|
774
|
+
var questionArr = this.fCtrls.questionArray.value.filter(x => x.isMatrixGroup != true);
|
|
775
|
+
return of(questionArr);
|
|
776
|
+
}
|
|
521
777
|
}
|
|
522
778
|
else {
|
|
523
|
-
return of(
|
|
779
|
+
return of(null);
|
|
524
780
|
}
|
|
525
781
|
}
|
|
526
782
|
onPaggingBack() {
|
|
@@ -537,10 +793,20 @@ class SurveryLibComponent {
|
|
|
537
793
|
}
|
|
538
794
|
onUpdateAnswer(model) {
|
|
539
795
|
const index = this.fCtrls.questionArray.value.findIndex(x => x.questionId == model.QuestionId);
|
|
540
|
-
this.fCtrls.questionArray.controls[index]
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
796
|
+
var questionGroup = this.fCtrls.questionArray.controls[index];
|
|
797
|
+
questionGroup.controls.isValid.setValue(model.IsValid);
|
|
798
|
+
if (questionGroup.value.questionType == this.questionTypeEnum.TextInput) {
|
|
799
|
+
questionGroup.controls.answerText.setValue(model.Answer);
|
|
800
|
+
}
|
|
801
|
+
else if (questionGroup.value.questionType == this.questionTypeEnum.CheckBox) {
|
|
802
|
+
questionGroup.controls.answerIdArr.setValue(model.Answer);
|
|
803
|
+
}
|
|
804
|
+
else {
|
|
805
|
+
questionGroup.controls.answerId.setValue(model.Answer);
|
|
806
|
+
}
|
|
807
|
+
if (this.fCtrls.ruleQuestionArray.value.findIndex(x => x.questionId == model.QuestionId) > -1) {
|
|
808
|
+
this.checkRules();
|
|
809
|
+
}
|
|
544
810
|
}
|
|
545
811
|
loadQuestions(survey) {
|
|
546
812
|
survey.surveyPages.forEach((page, pageIndex) => {
|
|
@@ -550,41 +816,119 @@ class SurveryLibComponent {
|
|
|
550
816
|
this.fCtrls.questionArray.push(this._formBuilder.group({
|
|
551
817
|
surveyPageIndex: pageIndex,
|
|
552
818
|
questionId: [question.questionId],
|
|
553
|
-
|
|
819
|
+
questionType: [question.questionTypeId],
|
|
820
|
+
isMatrixGroup: [false],
|
|
821
|
+
answerId: [null],
|
|
822
|
+
answerIdArr: [null],
|
|
823
|
+
answerText: [null],
|
|
554
824
|
isRequired: [question.isRequired],
|
|
555
|
-
isValid: [null]
|
|
825
|
+
isValid: [null],
|
|
826
|
+
isDisabled: [question.isReadOnly],
|
|
827
|
+
isShow: [question.isVisable],
|
|
828
|
+
isDisabled_default: [question.isReadOnly],
|
|
829
|
+
isShow_default: [question.isVisable]
|
|
556
830
|
}));
|
|
557
831
|
}
|
|
558
832
|
else {
|
|
833
|
+
this.fCtrls.questionArray.push(this._formBuilder.group({
|
|
834
|
+
surveyPageIndex: pageIndex,
|
|
835
|
+
questionId: [question.questionId],
|
|
836
|
+
questionType: [question.questionTypeId],
|
|
837
|
+
isMatrixGroup: [true],
|
|
838
|
+
answerId: [null],
|
|
839
|
+
answerIdArr: [null],
|
|
840
|
+
answerText: [null],
|
|
841
|
+
isRequired: [question.isRequired],
|
|
842
|
+
isValid: [null],
|
|
843
|
+
isDisabled: [question.isReadOnly],
|
|
844
|
+
isShow: [question.isVisable],
|
|
845
|
+
isDisabled_default: [question.isReadOnly],
|
|
846
|
+
isShow_default: [question.isVisable],
|
|
847
|
+
}));
|
|
559
848
|
question.surveySubQuestions.forEach(subQuestion => {
|
|
560
849
|
this.fCtrls.questionArray.push(this._formBuilder.group({
|
|
561
850
|
surveyPageIndex: pageIndex,
|
|
562
851
|
questionId: [subQuestion.questionId],
|
|
563
|
-
|
|
852
|
+
questionType: [subQuestion.questionTypeId],
|
|
853
|
+
isMatrixGroup: [false],
|
|
854
|
+
answerId: [null],
|
|
855
|
+
answerIdArr: [null],
|
|
856
|
+
answerText: [null],
|
|
564
857
|
isRequired: [question.isRequired],
|
|
565
|
-
isValid: [null]
|
|
858
|
+
isValid: [null],
|
|
859
|
+
isDisabled: [subQuestion.isReadOnly],
|
|
860
|
+
isShow: [subQuestion.isVisable],
|
|
861
|
+
isDisabled_default: [subQuestion.isReadOnly],
|
|
862
|
+
isShow_default: [subQuestion.isVisable]
|
|
566
863
|
}));
|
|
567
864
|
});
|
|
568
865
|
}
|
|
569
866
|
});
|
|
570
867
|
});
|
|
571
868
|
});
|
|
869
|
+
survey.surveyRules.forEach(rule => {
|
|
870
|
+
rule.ruleExps.forEach(ruleExp => {
|
|
871
|
+
this.fCtrls.ruleQuestionArray.push(this._formBuilder.group({
|
|
872
|
+
questionId: ruleExp.questionId
|
|
873
|
+
}));
|
|
874
|
+
});
|
|
875
|
+
});
|
|
572
876
|
}
|
|
573
877
|
haveInValidateQuestions() {
|
|
574
878
|
const currentPageIndex = this.fCtrls.currentPageIndex.value;
|
|
575
|
-
var invalidRecords = this.
|
|
879
|
+
var invalidRecords = this.fCtrls.questionArray.value.filter(x => x.surveyPageIndex == currentPageIndex && x.isValid != true && x.isDisabled == false && x.isMatrixGroup != true);
|
|
576
880
|
if (invalidRecords.length > 0) {
|
|
577
881
|
$(`#survey-page_${currentPageIndex}`).addClass('survey-page_submitted');
|
|
578
882
|
}
|
|
579
883
|
return invalidRecords.length > 0;
|
|
580
884
|
}
|
|
581
|
-
|
|
582
|
-
|
|
885
|
+
checkRules() {
|
|
886
|
+
this.surveyData.surveyRules.forEach(rule => {
|
|
887
|
+
this._checkRuleExpsUsecase.execute({
|
|
888
|
+
ruleExps: rule.ruleExps,
|
|
889
|
+
questions: this.fCtrls.questionArray.value
|
|
890
|
+
}).subscribe(result => {
|
|
891
|
+
var isPassed = result.exprestionResultArr.filter(x => x == false).length == 0;
|
|
892
|
+
if (isPassed) {
|
|
893
|
+
rule.ruleResultQuestions.forEach(resultQuestion => {
|
|
894
|
+
const index = this.fCtrls.questionArray.value.findIndex(x => x.questionId == resultQuestion.questionId);
|
|
895
|
+
var questionGroup = this.fCtrls.questionArray.at(index);
|
|
896
|
+
if (rule.logicActionId == LogicActionEnum.Show) {
|
|
897
|
+
questionGroup.controls.isShow.setValue(true);
|
|
898
|
+
}
|
|
899
|
+
else if (rule.logicActionId == LogicActionEnum.Hide) {
|
|
900
|
+
questionGroup.controls.isShow.setValue(false);
|
|
901
|
+
}
|
|
902
|
+
else if (rule.logicActionId == LogicActionEnum.Enable) {
|
|
903
|
+
questionGroup.controls.isDisabled.setValue(false);
|
|
904
|
+
}
|
|
905
|
+
else if (rule.logicActionId == LogicActionEnum.Disable) {
|
|
906
|
+
questionGroup.controls.isDisabled.setValue(true);
|
|
907
|
+
}
|
|
908
|
+
else if (rule.logicActionId == LogicActionEnum.SetAnswer) {
|
|
909
|
+
}
|
|
910
|
+
});
|
|
911
|
+
}
|
|
912
|
+
else {
|
|
913
|
+
rule.ruleResultQuestions.forEach(resultQuestion => {
|
|
914
|
+
const index = this.fCtrls.questionArray.value.findIndex(x => x.questionId == resultQuestion.questionId);
|
|
915
|
+
var questionGroup = this.fCtrls.questionArray.at(index);
|
|
916
|
+
questionGroup.patchValue({
|
|
917
|
+
isShow: questionGroup.value.isShow_default,
|
|
918
|
+
isDisabled: questionGroup.value.isDisabled_default
|
|
919
|
+
});
|
|
920
|
+
});
|
|
921
|
+
}
|
|
922
|
+
});
|
|
923
|
+
});
|
|
924
|
+
}
|
|
925
|
+
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 }); }
|
|
926
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", type: SurveryLibComponent, selector: "lib-survery-lib", outputs: { surveyResultEmit: "surveyResultEmit" }, ngImport: i0, template: "<div 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\">\r\n {{item.questionGroupName}}\r\n </h2>\r\n <span class=\"group-sub-title \">\r\n {{item.questionGroupDescription}}\r\n </span>\r\n </div>\r\n <ng-container *ngFor=\"let question of item.surveyQuestions\">\r\n <lib-question-boolean-template [setQuestion]=\"question\" (emitter)=\"onUpdateAnswer($event)\"\r\n *ngIf=\"question.questionTypeId == questionTypeEnum.Boolean\"\r\n [isShow]=\" (question|filterQuestion : fCtrls.questionArray.value).isShow\"\r\n [isDisabled]=\"(question|filterQuestion : fCtrls.questionArray.value).isDisabled\"></lib-question-boolean-template>\r\n\r\n <lib-question-text-template [setQuestion]=\"question\" (emitter)=\"onUpdateAnswer($event)\"\r\n *ngIf=\"question.questionTypeId == questionTypeEnum.TextInput\"\r\n [isShow]=\" (question|filterQuestion : fCtrls.questionArray.value).isShow\"\r\n [isDisabled]=\"(question|filterQuestion : fCtrls.questionArray.value).isDisabled\"\r\n [isTextArea]=\"question.isAdvanceTextArea\"></lib-question-text-template>\r\n\r\n <lib-question-radio-button-template [setQuestion]=\"question\" (emitter)=\"onUpdateAnswer($event)\"\r\n *ngIf=\"question.questionTypeId == questionTypeEnum.RadioButton\"\r\n [isShow]=\" (question|filterQuestion : fCtrls.questionArray.value).isShow\"\r\n [isDisabled]=\"(question|filterQuestion : fCtrls.questionArray.value).isDisabled\"></lib-question-radio-button-template>\r\n\r\n <lib-question-dropdown-template [setQuestion]=\"question\" (emitter)=\"onUpdateAnswer($event)\"\r\n *ngIf=\"question.questionTypeId == questionTypeEnum.DropDown\"\r\n [isShow]=\" (question|filterQuestion : fCtrls.questionArray.value).isShow\"\r\n [isDisabled]=\"(question|filterQuestion : fCtrls.questionArray.value).isDisabled\"></lib-question-dropdown-template>\r\n\r\n <lib-question-check-box-template [setQuestion]=\"question\" (emitter)=\"onUpdateAnswer($event)\"\r\n *ngIf=\"question.questionTypeId == questionTypeEnum.CheckBox\"\r\n [isShow]=\" (question|filterQuestion : fCtrls.questionArray.value).isShow\"\r\n [isDisabled]=\"(question|filterQuestion : fCtrls.questionArray.value).isDisabled\"></lib-question-check-box-template>\r\n\r\n <lib-question-matrix-template [setQuestion]=\"question\" (emitter)=\"onUpdateAnswers($event)\"\r\n *ngIf=\"question.questionTypeId == questionTypeEnum.Matrix\"\r\n [isShow]=\" (question|filterQuestion : fCtrls.questionArray.value).isShow\"\r\n [isDisabled]=\"(question|filterQuestion : fCtrls.questionArray.value).isDisabled\"></lib-question-matrix-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\">\r\n <nav aria-label=\"Page navigation example\">\r\n <ul class=\"pagination\">\r\n <li class=\"page-item previous-page-item \">\r\n <a class=\"page-link\" href=\"javascript:void(0)\" (click)=\"onPaggingBack()\"\r\n [ngClass]=\"{'disable__btn':fCtrls.currentPageIndex.value == 0}\">\u0627\u0644\u0633\u0627\u0628\u0642</a>\r\n </li>\r\n <li class=\"page-item active\" *ngFor=\"let item of surveyData?.surveyPages;let i = index\"\r\n [ngClass]=\"{'active': i == fCtrls.currentPageIndex.value}\">\r\n <a class=\"page-link\" href=\"javascript:void(0)\">{{i + 1}}</a>\r\n </li>\r\n <li class=\"page-item next-page-item\">\r\n <a class=\"page-link\" href=\"javascript:void(0)\" (click)=\"onPaggingNext()\"\r\n [ngClass]=\"{'disable__btn':fCtrls.currentPageIndex.value == (surveyData.surveyPages.length - 1)}\">\u0627\u0644\u062A\u0627\u0644\u064A</a>\r\n </li>\r\n </ul>\r\n </nav>\r\n </div>\r\n </div>\r\n </div>\r\n</div>", styles: [".disable__btn{background-color:gray!important;cursor:not-allowed}\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: ["isShow", "isTextArea", "setQuestion", "isDisabled"], outputs: ["emitter"] }, { kind: "component", type: QuestionRadioButtonTemplateComponent, selector: "lib-question-radio-button-template", inputs: ["isShow", "isDisabled", "setQuestion"], outputs: ["emitter"] }, { kind: "component", type: QuestionCheckBoxTemplateComponent, selector: "lib-question-check-box-template", inputs: ["isShow", "isDisabled", "setQuestion"], outputs: ["emitter"] }, { kind: "component", type: QuestionDropdownTemplateComponent, selector: "lib-question-dropdown-template", inputs: ["isShow", "isDisabled", "setQuestion"], outputs: ["emitter"] }, { kind: "component", type: QuestionMatrixTemplateComponent, selector: "lib-question-matrix-template", inputs: ["isShow", "isDisabled", "setQuestion"], outputs: ["emitter"] }, { kind: "component", type: QuestionBooleanTemplateComponent, selector: "lib-question-boolean-template", inputs: ["isShow", "isDisabled", "setQuestion"], outputs: ["emitter"] }, { kind: "pipe", type: FilterQuestionPipe, name: "filterQuestion" }] }); }
|
|
583
927
|
}
|
|
584
928
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: SurveryLibComponent, decorators: [{
|
|
585
929
|
type: Component,
|
|
586
|
-
args: [{ selector: 'lib-survery-lib', template: "<div 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\">\r\n {{item.questionGroupName}}\r\n </h2>\r\n <span class=\"group-sub-title \">\r\n {{item.questionGroupDescription}}\r\n </span>\r\n </div>\r\n <ng-container *ngFor=\"let question of item.surveyQuestions\">\r\n <lib-question-boolean-template [setQuestion]=\"question\" (emitter)=\"onUpdateAnswer($event)\"\r\n
|
|
587
|
-
}], ctorParameters: function () { return [{ type: SurveyLibService }, { type: i1.FormBuilder }, { type:
|
|
930
|
+
args: [{ selector: 'lib-survery-lib', template: "<div 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\">\r\n {{item.questionGroupName}}\r\n </h2>\r\n <span class=\"group-sub-title \">\r\n {{item.questionGroupDescription}}\r\n </span>\r\n </div>\r\n <ng-container *ngFor=\"let question of item.surveyQuestions\">\r\n <lib-question-boolean-template [setQuestion]=\"question\" (emitter)=\"onUpdateAnswer($event)\"\r\n *ngIf=\"question.questionTypeId == questionTypeEnum.Boolean\"\r\n [isShow]=\" (question|filterQuestion : fCtrls.questionArray.value).isShow\"\r\n [isDisabled]=\"(question|filterQuestion : fCtrls.questionArray.value).isDisabled\"></lib-question-boolean-template>\r\n\r\n <lib-question-text-template [setQuestion]=\"question\" (emitter)=\"onUpdateAnswer($event)\"\r\n *ngIf=\"question.questionTypeId == questionTypeEnum.TextInput\"\r\n [isShow]=\" (question|filterQuestion : fCtrls.questionArray.value).isShow\"\r\n [isDisabled]=\"(question|filterQuestion : fCtrls.questionArray.value).isDisabled\"\r\n [isTextArea]=\"question.isAdvanceTextArea\"></lib-question-text-template>\r\n\r\n <lib-question-radio-button-template [setQuestion]=\"question\" (emitter)=\"onUpdateAnswer($event)\"\r\n *ngIf=\"question.questionTypeId == questionTypeEnum.RadioButton\"\r\n [isShow]=\" (question|filterQuestion : fCtrls.questionArray.value).isShow\"\r\n [isDisabled]=\"(question|filterQuestion : fCtrls.questionArray.value).isDisabled\"></lib-question-radio-button-template>\r\n\r\n <lib-question-dropdown-template [setQuestion]=\"question\" (emitter)=\"onUpdateAnswer($event)\"\r\n *ngIf=\"question.questionTypeId == questionTypeEnum.DropDown\"\r\n [isShow]=\" (question|filterQuestion : fCtrls.questionArray.value).isShow\"\r\n [isDisabled]=\"(question|filterQuestion : fCtrls.questionArray.value).isDisabled\"></lib-question-dropdown-template>\r\n\r\n <lib-question-check-box-template [setQuestion]=\"question\" (emitter)=\"onUpdateAnswer($event)\"\r\n *ngIf=\"question.questionTypeId == questionTypeEnum.CheckBox\"\r\n [isShow]=\" (question|filterQuestion : fCtrls.questionArray.value).isShow\"\r\n [isDisabled]=\"(question|filterQuestion : fCtrls.questionArray.value).isDisabled\"></lib-question-check-box-template>\r\n\r\n <lib-question-matrix-template [setQuestion]=\"question\" (emitter)=\"onUpdateAnswers($event)\"\r\n *ngIf=\"question.questionTypeId == questionTypeEnum.Matrix\"\r\n [isShow]=\" (question|filterQuestion : fCtrls.questionArray.value).isShow\"\r\n [isDisabled]=\"(question|filterQuestion : fCtrls.questionArray.value).isDisabled\"></lib-question-matrix-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\">\r\n <nav aria-label=\"Page navigation example\">\r\n <ul class=\"pagination\">\r\n <li class=\"page-item previous-page-item \">\r\n <a class=\"page-link\" href=\"javascript:void(0)\" (click)=\"onPaggingBack()\"\r\n [ngClass]=\"{'disable__btn':fCtrls.currentPageIndex.value == 0}\">\u0627\u0644\u0633\u0627\u0628\u0642</a>\r\n </li>\r\n <li class=\"page-item active\" *ngFor=\"let item of surveyData?.surveyPages;let i = index\"\r\n [ngClass]=\"{'active': i == fCtrls.currentPageIndex.value}\">\r\n <a class=\"page-link\" href=\"javascript:void(0)\">{{i + 1}}</a>\r\n </li>\r\n <li class=\"page-item next-page-item\">\r\n <a class=\"page-link\" href=\"javascript:void(0)\" (click)=\"onPaggingNext()\"\r\n [ngClass]=\"{'disable__btn':fCtrls.currentPageIndex.value == (surveyData.surveyPages.length - 1)}\">\u0627\u0644\u062A\u0627\u0644\u064A</a>\r\n </li>\r\n </ul>\r\n </nav>\r\n </div>\r\n </div>\r\n </div>\r\n</div>", styles: [".disable__btn{background-color:gray!important;cursor:not-allowed}\n"] }]
|
|
931
|
+
}], ctorParameters: function () { return [{ type: SurveyLibService }, { type: i1.FormBuilder }, { type: CheckRuleExpsUsecase }]; }, propDecorators: { surveyResultEmit: [{
|
|
588
932
|
type: Output
|
|
589
933
|
}] } });
|
|
590
934
|
|
|
@@ -601,7 +945,8 @@ class SurveryLibModule {
|
|
|
601
945
|
QuestionCheckBoxTemplateComponent,
|
|
602
946
|
QuestionDropdownTemplateComponent,
|
|
603
947
|
QuestionMatrixTemplateComponent,
|
|
604
|
-
QuestionBooleanTemplateComponent
|
|
948
|
+
QuestionBooleanTemplateComponent,
|
|
949
|
+
FilterQuestionPipe], imports: [CommonModule, HttpClientModule, ReactiveFormsModule, FormsModule, NgsFormsModule], exports: [SurveryLibComponent] }); }
|
|
605
950
|
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: SurveryLibModule, imports: [CommonModule, HttpClientModule, ReactiveFormsModule, FormsModule, NgsFormsModule] }); }
|
|
606
951
|
}
|
|
607
952
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: SurveryLibModule, decorators: [{
|
|
@@ -614,7 +959,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImpor
|
|
|
614
959
|
QuestionCheckBoxTemplateComponent,
|
|
615
960
|
QuestionDropdownTemplateComponent,
|
|
616
961
|
QuestionMatrixTemplateComponent,
|
|
617
|
-
QuestionBooleanTemplateComponent
|
|
962
|
+
QuestionBooleanTemplateComponent,
|
|
963
|
+
FilterQuestionPipe
|
|
618
964
|
],
|
|
619
965
|
imports: [
|
|
620
966
|
CommonModule, HttpClientModule, ReactiveFormsModule, FormsModule, NgsFormsModule
|