survery-lib 0.1.55 → 0.1.57
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-text-template/question-text-template.component.mjs +22 -7
- package/esm2022/lib/survery-lib.component.mjs +34 -10
- package/esm2022/lib/usecases/check-rule-exps.usecase.mjs +1 -1
- package/esm2022/shared/form-interfaces/survery-lib.form-interface.mjs +1 -1
- package/fesm2022/survery-lib.mjs +65 -27
- package/fesm2022/survery-lib.mjs.map +1 -1
- package/package.json +1 -1
- package/shared/form-interfaces/survery-lib.form-interface.d.ts +3 -0
package/fesm2022/survery-lib.mjs
CHANGED
|
@@ -34,6 +34,18 @@ var LogicActionEnum;
|
|
|
34
34
|
LogicActionEnum[LogicActionEnum["SetAnswer"] = 5] = "SetAnswer";
|
|
35
35
|
})(LogicActionEnum || (LogicActionEnum = {}));
|
|
36
36
|
|
|
37
|
+
var InputTypeEnum;
|
|
38
|
+
(function (InputTypeEnum) {
|
|
39
|
+
InputTypeEnum[InputTypeEnum["Color"] = 1] = "Color";
|
|
40
|
+
InputTypeEnum[InputTypeEnum["Date"] = 2] = "Date";
|
|
41
|
+
InputTypeEnum[InputTypeEnum["DateTime"] = 3] = "DateTime";
|
|
42
|
+
InputTypeEnum[InputTypeEnum["Email"] = 4] = "Email";
|
|
43
|
+
InputTypeEnum[InputTypeEnum["Number"] = 5] = "Number";
|
|
44
|
+
InputTypeEnum[InputTypeEnum["Password"] = 6] = "Password";
|
|
45
|
+
InputTypeEnum[InputTypeEnum["Text"] = 7] = "Text";
|
|
46
|
+
InputTypeEnum[InputTypeEnum["Phone"] = 8] = "Phone";
|
|
47
|
+
})(InputTypeEnum || (InputTypeEnum = {}));
|
|
48
|
+
|
|
37
49
|
class SurveyLibService {
|
|
38
50
|
get surveyDataObsrv() {
|
|
39
51
|
return this.surveyDataSubject.asObservable();
|
|
@@ -263,18 +275,6 @@ class CheckRulesUsecaseModel {
|
|
|
263
275
|
class CheckRulesUsecaseResult {
|
|
264
276
|
}
|
|
265
277
|
|
|
266
|
-
var InputTypeEnum;
|
|
267
|
-
(function (InputTypeEnum) {
|
|
268
|
-
InputTypeEnum[InputTypeEnum["Color"] = 1] = "Color";
|
|
269
|
-
InputTypeEnum[InputTypeEnum["Date"] = 2] = "Date";
|
|
270
|
-
InputTypeEnum[InputTypeEnum["DateTime"] = 3] = "DateTime";
|
|
271
|
-
InputTypeEnum[InputTypeEnum["Email"] = 4] = "Email";
|
|
272
|
-
InputTypeEnum[InputTypeEnum["Number"] = 5] = "Number";
|
|
273
|
-
InputTypeEnum[InputTypeEnum["Password"] = 6] = "Password";
|
|
274
|
-
InputTypeEnum[InputTypeEnum["Text"] = 7] = "Text";
|
|
275
|
-
InputTypeEnum[InputTypeEnum["Phone"] = 8] = "Phone";
|
|
276
|
-
})(InputTypeEnum || (InputTypeEnum = {}));
|
|
277
|
-
|
|
278
278
|
function PhoneValidator(control) {
|
|
279
279
|
if (control.value) {
|
|
280
280
|
var phoneCode = control.value.trim().slice(0, 2);
|
|
@@ -468,12 +468,27 @@ class QuestionTextTemplateComponent {
|
|
|
468
468
|
ngOnInit() {
|
|
469
469
|
this.fCtrls.answer.valueChanges.pipe().pipe(debounceTime(200)).subscribe(value => {
|
|
470
470
|
const formValue = this.rForm.value;
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
471
|
+
if (formValue.inputTypeId == InputTypeEnum.Email) {
|
|
472
|
+
const isRequired = this.fCtrls.answer.hasValidator(Validators.required);
|
|
473
|
+
if (!isRequired) {
|
|
474
|
+
if (value?.trim()) {
|
|
475
|
+
this.fCtrls.answer.addValidators([Validators.email]);
|
|
476
|
+
}
|
|
477
|
+
else {
|
|
478
|
+
this.fCtrls.answer.clearValidators();
|
|
479
|
+
}
|
|
480
|
+
this.fCtrls.answer.updateValueAndValidity();
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
setTimeout(() => {
|
|
484
|
+
const formValue = this.rForm.value;
|
|
485
|
+
this.emitter.emit({
|
|
486
|
+
QuestionId: formValue.id,
|
|
487
|
+
IsValid: this.fCtrls.answer.valid,
|
|
488
|
+
Answer: value,
|
|
489
|
+
SurveyAnswerId: formValue.surveyAnswerId
|
|
490
|
+
});
|
|
491
|
+
}, 100);
|
|
477
492
|
});
|
|
478
493
|
this.fCtrls.answer.setValue(null);
|
|
479
494
|
this._surveyLibService.surveyAnswersObsrv.pipe(map(x => x.defaultAnswers.filter(x => x.QuestionId == this.fCtrls.id.value)))
|
|
@@ -1205,8 +1220,13 @@ class SurveryLibComponent {
|
|
|
1205
1220
|
var pageArr = [];
|
|
1206
1221
|
for (let index = 0; index < this.fCtrls.questionArray.value.length; index++) {
|
|
1207
1222
|
const question = this.fCtrls.questionArray.value[index];
|
|
1208
|
-
if (question.isShow == true
|
|
1209
|
-
|
|
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
|
+
}
|
|
1210
1230
|
}
|
|
1211
1231
|
}
|
|
1212
1232
|
const distinctArray = pageArr.filter((n, i) => pageArr.indexOf(n) === i);
|
|
@@ -1331,7 +1351,7 @@ class SurveryLibComponent {
|
|
|
1331
1351
|
questionGroup.controls.answerId.setValue(model.Answer);
|
|
1332
1352
|
}
|
|
1333
1353
|
if (this.fCtrls.ruleQuestionArray.value.findIndex(x => x.questionId == model.QuestionId) > -1) {
|
|
1334
|
-
this.checkRules();
|
|
1354
|
+
this.checkRules(questionGroup.value.questionId);
|
|
1335
1355
|
}
|
|
1336
1356
|
}
|
|
1337
1357
|
}
|
|
@@ -1346,22 +1366,37 @@ class SurveryLibComponent {
|
|
|
1346
1366
|
survey.surveyRules.forEach(rule => {
|
|
1347
1367
|
rule.ruleExps.forEach(ruleExp => {
|
|
1348
1368
|
this.fCtrls.ruleQuestionArray.push(this._formBuilder.group({
|
|
1349
|
-
questionId: ruleExp.questionId
|
|
1369
|
+
questionId: ruleExp.questionId,
|
|
1370
|
+
ruleId: rule.ruleId
|
|
1350
1371
|
}));
|
|
1351
1372
|
});
|
|
1352
1373
|
});
|
|
1353
1374
|
}
|
|
1354
1375
|
haveInValidateQuestions() {
|
|
1355
1376
|
const currentPageIndex = this.fCtrls.currentPageIndex.value;
|
|
1356
|
-
var invalidRecords =
|
|
1357
|
-
|
|
1377
|
+
var invalidRecords = [];
|
|
1378
|
+
var arr = this.fCtrls.questionArray.value.filter(x => x.surveyPageIndex == currentPageIndex && x.isDisabled == false && x.isShow == true);
|
|
1379
|
+
arr.map(x => {
|
|
1380
|
+
if (x.isRequired == true && x.isValid != true && x.isMatrixGroup != true) {
|
|
1381
|
+
invalidRecords.push(x);
|
|
1382
|
+
}
|
|
1383
|
+
else {
|
|
1384
|
+
if (x.questionType == QuestionTypeEnum.TextInput && x.inputTypeId == InputTypeEnum.Email) {
|
|
1385
|
+
if (x.answerText?.trim() && x.isValid != true) {
|
|
1386
|
+
invalidRecords.push(x);
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
});
|
|
1358
1391
|
if (invalidRecords.length > 0) {
|
|
1359
1392
|
$(`#survey-page_${currentPageIndex}`).addClass('survey-page_submitted');
|
|
1360
1393
|
}
|
|
1361
1394
|
return invalidRecords;
|
|
1362
1395
|
}
|
|
1363
|
-
checkRules() {
|
|
1364
|
-
this.
|
|
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 => {
|
|
1365
1400
|
this._checkRuleExpsUsecase.execute({
|
|
1366
1401
|
ruleExps: rule.ruleExps,
|
|
1367
1402
|
questions: this.fCtrls.questionArray.value,
|
|
@@ -1444,6 +1479,7 @@ class SurveryLibComponent {
|
|
|
1444
1479
|
surveyPageIndex: pageIndex,
|
|
1445
1480
|
questionId: [question.questionId],
|
|
1446
1481
|
questionType: [question.questionTypeId],
|
|
1482
|
+
inputTypeId: [question.surveyAnswers[0].inputTypeId],
|
|
1447
1483
|
isMatrixGroup: [false],
|
|
1448
1484
|
answerId: [null],
|
|
1449
1485
|
answerIdArr: [null],
|
|
@@ -1461,6 +1497,7 @@ class SurveryLibComponent {
|
|
|
1461
1497
|
surveyPageIndex: pageIndex,
|
|
1462
1498
|
questionId: [question.questionId],
|
|
1463
1499
|
questionType: [question.questionTypeId],
|
|
1500
|
+
inputTypeId: [question.surveyAnswers[0].inputTypeId],
|
|
1464
1501
|
isMatrixGroup: [true],
|
|
1465
1502
|
answerId: [null],
|
|
1466
1503
|
answerIdArr: [null],
|
|
@@ -1476,7 +1513,8 @@ class SurveryLibComponent {
|
|
|
1476
1513
|
this.fCtrls.questionArray.push(this._formBuilder.group({
|
|
1477
1514
|
surveyPageIndex: pageIndex,
|
|
1478
1515
|
questionId: [subQuestion.questionId],
|
|
1479
|
-
questionType: [
|
|
1516
|
+
questionType: [question.questionTypeId],
|
|
1517
|
+
inputTypeId: [question.surveyAnswers[0].inputTypeId],
|
|
1480
1518
|
isMatrixGroup: [false],
|
|
1481
1519
|
answerId: [null],
|
|
1482
1520
|
answerIdArr: [null],
|