survery-lib 0.1.11 → 0.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/assets/style.css.map +1 -1
  2. package/esm2022/lib/components/question-boolean-template/question-boolean-template.component.mjs +99 -0
  3. package/esm2022/lib/components/question-check-box-template/question-check-box-template.component.mjs +110 -0
  4. package/esm2022/lib/components/question-dropdown-multi-template/question-dropdown-multi-template.component.mjs +95 -0
  5. package/esm2022/lib/components/question-dropdown-template/question-dropdown-template.component.mjs +83 -0
  6. package/esm2022/lib/components/question-matrix-template/question-matrix-template.component.mjs +101 -0
  7. package/esm2022/lib/components/question-radio-button-template/question-radio-button-template.component.mjs +99 -0
  8. package/esm2022/lib/components/question-text-template/question-text-template.component.mjs +99 -0
  9. package/esm2022/lib/pipes/default-question-answer.pipe.mjs +19 -0
  10. package/esm2022/lib/pipes/default-question-answers.pipe.mjs +19 -0
  11. package/esm2022/lib/pipes/filter-question.pipe.mjs +16 -0
  12. package/esm2022/lib/services/survey-lib.service.mjs +30 -0
  13. package/esm2022/lib/survery-lib.component.mjs +302 -0
  14. package/esm2022/lib/survery-lib.module.mjs +63 -0
  15. package/esm2022/lib/usecases/base/use-case.mjs +2 -0
  16. package/esm2022/lib/usecases/check-rule-exps.usecase.mjs +154 -0
  17. package/esm2022/public-api.mjs +8 -0
  18. package/esm2022/shared/dtos/default-question-answers.dto.mjs +3 -0
  19. package/esm2022/shared/dtos/rule-exp-answer.dto.mjs +2 -0
  20. package/esm2022/shared/dtos/rule-exp.dto.mjs +2 -0
  21. package/esm2022/shared/dtos/rule-result-question.dto.mjs +2 -0
  22. package/esm2022/shared/dtos/survey-answer.dto.mjs +2 -0
  23. package/esm2022/shared/dtos/survey-answers-subject.dto.mjs +3 -0
  24. package/esm2022/shared/dtos/survey-page.dto.mjs +2 -0
  25. package/esm2022/shared/dtos/survey-question-group.dto.mjs +2 -0
  26. package/esm2022/shared/dtos/survey-question.dto.mjs +2 -0
  27. package/esm2022/shared/dtos/survey-rule.dto.mjs +2 -0
  28. package/esm2022/shared/dtos/survey-sub-question.dto.mjs +2 -0
  29. package/esm2022/shared/dtos/survey.dto.mjs +2 -0
  30. package/esm2022/shared/enums/Logic-Property.enum.mjs +14 -0
  31. package/esm2022/shared/enums/logic-action.enum.mjs +9 -0
  32. package/esm2022/shared/enums/operator.enum.mjs +6 -0
  33. package/esm2022/shared/enums/question-type.enum.mjs +11 -0
  34. package/esm2022/shared/form-interfaces/question-boolean-template.form-interface.mjs +2 -0
  35. package/esm2022/shared/form-interfaces/question-check-box-template.form-interface.mjs +3 -0
  36. package/esm2022/shared/form-interfaces/question-dropdown-multi-template.form-interface.mjs +3 -0
  37. package/esm2022/shared/form-interfaces/question-dropdown-template.form-interface.mjs +3 -0
  38. package/esm2022/shared/form-interfaces/question-matrix-template.form-interface.mjs +2 -0
  39. package/esm2022/shared/form-interfaces/question-radio-button-template.form-interface.mjs +3 -0
  40. package/esm2022/shared/form-interfaces/question-text-template.form-interface.mjs +2 -0
  41. package/esm2022/shared/form-interfaces/survery-lib.form-interface.mjs +2 -0
  42. package/esm2022/shared/models/question-answer.model.mjs +3 -0
  43. package/esm2022/shared/models/survery-question-result.model.mjs +3 -0
  44. package/esm2022/survery-lib.mjs +5 -0
  45. package/fesm2022/survery-lib.mjs +1240 -0
  46. package/fesm2022/survery-lib.mjs.map +1 -0
  47. package/index.d.ts +5 -0
  48. package/lib/components/question-boolean-template/question-boolean-template.component.d.ts +36 -0
  49. package/lib/components/question-check-box-template/question-check-box-template.component.d.ts +37 -0
  50. package/lib/components/question-dropdown-multi-template/question-dropdown-multi-template.component.d.ts +35 -0
  51. package/lib/components/question-dropdown-template/question-dropdown-template.component.d.ts +33 -0
  52. package/lib/components/question-matrix-template/question-matrix-template.component.d.ts +33 -0
  53. package/lib/components/question-radio-button-template/question-radio-button-template.component.d.ts +36 -0
  54. package/lib/components/question-text-template/question-text-template.component.d.ts +35 -0
  55. package/lib/pipes/default-question-answer.pipe.d.ts +8 -0
  56. package/lib/pipes/default-question-answers.pipe.d.ts +8 -0
  57. package/lib/pipes/filter-question.pipe.d.ts +9 -0
  58. package/lib/services/survey-lib.service.d.ts +14 -0
  59. package/lib/survery-lib.component.d.ts +49 -0
  60. package/lib/survery-lib.module.d.ts +24 -0
  61. package/{src/lib/usecases/base/use-case.ts → lib/usecases/base/use-case.d.ts} +7 -9
  62. package/lib/usecases/check-rule-exps.usecase.d.ts +21 -0
  63. package/package.json +28 -15
  64. package/{src/public-api.ts → public-api.d.ts} +1 -5
  65. package/shared/dtos/default-question-answers.dto.d.ts +9 -0
  66. package/{src/shared/dtos/rule-exp-answer.dto.ts → shared/dtos/rule-exp-answer.dto.d.ts} +5 -5
  67. package/{src/shared/dtos/rule-exp.dto.ts → shared/dtos/rule-exp.dto.d.ts} +13 -14
  68. package/{src/shared/dtos/rule-result-question.dto.ts → shared/dtos/rule-result-question.dto.d.ts} +4 -5
  69. package/{src/shared/dtos/survey-answer.dto.ts → shared/dtos/survey-answer.dto.d.ts} +16 -16
  70. package/{src/shared/dtos/survey-answers-subject.dto.ts → shared/dtos/survey-answers-subject.dto.d.ts} +5 -6
  71. package/{src/shared/dtos/survey-page.dto.ts → shared/dtos/survey-page.dto.d.ts} +9 -10
  72. package/{src/shared/dtos/survey-question-group.dto.ts → shared/dtos/survey-question-group.dto.d.ts} +8 -9
  73. package/{src/shared/dtos/survey-question.dto.ts → shared/dtos/survey-question.dto.d.ts} +18 -19
  74. package/{src/shared/dtos/survey-rule.dto.ts → shared/dtos/survey-rule.dto.d.ts} +10 -11
  75. package/{src/shared/dtos/survey-sub-question.dto.ts → shared/dtos/survey-sub-question.dto.d.ts} +9 -9
  76. package/{src/shared/dtos/survey.dto.ts → shared/dtos/survey.dto.d.ts} +16 -17
  77. package/shared/enums/Logic-Property.enum.d.ts +12 -0
  78. package/{src/shared/enums/logic-action.enum.ts → shared/enums/logic-action.enum.d.ts} +7 -7
  79. package/shared/enums/operator.enum.d.ts +4 -0
  80. package/{src/shared/enums/question-type.enum.ts → shared/enums/question-type.enum.d.ts} +9 -9
  81. package/shared/form-interfaces/question-boolean-template.form-interface.d.ts +15 -0
  82. package/shared/form-interfaces/question-check-box-template.form-interface.d.ts +15 -0
  83. package/shared/form-interfaces/question-dropdown-multi-template.form-interface.d.ts +15 -0
  84. package/shared/form-interfaces/question-dropdown-template.form-interface.d.ts +9 -0
  85. package/{src/shared/form-interfaces/question-matrix-template.form-interface.ts → shared/form-interfaces/question-matrix-template.form-interface.d.ts} +11 -13
  86. package/shared/form-interfaces/question-radio-button-template.form-interface.d.ts +15 -0
  87. package/shared/form-interfaces/question-text-template.form-interface.d.ts +10 -0
  88. package/shared/form-interfaces/survery-lib.form-interface.d.ts +24 -0
  89. package/shared/models/question-answer.model.d.ts +6 -0
  90. package/shared/models/survery-question-result.model.d.ts +8 -0
  91. package/ng-package.json +0 -11
  92. package/scss/style.scss +0 -88
  93. package/src/lib/components/question-boolean-template/question-boolean-template.component.html +0 -13
  94. package/src/lib/components/question-boolean-template/question-boolean-template.component.scss +0 -0
  95. package/src/lib/components/question-boolean-template/question-boolean-template.component.spec.ts +0 -21
  96. package/src/lib/components/question-boolean-template/question-boolean-template.component.ts +0 -109
  97. package/src/lib/components/question-check-box-template/question-check-box-template.component.html +0 -13
  98. package/src/lib/components/question-check-box-template/question-check-box-template.component.scss +0 -0
  99. package/src/lib/components/question-check-box-template/question-check-box-template.component.spec.ts +0 -21
  100. package/src/lib/components/question-check-box-template/question-check-box-template.component.ts +0 -124
  101. package/src/lib/components/question-dropdown-multi-template/question-dropdown-multi-template.component.html +0 -10
  102. package/src/lib/components/question-dropdown-multi-template/question-dropdown-multi-template.component.scss +0 -3
  103. package/src/lib/components/question-dropdown-multi-template/question-dropdown-multi-template.component.spec.ts +0 -21
  104. package/src/lib/components/question-dropdown-multi-template/question-dropdown-multi-template.component.ts +0 -100
  105. package/src/lib/components/question-dropdown-template/question-dropdown-template.component.html +0 -10
  106. package/src/lib/components/question-dropdown-template/question-dropdown-template.component.scss +0 -0
  107. package/src/lib/components/question-dropdown-template/question-dropdown-template.component.spec.ts +0 -21
  108. package/src/lib/components/question-dropdown-template/question-dropdown-template.component.ts +0 -87
  109. package/src/lib/components/question-matrix-template/question-matrix-template.component.html +0 -36
  110. package/src/lib/components/question-matrix-template/question-matrix-template.component.scss +0 -0
  111. package/src/lib/components/question-matrix-template/question-matrix-template.component.spec.ts +0 -21
  112. package/src/lib/components/question-matrix-template/question-matrix-template.component.ts +0 -110
  113. package/src/lib/components/question-radio-button-template/question-radio-button-template.component.html +0 -13
  114. package/src/lib/components/question-radio-button-template/question-radio-button-template.component.scss +0 -0
  115. package/src/lib/components/question-radio-button-template/question-radio-button-template.component.spec.ts +0 -21
  116. package/src/lib/components/question-radio-button-template/question-radio-button-template.component.ts +0 -111
  117. package/src/lib/components/question-text-template/question-text-template.component.html +0 -13
  118. package/src/lib/components/question-text-template/question-text-template.component.scss +0 -0
  119. package/src/lib/components/question-text-template/question-text-template.component.spec.ts +0 -21
  120. package/src/lib/components/question-text-template/question-text-template.component.ts +0 -105
  121. package/src/lib/pipes/default-question-answer.pipe.spec.ts +0 -8
  122. package/src/lib/pipes/default-question-answer.pipe.ts +0 -18
  123. package/src/lib/pipes/default-question-answers.pipe.spec.ts +0 -8
  124. package/src/lib/pipes/default-question-answers.pipe.ts +0 -17
  125. package/src/lib/pipes/filter-question.pipe.spec.ts +0 -8
  126. package/src/lib/pipes/filter-question.pipe.ts +0 -14
  127. package/src/lib/services/survey-lib.service.spec.ts +0 -16
  128. package/src/lib/services/survey-lib.service.ts +0 -31
  129. package/src/lib/survery-lib.component.spec.ts +0 -21
  130. package/src/lib/survery-lib.component.ts +0 -308
  131. package/src/lib/survery-lib.module.ts +0 -47
  132. package/src/lib/survey-lib.component.html +0 -67
  133. package/src/lib/survey-lib.component.scss +0 -4
  134. package/src/lib/usecases/check-rule-exps.usecase.ts +0 -188
  135. package/src/shared/dtos/default-question-answers.dto.ts +0 -10
  136. package/src/shared/enums/logic-property.enum.ts +0 -12
  137. package/src/shared/enums/operator.enum.ts +0 -4
  138. package/src/shared/form-interfaces/question-boolean-template.form-interface.ts +0 -17
  139. package/src/shared/form-interfaces/question-check-box-template.form-interface.ts +0 -18
  140. package/src/shared/form-interfaces/question-dropdown-multi-template.form-interface.ts +0 -17
  141. package/src/shared/form-interfaces/question-dropdown-template.form-interface.ts +0 -10
  142. package/src/shared/form-interfaces/question-radio-button-template.form-interface.ts +0 -17
  143. package/src/shared/form-interfaces/question-text-template.form-interface.ts +0 -11
  144. package/src/shared/form-interfaces/survery-lib.form-interface.ts +0 -27
  145. package/src/shared/models/question-answer.model.ts +0 -6
  146. package/src/shared/models/survery-question-result.model.ts +0 -8
  147. package/tsconfig.lib.json +0 -14
  148. package/tsconfig.lib.prod.json +0 -10
  149. package/tsconfig.spec.json +0 -14
@@ -0,0 +1,1240 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Injectable, EventEmitter, Component, Output, Input, Pipe, NgModule } from '@angular/core';
3
+ import { v4 } from 'uuid';
4
+ import { Subject, of, debounceTime, map, filter } from 'rxjs';
5
+ import * as i1 from '@ng-stack/forms';
6
+ import { Validators as Validators$1, NgsFormsModule } from '@ng-stack/forms';
7
+ import * as i3 from '@angular/common';
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';
12
+ import { NgSelectModule } from '@ng-select/ng-select';
13
+ import { HttpClientModule } from '@angular/common/http';
14
+
15
+ var QuestionTypeEnum;
16
+ (function (QuestionTypeEnum) {
17
+ QuestionTypeEnum[QuestionTypeEnum["RadioButton"] = 1] = "RadioButton";
18
+ QuestionTypeEnum[QuestionTypeEnum["CheckBox"] = 2] = "CheckBox";
19
+ QuestionTypeEnum[QuestionTypeEnum["DropDown"] = 3] = "DropDown";
20
+ QuestionTypeEnum[QuestionTypeEnum["Boolean"] = 4] = "Boolean";
21
+ QuestionTypeEnum[QuestionTypeEnum["TextInput"] = 5] = "TextInput";
22
+ QuestionTypeEnum[QuestionTypeEnum["Matrix"] = 6] = "Matrix";
23
+ QuestionTypeEnum[QuestionTypeEnum["DropDownMulti"] = 7] = "DropDownMulti";
24
+ })(QuestionTypeEnum || (QuestionTypeEnum = {}));
25
+
26
+ var LogicActionEnum;
27
+ (function (LogicActionEnum) {
28
+ LogicActionEnum[LogicActionEnum["Show"] = 1] = "Show";
29
+ LogicActionEnum[LogicActionEnum["Hide"] = 2] = "Hide";
30
+ LogicActionEnum[LogicActionEnum["Enable"] = 3] = "Enable";
31
+ LogicActionEnum[LogicActionEnum["Disable"] = 4] = "Disable";
32
+ LogicActionEnum[LogicActionEnum["SetAnswer"] = 5] = "SetAnswer";
33
+ })(LogicActionEnum || (LogicActionEnum = {}));
34
+
35
+ class SurveyLibService {
36
+ get surveyDataObsrv() {
37
+ return this.surveyDataSubject.asObservable();
38
+ }
39
+ get surveyAnswersObsrv() {
40
+ return this.surveyAnswersSubject.asObservable();
41
+ }
42
+ constructor() {
43
+ this.surveyDataSubject = new Subject();
44
+ this.surveyAnswersSubject = new Subject();
45
+ }
46
+ setSurveyData(survey) {
47
+ this.surveyDataSubject.next(survey);
48
+ }
49
+ setsurveyAnswers(model) {
50
+ this.surveyAnswersSubject.next(model);
51
+ }
52
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: SurveyLibService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
53
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: SurveyLibService, providedIn: 'root' }); }
54
+ }
55
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: SurveyLibService, decorators: [{
56
+ type: Injectable,
57
+ args: [{
58
+ providedIn: 'root'
59
+ }]
60
+ }], ctorParameters: function () { return []; } });
61
+
62
+ var LogicPropertyEnum;
63
+ (function (LogicPropertyEnum) {
64
+ LogicPropertyEnum[LogicPropertyEnum["GreaterThan"] = 1] = "GreaterThan";
65
+ LogicPropertyEnum[LogicPropertyEnum["GreaterThanOrEqual"] = 2] = "GreaterThanOrEqual";
66
+ LogicPropertyEnum[LogicPropertyEnum["LessThan"] = 3] = "LessThan";
67
+ LogicPropertyEnum[LogicPropertyEnum["LessThanOrEqual"] = 4] = "LessThanOrEqual";
68
+ LogicPropertyEnum[LogicPropertyEnum["Equal"] = 5] = "Equal";
69
+ LogicPropertyEnum[LogicPropertyEnum["NotEqual"] = 6] = "NotEqual";
70
+ LogicPropertyEnum[LogicPropertyEnum["IsEmpty"] = 9] = "IsEmpty";
71
+ LogicPropertyEnum[LogicPropertyEnum["IsNotEmpty"] = 10] = "IsNotEmpty";
72
+ LogicPropertyEnum[LogicPropertyEnum["AnyOf"] = 11] = "AnyOf";
73
+ LogicPropertyEnum[LogicPropertyEnum["Then"] = 12] = "Then";
74
+ })(LogicPropertyEnum || (LogicPropertyEnum = {}));
75
+
76
+ var OperatorEnum;
77
+ (function (OperatorEnum) {
78
+ OperatorEnum[OperatorEnum["Or"] = 7] = "Or";
79
+ OperatorEnum[OperatorEnum["And"] = 8] = "And";
80
+ })(OperatorEnum || (OperatorEnum = {}));
81
+
82
+ class CheckRuleExpsUsecase {
83
+ constructor() {
84
+ }
85
+ execute(params) {
86
+ var useCaseResult = {
87
+ exprestionResultArr: []
88
+ };
89
+ params.ruleExps.forEach(ruleExp => {
90
+ const index = params.questions.findIndex(x => x.questionId == ruleExp.questionId);
91
+ var questionGroupValue = params.questions.at(index);
92
+ var result;
93
+ if (questionGroupValue.questionType == QuestionTypeEnum.TextInput) {
94
+ result = this.checkRuleExpForAnswerText(ruleExp, questionGroupValue.answerText);
95
+ }
96
+ else if (questionGroupValue.questionType == QuestionTypeEnum.CheckBox) {
97
+ result = this.checkRuleExpForAnswerIdArr(ruleExp, questionGroupValue.answerIdArr);
98
+ }
99
+ else {
100
+ result = this.checkRuleExpForAnswerId(ruleExp, questionGroupValue.answerId);
101
+ }
102
+ var answers = ruleExp.ruleExpAnswers.map(x => x.answerId + '-' + x.answerTitle);
103
+ 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]})`);
104
+ useCaseResult.exprestionResultArr.push(result);
105
+ });
106
+ return of(useCaseResult);
107
+ }
108
+ checkRuleExpForAnswerId(ruleExp, answerId) {
109
+ var ruleExpResultArr = [];
110
+ if (ruleExp.logicPropertyId == LogicPropertyEnum.GreaterThan) {
111
+ ruleExp.ruleExpAnswers.forEach(answer => {
112
+ var result = answerId > answer.answerId;
113
+ ruleExpResultArr.push(result);
114
+ });
115
+ }
116
+ else if (ruleExp.logicPropertyId == LogicPropertyEnum.GreaterThanOrEqual) {
117
+ ruleExp.ruleExpAnswers.forEach(answer => {
118
+ var result = answerId >= answer.answerId;
119
+ ruleExpResultArr.push(result);
120
+ });
121
+ }
122
+ else if (ruleExp.logicPropertyId == LogicPropertyEnum.LessThan) {
123
+ ruleExp.ruleExpAnswers.forEach(answer => {
124
+ var result = answerId < answer.answerId;
125
+ ruleExpResultArr.push(result);
126
+ });
127
+ }
128
+ else if (ruleExp.logicPropertyId == LogicPropertyEnum.LessThanOrEqual) {
129
+ ruleExp.ruleExpAnswers.forEach(answer => {
130
+ var result = answerId <= answer.answerId;
131
+ ruleExpResultArr.push(result);
132
+ });
133
+ }
134
+ else if (ruleExp.logicPropertyId == LogicPropertyEnum.Equal) {
135
+ ruleExp.ruleExpAnswers.forEach(answer => {
136
+ var result = answerId == answer.answerId;
137
+ ruleExpResultArr.push(result);
138
+ });
139
+ }
140
+ else if (ruleExp.logicPropertyId == LogicPropertyEnum.NotEqual) {
141
+ ruleExp.ruleExpAnswers.forEach(answer => {
142
+ var result = answerId != answer.answerId;
143
+ ruleExpResultArr.push(result);
144
+ });
145
+ }
146
+ else if (ruleExp.logicPropertyId == LogicPropertyEnum.IsEmpty) {
147
+ var result = answerId == null;
148
+ ruleExpResultArr.push(result);
149
+ }
150
+ else if (ruleExp.logicPropertyId == LogicPropertyEnum.IsNotEmpty) {
151
+ var result = answerId != null;
152
+ ruleExpResultArr.push(result);
153
+ }
154
+ else if (ruleExp.logicPropertyId == LogicPropertyEnum.AnyOf) {
155
+ var answerIdArr = ruleExp.ruleExpAnswers.map(x => x.answerId);
156
+ var result = answerIdArr.findIndex(x => x == answerId) > -1;
157
+ ruleExpResultArr.push(result);
158
+ }
159
+ else if (ruleExp.logicPropertyId == LogicPropertyEnum.Then) {
160
+ var answerIdArr = ruleExp.ruleExpAnswers.map(x => x.answerId);
161
+ var result = answerIdArr.findIndex(x => x == answerId) == -1;
162
+ ruleExpResultArr.push(result);
163
+ }
164
+ if (ruleExpResultArr.length == 0) {
165
+ return false;
166
+ }
167
+ else if (ruleExp.ruleExpAnswers.length == 1) {
168
+ return ruleExpResultArr.filter(x => x == true).length > 0;
169
+ }
170
+ else if (ruleExp.opporator == OperatorEnum.Or) {
171
+ return ruleExpResultArr.filter(x => x == true).length > 0;
172
+ }
173
+ else {
174
+ return ruleExpResultArr.filter(x => x == false).length == 0;
175
+ }
176
+ }
177
+ checkRuleExpForAnswerIdArr(ruleExp, answerIdArr) {
178
+ var ruleExpResultArr = [];
179
+ answerIdArr?.forEach(answer => {
180
+ var isResult = this.checkRuleExpForAnswerId(ruleExp, answer);
181
+ ruleExpResultArr.push(isResult);
182
+ });
183
+ if (ruleExpResultArr.length == 0) {
184
+ return false;
185
+ }
186
+ else if (ruleExp.ruleExpAnswers.length == 1) {
187
+ return ruleExpResultArr.filter(x => x == true).length > 0;
188
+ }
189
+ else if (ruleExp.opporator == OperatorEnum.Or) {
190
+ return ruleExpResultArr.filter(x => x == true).length > 0;
191
+ }
192
+ else {
193
+ return ruleExpResultArr.filter(x => x == false).length == 0;
194
+ }
195
+ }
196
+ checkRuleExpForAnswerText(ruleExp, answer) {
197
+ var ruleExpResultArr = [];
198
+ if (ruleExp.logicPropertyId == LogicPropertyEnum.IsEmpty) {
199
+ var result = answer == null || answer == '';
200
+ ruleExpResultArr.push(result);
201
+ }
202
+ else if (ruleExp.logicPropertyId == LogicPropertyEnum.IsNotEmpty) {
203
+ var result = answer != null && answer != '';
204
+ ruleExpResultArr.push(result);
205
+ }
206
+ if (ruleExp.ruleExpAnswers.length == 1) {
207
+ return ruleExpResultArr.filter(x => x == true).length > 0;
208
+ }
209
+ else if (ruleExp.opporator == OperatorEnum.Or) {
210
+ return ruleExpResultArr.filter(x => x == true).length > 0;
211
+ }
212
+ else {
213
+ return ruleExpResultArr.filter(x => x == false).length == 0;
214
+ }
215
+ }
216
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: CheckRuleExpsUsecase, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
217
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: CheckRuleExpsUsecase, providedIn: 'root' }); }
218
+ }
219
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: CheckRuleExpsUsecase, decorators: [{
220
+ type: Injectable,
221
+ args: [{
222
+ providedIn: 'root'
223
+ }]
224
+ }], ctorParameters: function () { return []; } });
225
+ class CheckRulesUsecaseModel {
226
+ }
227
+ class CheckRulesUsecaseResult {
228
+ }
229
+
230
+ class QuestionTextTemplateComponent {
231
+ get fCtrls() {
232
+ return this.rForm.controls;
233
+ }
234
+ get questionTypeEnum() {
235
+ return QuestionTypeEnum;
236
+ }
237
+ set setQuestion(value) {
238
+ this.rForm.patchValue({
239
+ id: value.questionId,
240
+ name: value.questionName,
241
+ title: value.questionTitle,
242
+ typeId: value.questionTypeId,
243
+ description: value.questionDescription
244
+ });
245
+ if (value.surveyAnswers[0]?.answerId != null && value.surveyAnswers[0]?.answerId != undefined) {
246
+ this.fCtrls.surveyAnswerId.setValue(value.surveyAnswers[0].answerId);
247
+ }
248
+ if (value.isRequired == true) {
249
+ this.fCtrls.answer.addValidators([Validators.required]);
250
+ this.fCtrls.answer.updateValueAndValidity();
251
+ }
252
+ this.isShow = value.isVisable;
253
+ this.toggleEnableAnswer(value.isReadOnly);
254
+ }
255
+ set isDisabled(value) {
256
+ this.toggleEnableAnswer(value);
257
+ }
258
+ constructor(_formBuilder, _surveyLibService) {
259
+ this._formBuilder = _formBuilder;
260
+ this._surveyLibService = _surveyLibService;
261
+ this.emitter = new EventEmitter();
262
+ this.isShow = true;
263
+ this.rForm = this._formBuilder.group({
264
+ id: [null],
265
+ name: [null],
266
+ title: [null],
267
+ typeId: [null],
268
+ description: [null],
269
+ surveyAnswerId: [null],
270
+ answer: [null]
271
+ });
272
+ }
273
+ ngOnInit() {
274
+ this.fCtrls.answer.valueChanges.pipe().pipe(debounceTime(200)).subscribe(value => {
275
+ const formValue = this.rForm.value;
276
+ this.emitter.emit({
277
+ QuestionId: formValue.id,
278
+ IsValid: this.fCtrls.answer.valid,
279
+ Answer: value,
280
+ SurveyAnswerId: formValue.surveyAnswerId
281
+ });
282
+ });
283
+ this.fCtrls.answer.setValue(null);
284
+ this._surveyLibService.surveyAnswersObsrv.pipe(map(x => x.defaultAnswers.filter(x => x.QuestionId == this.fCtrls.id.value)))
285
+ .pipe(filter(x => x.length > 0)).pipe(map(x => x.at(0)))
286
+ .subscribe(answer => {
287
+ this.fCtrls.answer.setValue(answer.AnswerText);
288
+ });
289
+ }
290
+ convertToFormControl(element) {
291
+ return element;
292
+ }
293
+ toggleEnableAnswer(isReadOnly) {
294
+ if (isReadOnly == true) {
295
+ this.fCtrls.answer.disable();
296
+ }
297
+ else {
298
+ this.fCtrls.answer.enable();
299
+ }
300
+ this.fCtrls.answer.updateValueAndValidity();
301
+ }
302
+ 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 }); }
303
+ 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"] }] }); }
304
+ }
305
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionTextTemplateComponent, decorators: [{
306
+ type: Component,
307
+ 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>" }]
308
+ }], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: SurveyLibService }]; }, propDecorators: { emitter: [{
309
+ type: Output
310
+ }], isShow: [{
311
+ type: Input
312
+ }], isTextArea: [{
313
+ type: Input
314
+ }], setQuestion: [{
315
+ type: Input
316
+ }], isDisabled: [{
317
+ type: Input
318
+ }] } });
319
+
320
+ class QuestionRadioButtonTemplateComponent {
321
+ get fCtrls() {
322
+ return this.rForm.controls;
323
+ }
324
+ get questionTypeEnum() {
325
+ return QuestionTypeEnum;
326
+ }
327
+ set setQuestion(value) {
328
+ this.surveyQuestion = value;
329
+ this.rForm.patchValue({
330
+ id: value.questionId,
331
+ name: value.questionName,
332
+ title: value.questionTitle,
333
+ typeId: value.questionTypeId,
334
+ description: value.questionDescription
335
+ });
336
+ value.surveyAnswers.forEach(surveryAnswer => {
337
+ this.fCtrls.answerArray.push(this._formBuilder.group({
338
+ id: [surveryAnswer.answerId],
339
+ title: [surveryAnswer.answerTitle],
340
+ isSelected: [false]
341
+ }));
342
+ });
343
+ if (value.isRequired == true) {
344
+ this.fCtrls.answer.addValidators([Validators.required]);
345
+ this.fCtrls.answer.updateValueAndValidity();
346
+ }
347
+ this.isShow = value.isVisable;
348
+ this.isDisabled = value.isReadOnly;
349
+ }
350
+ constructor(_formBuilder, _surveyLibService) {
351
+ this._formBuilder = _formBuilder;
352
+ this._surveyLibService = _surveyLibService;
353
+ this.elemId = v4();
354
+ this.emitter = new EventEmitter();
355
+ this.isShow = true;
356
+ this.isDisabled = false;
357
+ this.rForm = this._formBuilder.group({
358
+ id: [null],
359
+ name: [null],
360
+ title: [null],
361
+ typeId: [null],
362
+ description: [null],
363
+ answer: [null],
364
+ answerArray: this._formBuilder.array([])
365
+ });
366
+ }
367
+ ngOnInit() {
368
+ this.fCtrls.answer.valueChanges.pipe().pipe(debounceTime(200)).subscribe(value => {
369
+ console.log(value);
370
+ const formValue = this.rForm.value;
371
+ this.emitter.emit({
372
+ QuestionId: formValue.id,
373
+ IsValid: this.fCtrls.answer.valid,
374
+ Answer: value
375
+ });
376
+ });
377
+ this.fCtrls.answer.setValue(null);
378
+ this._surveyLibService.surveyAnswersObsrv.pipe(map(x => x.defaultAnswers.filter(x => x.QuestionId == this.fCtrls.id.value)))
379
+ .pipe(filter(x => x.length > 0)).pipe(map(x => x.at(0)))
380
+ .subscribe(answer => {
381
+ this.fCtrls.answer.setValue(answer.AnswerId);
382
+ const groupIndex = this.fCtrls.answerArray.value.findIndex(x => x.id == answer.AnswerId);
383
+ if (groupIndex > -1) {
384
+ this.fCtrls.answerArray.at(groupIndex).controls.isSelected.setValue(true);
385
+ }
386
+ });
387
+ }
388
+ onChangeAnswer(item) {
389
+ this.fCtrls.answer.setValue(item.id);
390
+ }
391
+ convertToFormControl(element) {
392
+ return element;
393
+ }
394
+ 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 }); }
395
+ 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 fCtrls.answerArray.controls;let i = index\">\n <input class=\"form-check-input\" type=\"radio\" (change)=\"onChangeAnswer(item.value)\" [disabled]=\"isDisabled\"\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}}\">{{item.value.title}}</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"] }] }); }
396
+ }
397
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionRadioButtonTemplateComponent, decorators: [{
398
+ type: Component,
399
+ 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 fCtrls.answerArray.controls;let i = index\">\n <input class=\"form-check-input\" type=\"radio\" (change)=\"onChangeAnswer(item.value)\" [disabled]=\"isDisabled\"\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}}\">{{item.value.title}}</label>\n </div>\n </div>\n</div>\n" }]
400
+ }], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: SurveyLibService }]; }, propDecorators: { emitter: [{
401
+ type: Output
402
+ }], isShow: [{
403
+ type: Input
404
+ }], isDisabled: [{
405
+ type: Input
406
+ }], setQuestion: [{
407
+ type: Input
408
+ }] } });
409
+
410
+ class QuestionCheckBoxTemplateComponent {
411
+ get fCtrls() {
412
+ return this.rForm.controls;
413
+ }
414
+ get questionTypeEnum() {
415
+ return QuestionTypeEnum;
416
+ }
417
+ set setQuestion(value) {
418
+ this.surveyQuestion = value;
419
+ this.rForm.patchValue({
420
+ id: value.questionId,
421
+ name: value.questionName,
422
+ title: value.questionTitle,
423
+ typeId: value.questionTypeId,
424
+ description: value.questionDescription
425
+ });
426
+ value.surveyAnswers.forEach(surveryAnswer => {
427
+ this.fCtrls.answerArray.push(this._formBuilder.group({
428
+ id: [surveryAnswer.answerId],
429
+ title: [surveryAnswer.answerTitle],
430
+ isSelected: [false]
431
+ }));
432
+ });
433
+ if (value.isRequired == true) {
434
+ this.fCtrls.answer.addValidators([Validators.required]);
435
+ this.fCtrls.answer.updateValueAndValidity();
436
+ }
437
+ this.isShow = value.isVisable;
438
+ this.isDisabled = value.isReadOnly;
439
+ }
440
+ constructor(_formBuilder, _surveyLibService) {
441
+ this._formBuilder = _formBuilder;
442
+ this._surveyLibService = _surveyLibService;
443
+ this.elemId = v4();
444
+ this.emitter = new EventEmitter();
445
+ this.isShow = true;
446
+ this.isDisabled = false;
447
+ this.rForm = this._formBuilder.group({
448
+ id: [null],
449
+ name: [null],
450
+ title: [null],
451
+ typeId: [null],
452
+ description: [null],
453
+ answer: [null],
454
+ answerArray: this._formBuilder.array([])
455
+ });
456
+ }
457
+ ngOnInit() {
458
+ this.fCtrls.answer.valueChanges.pipe().pipe(debounceTime(200)).subscribe(value => {
459
+ const formValue = this.rForm.value;
460
+ this.emitter.emit({
461
+ QuestionId: formValue.id,
462
+ IsValid: this.fCtrls.answer.valid,
463
+ Answer: value
464
+ });
465
+ });
466
+ this.fCtrls.answer.setValue(null);
467
+ this._surveyLibService.surveyAnswersObsrv
468
+ .pipe(map(x => x.defaultAnswers.filter(x => x.QuestionId == this.fCtrls.id.value)))
469
+ .pipe(filter(x => x.length > 0)).pipe(map(x => x.at(0)))
470
+ .subscribe(answer => {
471
+ const distinctArray = answer.AnswerIdArr.filter((n, i) => answer.AnswerIdArr.indexOf(n) === i);
472
+ this.fCtrls.answer.setValue(distinctArray);
473
+ answer.AnswerIdArr.forEach(answerId => {
474
+ const groupIndex = this.fCtrls.answerArray.value.findIndex(x => x.id == answerId);
475
+ if (groupIndex > -1) {
476
+ this.fCtrls.answerArray.at(groupIndex).controls.isSelected.setValue(true);
477
+ }
478
+ });
479
+ });
480
+ }
481
+ onChangeAnswer(item, event) {
482
+ var answerArr = this.fCtrls.answer.value || [];
483
+ if (event.target.checked == true) {
484
+ answerArr.push(item.id);
485
+ }
486
+ else {
487
+ answerArr = answerArr.filter(x => x != item.id);
488
+ }
489
+ answerArr = answerArr.length == 0 ? [] : answerArr;
490
+ this.fCtrls.answer.setValue(answerArr);
491
+ }
492
+ convertToFormControl(element) {
493
+ return element;
494
+ }
495
+ 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 }); }
496
+ 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 fCtrls.answerArray.controls ;let i = index\">\n <input type=\"checkbox\" class=\"form-check-input\" id=\"{{elemId}}__checkbox_{{i}}\" [disabled]=\"isDisabled\"\n (change)=\"onChangeAnswer(item.value ,$event)\" [checked]=\"item.value.isSelected == true? true : null\">\n <label class=\"form-check-label \" for=\"{{elemId}}__checkbox_{{i}}\">{{item.value.title}}</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"] }] }); }
497
+ }
498
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionCheckBoxTemplateComponent, decorators: [{
499
+ type: Component,
500
+ 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 fCtrls.answerArray.controls ;let i = index\">\n <input type=\"checkbox\" class=\"form-check-input\" id=\"{{elemId}}__checkbox_{{i}}\" [disabled]=\"isDisabled\"\n (change)=\"onChangeAnswer(item.value ,$event)\" [checked]=\"item.value.isSelected == true? true : null\">\n <label class=\"form-check-label \" for=\"{{elemId}}__checkbox_{{i}}\">{{item.value.title}}</label>\n </div>\n </div>\n</div>\n" }]
501
+ }], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: SurveyLibService }]; }, propDecorators: { emitter: [{
502
+ type: Output
503
+ }], isShow: [{
504
+ type: Input
505
+ }], isDisabled: [{
506
+ type: Input
507
+ }], setQuestion: [{
508
+ type: Input
509
+ }] } });
510
+
511
+ class QuestionDropdownTemplateComponent {
512
+ get fCtrls() {
513
+ return this.rForm.controls;
514
+ }
515
+ get questionTypeEnum() {
516
+ return QuestionTypeEnum;
517
+ }
518
+ set setQuestion(value) {
519
+ this.surveyQuestion = value;
520
+ this.rForm.patchValue({
521
+ id: value.questionId,
522
+ name: value.questionName,
523
+ title: value.questionTitle,
524
+ typeId: value.questionTypeId,
525
+ description: value.questionDescription
526
+ });
527
+ if (value.isRequired == true) {
528
+ this.fCtrls.answer.addValidators([Validators.required]);
529
+ this.fCtrls.answer.updateValueAndValidity();
530
+ }
531
+ this.isShow = value.isVisable;
532
+ this.isDisabled = value.isReadOnly;
533
+ }
534
+ constructor(_formBuilder, _surveyLibService) {
535
+ this._formBuilder = _formBuilder;
536
+ this._surveyLibService = _surveyLibService;
537
+ this.emitter = new EventEmitter();
538
+ this.isShow = true;
539
+ this.isDisabled = false;
540
+ this.rForm = this._formBuilder.group({
541
+ id: [null],
542
+ name: [null],
543
+ title: [null],
544
+ typeId: [null],
545
+ description: [null],
546
+ answer: [null]
547
+ });
548
+ }
549
+ ngOnInit() {
550
+ this.fCtrls.answer.valueChanges.pipe().pipe(debounceTime(200)).subscribe(value => {
551
+ const formValue = this.rForm.value;
552
+ this.emitter.emit({
553
+ QuestionId: formValue.id,
554
+ IsValid: this.fCtrls.answer.valid,
555
+ Answer: value
556
+ });
557
+ });
558
+ this.fCtrls.answer.setValue(null);
559
+ this._surveyLibService.surveyAnswersObsrv
560
+ .pipe(map(x => x.defaultAnswers.filter(x => x.QuestionId == this.fCtrls.id.value)))
561
+ .pipe(filter(x => x.length > 0)).pipe(map(x => x.at(0)))
562
+ .subscribe(answer => {
563
+ this.fCtrls.answer.setValue(answer.AnswerId);
564
+ });
565
+ }
566
+ convertToFormControl(element) {
567
+ return element;
568
+ }
569
+ 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 }); }
570
+ 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"] }] }); }
571
+ }
572
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionDropdownTemplateComponent, decorators: [{
573
+ type: Component,
574
+ 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" }]
575
+ }], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: SurveyLibService }]; }, propDecorators: { emitter: [{
576
+ type: Output
577
+ }], isShow: [{
578
+ type: Input
579
+ }], isDisabled: [{
580
+ type: Input
581
+ }], setQuestion: [{
582
+ type: Input
583
+ }] } });
584
+
585
+ class QuestionMatrixTemplateComponent {
586
+ get fCtrls() {
587
+ return this.rForm.controls;
588
+ }
589
+ get questionTypeEnum() {
590
+ return QuestionTypeEnum;
591
+ }
592
+ set setQuestion(value) {
593
+ this.surveyQuestion = value;
594
+ this.rForm.patchValue({
595
+ id: value.questionId,
596
+ typeId: value.questionTypeId
597
+ });
598
+ value.surveySubQuestions.forEach(x => {
599
+ var group = this._formBuilder.group({
600
+ subQuestionId: [x.questionId],
601
+ questionTitle: [x.questionTitle],
602
+ answer: [null],
603
+ });
604
+ if (value.isRequired == true) {
605
+ group.controls.answer.addValidators([Validators.required]);
606
+ group.controls.answer.updateValueAndValidity();
607
+ }
608
+ group.controls.answer.valueChanges.pipe().pipe(debounceTime(200)).subscribe(value => {
609
+ const formValue = this.rForm.value;
610
+ this.emitter.emit({
611
+ QuestionId: group.value.subQuestionId,
612
+ Answer: group.value.answer,
613
+ IsValid: group.controls.answer.valid
614
+ });
615
+ });
616
+ this.fCtrls.subQuestionArray.push(group);
617
+ });
618
+ this.isShow = value.isVisable;
619
+ this.isDisabled = value.isReadOnly;
620
+ }
621
+ constructor(_formBuilder, _surveyLibService) {
622
+ this._formBuilder = _formBuilder;
623
+ this._surveyLibService = _surveyLibService;
624
+ this.elemId = v4();
625
+ this.emitter = new EventEmitter();
626
+ this.isShow = true;
627
+ this.isDisabled = false;
628
+ this.rForm = this._formBuilder.group({
629
+ id: [null],
630
+ typeId: [null],
631
+ subQuestionArray: this._formBuilder.array([])
632
+ });
633
+ }
634
+ ngOnInit() {
635
+ this._surveyLibService.surveyAnswersObsrv
636
+ .pipe(map(x => x.defaultAnswers.filter(x => x.ParentQuestionId == this.fCtrls.id.value)))
637
+ .pipe(filter(x => x.length > 0))
638
+ .subscribe(answers => {
639
+ this.fCtrls.subQuestionArray.controls.forEach(group => {
640
+ var answer = answers.find(x => x.QuestionId == group.value.subQuestionId);
641
+ if (answer != null) {
642
+ group.controls.answer.setValue(answer.AnswerId);
643
+ }
644
+ });
645
+ });
646
+ }
647
+ onChangeAnswer(question, answer) {
648
+ const index = this.fCtrls.subQuestionArray.value.findIndex(x => x.subQuestionId == question.subQuestionId);
649
+ var subQuestionGroup = this.fCtrls.subQuestionArray.controls[index];
650
+ subQuestionGroup.controls.answer.setValue(answer.answerId);
651
+ this.emitter.emit({
652
+ QuestionId: subQuestionGroup.value.subQuestionId,
653
+ Answer: subQuestionGroup.value.answer,
654
+ IsValid: subQuestionGroup.controls.answer.valid
655
+ });
656
+ }
657
+ convertToFormControl(element) {
658
+ return element;
659
+ }
660
+ 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 }); }
661
+ 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}}\" [checked]=\"answer.answerId == questionGroup.value.answer\">\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"] }] }); }
662
+ }
663
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionMatrixTemplateComponent, decorators: [{
664
+ type: Component,
665
+ 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}}\" [checked]=\"answer.answerId == questionGroup.value.answer\">\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>" }]
666
+ }], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: SurveyLibService }]; }, propDecorators: { emitter: [{
667
+ type: Output
668
+ }], isShow: [{
669
+ type: Input
670
+ }], isDisabled: [{
671
+ type: Input
672
+ }], setQuestion: [{
673
+ type: Input
674
+ }] } });
675
+
676
+ class QuestionBooleanTemplateComponent {
677
+ get fCtrls() {
678
+ return this.rForm.controls;
679
+ }
680
+ get questionTypeEnum() {
681
+ return QuestionTypeEnum;
682
+ }
683
+ set setQuestion(value) {
684
+ this.surveyQuestion = value;
685
+ this.rForm.patchValue({
686
+ id: value.questionId,
687
+ name: value.questionName,
688
+ title: value.questionTitle,
689
+ typeId: value.questionTypeId,
690
+ description: value.questionDescription
691
+ });
692
+ value.surveyAnswers.forEach(surveryAnswer => {
693
+ this.fCtrls.answerArray.push(this._formBuilder.group({
694
+ id: [surveryAnswer.answerId],
695
+ title: [surveryAnswer.answerTitle],
696
+ isSelected: [false]
697
+ }));
698
+ });
699
+ if (value.isRequired == true) {
700
+ this.fCtrls.answer.addValidators([Validators.required]);
701
+ this.fCtrls.answer.updateValueAndValidity();
702
+ }
703
+ this.isShow = value.isVisable;
704
+ this.isDisabled = value.isReadOnly;
705
+ }
706
+ constructor(_formBuilder, _surveyLibService) {
707
+ this._formBuilder = _formBuilder;
708
+ this._surveyLibService = _surveyLibService;
709
+ this.elemId = v4();
710
+ this.emitter = new EventEmitter();
711
+ this.isShow = true;
712
+ this.isDisabled = false;
713
+ this.rForm = this._formBuilder.group({
714
+ id: [null],
715
+ name: [null],
716
+ title: [null],
717
+ typeId: [null],
718
+ description: [null],
719
+ answer: [null],
720
+ answerArray: this._formBuilder.array([])
721
+ });
722
+ }
723
+ ngOnInit() {
724
+ this.fCtrls.answer.valueChanges.pipe().pipe(debounceTime(200)).subscribe(value => {
725
+ const formValue = this.rForm.value;
726
+ this.emitter.emit({
727
+ QuestionId: formValue.id,
728
+ IsValid: this.fCtrls.answer.valid,
729
+ Answer: value
730
+ });
731
+ });
732
+ this.fCtrls.answer.setValue(null);
733
+ this._surveyLibService.surveyAnswersObsrv
734
+ .pipe(map(x => x.defaultAnswers.filter(x => x.QuestionId == this.fCtrls.id.value)))
735
+ .pipe(filter(x => x.length > 0)).pipe(map(x => x.at(0)))
736
+ .subscribe(answer => {
737
+ this.fCtrls.answer.setValue(answer.AnswerId);
738
+ const groupIndex = this.fCtrls.answerArray.value.findIndex(x => x.id == answer.AnswerId);
739
+ if (groupIndex > -1) {
740
+ this.fCtrls.answerArray.at(groupIndex).controls.isSelected.setValue(true);
741
+ }
742
+ });
743
+ }
744
+ onChangeAnswer(item) {
745
+ this.fCtrls.answer.setValue(item.id);
746
+ }
747
+ convertToFormControl(element) {
748
+ return element;
749
+ }
750
+ 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 }); }
751
+ 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 fCtrls.answerArray.controls ;let i = index\">\n <input class=\"form-check-input\" type=\"radio\" (change)=\"onChangeAnswer(item.value)\" [disabled]=\"isDisabled\"\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}}\">{{item.value.title}}</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"] }] }); }
752
+ }
753
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionBooleanTemplateComponent, decorators: [{
754
+ type: Component,
755
+ 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 fCtrls.answerArray.controls ;let i = index\">\n <input class=\"form-check-input\" type=\"radio\" (change)=\"onChangeAnswer(item.value)\" [disabled]=\"isDisabled\"\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}}\">{{item.value.title}}</label>\n </div>\n </div>\n</div>\n" }]
756
+ }], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: SurveyLibService }]; }, propDecorators: { emitter: [{
757
+ type: Output
758
+ }], isShow: [{
759
+ type: Input
760
+ }], isDisabled: [{
761
+ type: Input
762
+ }], setQuestion: [{
763
+ type: Input
764
+ }] } });
765
+
766
+ class QuestionDropdownMultiTemplateComponent {
767
+ get fCtrls() {
768
+ return this.rForm.controls;
769
+ }
770
+ get questionTypeEnum() {
771
+ return QuestionTypeEnum;
772
+ }
773
+ set setQuestion(value) {
774
+ this.surveyQuestion = value;
775
+ this.rForm.patchValue({
776
+ id: value.questionId,
777
+ name: value.questionName,
778
+ title: value.questionTitle,
779
+ typeId: value.questionTypeId,
780
+ description: value.questionDescription
781
+ });
782
+ value.surveyAnswers.forEach(surveryAnswer => {
783
+ this.fCtrls.answerArray.push(this._formBuilder.group({
784
+ id: [surveryAnswer.answerId],
785
+ title: [surveryAnswer.answerTitle],
786
+ isSelected: [false]
787
+ }));
788
+ });
789
+ if (value.isRequired == true) {
790
+ this.fCtrls.answer.addValidators([Validators$1.required]);
791
+ this.fCtrls.answer.updateValueAndValidity();
792
+ }
793
+ this.isShow = value.isVisable;
794
+ this.isDisabled = value.isReadOnly;
795
+ }
796
+ constructor(_formBuilder, _surveyLibService) {
797
+ this._formBuilder = _formBuilder;
798
+ this._surveyLibService = _surveyLibService;
799
+ this.elemId = v4();
800
+ this.emitter = new EventEmitter();
801
+ this.isShow = true;
802
+ this.isDisabled = false;
803
+ this.rForm = this._formBuilder.group({
804
+ id: [null],
805
+ name: [null],
806
+ title: [null],
807
+ typeId: [null],
808
+ description: [null],
809
+ answer: [null],
810
+ answerArray: this._formBuilder.array([])
811
+ });
812
+ }
813
+ ngOnInit() {
814
+ this.fCtrls.answer.valueChanges.pipe().pipe(debounceTime(200)).subscribe(value => {
815
+ const formValue = this.rForm.value;
816
+ this.emitter.emit({
817
+ QuestionId: formValue.id,
818
+ IsValid: this.fCtrls.answer.valid,
819
+ Answer: value
820
+ });
821
+ });
822
+ this.fCtrls.answer.setValue(null);
823
+ this._surveyLibService.surveyAnswersObsrv
824
+ .pipe(map(x => x.defaultAnswers.filter(x => x.QuestionId == this.fCtrls.id.value)))
825
+ .pipe(filter(x => x.length > 0)).pipe(map(x => x.at(0)))
826
+ .subscribe(answer => {
827
+ const distinctArray = answer.AnswerIdArr.filter((n, i) => answer.AnswerIdArr.indexOf(n) === i);
828
+ this.fCtrls.answer.setValue(distinctArray);
829
+ });
830
+ }
831
+ convertToFormControl(element) {
832
+ return element;
833
+ }
834
+ 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 }); }
835
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", type: QuestionDropdownMultiTemplateComponent, selector: "lib-question-dropdown-multi-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 <ng-select [items]=\"this.fCtrls.answerArray.value\" bindValue=\"id\" bindLabel=\"title\" class=\"form-control\"\n [formControl]=\"convertToFormControl(fCtrls.answer)\" [disabled]=\"isDisabled\" [multiple]=\"true\">\n </ng-select>\n </div>\n</div>\n", styles: [".text-quastion .form-control{padding:10px}\n"], dependencies: [{ kind: "directive", type: i3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i4.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i4.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: i5.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"] }] }); }
836
+ }
837
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionDropdownMultiTemplateComponent, decorators: [{
838
+ type: Component,
839
+ 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':isShow != true}\">\n <h3 class=\"quastion-title \">\n {{fCtrls.title.value}}\n </h3>\n <div class=\"text-quastion\">\n <ng-select [items]=\"this.fCtrls.answerArray.value\" bindValue=\"id\" bindLabel=\"title\" class=\"form-control\"\n [formControl]=\"convertToFormControl(fCtrls.answer)\" [disabled]=\"isDisabled\" [multiple]=\"true\">\n </ng-select>\n </div>\n</div>\n", styles: [".text-quastion .form-control{padding:10px}\n"] }]
840
+ }], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: SurveyLibService }]; }, propDecorators: { emitter: [{
841
+ type: Output
842
+ }], isShow: [{
843
+ type: Input
844
+ }], isDisabled: [{
845
+ type: Input
846
+ }], setQuestion: [{
847
+ type: Input
848
+ }] } });
849
+
850
+ class FilterQuestionPipe {
851
+ transform(value, questionArr) {
852
+ return questionArr.find(x => x.questionId == value.questionId);
853
+ }
854
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: FilterQuestionPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
855
+ static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "16.1.7", ngImport: i0, type: FilterQuestionPipe, name: "filterQuestion" }); }
856
+ }
857
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: FilterQuestionPipe, decorators: [{
858
+ type: Pipe,
859
+ args: [{
860
+ name: 'filterQuestion'
861
+ }]
862
+ }] });
863
+
864
+ class SurveryLibComponent {
865
+ get fCtrls() {
866
+ return this.rForm.controls;
867
+ }
868
+ get questionTypeEnum() {
869
+ return QuestionTypeEnum;
870
+ }
871
+ get isFirstPage() {
872
+ return this.fCtrls.currentPageIndex.value == 0;
873
+ }
874
+ get isLastPage() {
875
+ return this.fCtrls.currentPageIndex.value == (this.surveyData?.surveyPages.length - 1);
876
+ }
877
+ get showedSurveyPages() {
878
+ var pageArr = [];
879
+ for (let index = 0; index < this.fCtrls.questionArray.value.length; index++) {
880
+ const question = this.fCtrls.questionArray.value[index];
881
+ if (question.isShow == true && (question.questionType != this.questionTypeEnum.Matrix || question.isMatrixGroup == true)) {
882
+ if (question.surveyPageIndex == 1) {
883
+ console.log(question);
884
+ }
885
+ pageArr.push(question.surveyPageIndex);
886
+ }
887
+ }
888
+ const distinctArray = pageArr.filter((n, i) => pageArr.indexOf(n) === i);
889
+ return distinctArray.sort((a, b) => a - b);
890
+ }
891
+ get curruntShowedSurveyPages() {
892
+ return this.showedSurveyPages.findIndex(x => x == this.fCtrls.currentPageIndex.value) + 1;
893
+ }
894
+ get surveyResult() {
895
+ return {
896
+ currentPageIndex: this.fCtrls.currentPageIndex.value,
897
+ answers: this.fCtrls.questionArray.value.filter(x => x.isMatrixGroup != true).map(x => {
898
+ return {
899
+ SurveyPageIndex: x.surveyPageIndex,
900
+ QuestionId: x.questionId,
901
+ QuestionType: x.questionType,
902
+ AnswerId: x.answerId,
903
+ AnswerText: x.answerText,
904
+ AnswerIdArr: x.answerIdArr
905
+ };
906
+ })
907
+ };
908
+ }
909
+ constructor(_surveyLibService, _formBuilder, _checkRuleExpsUsecase) {
910
+ this._surveyLibService = _surveyLibService;
911
+ this._formBuilder = _formBuilder;
912
+ this._checkRuleExpsUsecase = _checkRuleExpsUsecase;
913
+ this.reloadDefaultAnswerId = v4();
914
+ this.surveyResultEmit = new EventEmitter();
915
+ this.rForm = this._formBuilder.group({
916
+ currentPageIndex: [0],
917
+ questionArray: this._formBuilder.array([]),
918
+ ruleQuestionArray: this._formBuilder.array([])
919
+ });
920
+ }
921
+ ngOnInit() {
922
+ this._surveyLibService.surveyDataObsrv.subscribe(survey => {
923
+ this.fCtrls.questionArray.clear();
924
+ this.fCtrls.ruleQuestionArray.clear();
925
+ this.surveyData = null;
926
+ if (survey != null) {
927
+ this.surveyData = survey;
928
+ this.loadQuestions(survey);
929
+ }
930
+ });
931
+ this._surveyLibService.surveyAnswersObsrv.subscribe(value => {
932
+ this.defaultAnswers = [];
933
+ if (value != null) {
934
+ this.defaultAnswers = [...value.defaultAnswers];
935
+ this.fCtrls.currentPageIndex.setValue(value.currentpage);
936
+ }
937
+ this.reloadDefaultAnswerId = v4();
938
+ });
939
+ }
940
+ onPaggingNext() {
941
+ var isHaveInvalidRecords = this.haveInValidateQuestions();
942
+ if (isHaveInvalidRecords == false) {
943
+ const nextPageIndex = this.getNextShowedPage();
944
+ if (nextPageIndex != null) {
945
+ this.fCtrls.currentPageIndex.setValue(nextPageIndex);
946
+ }
947
+ else {
948
+ var questionArr = this.fCtrls.questionArray.value.filter(x => x.isMatrixGroup != true).map(x => {
949
+ return {
950
+ SurveyPageIndex: x.surveyPageIndex,
951
+ QuestionId: x.questionId,
952
+ QuestionType: x.questionType,
953
+ AnswerId: x.answerId,
954
+ AnswerText: x.answerText,
955
+ AnswerIdArr: x.answerIdArr
956
+ };
957
+ });
958
+ this.surveyResultEmit.emit(questionArr);
959
+ }
960
+ }
961
+ }
962
+ onPaggingChange(index) {
963
+ const formValue = this.rForm.value;
964
+ if (index < formValue.currentPageIndex) {
965
+ this.fCtrls.currentPageIndex.setValue(index);
966
+ }
967
+ else if (index == (formValue.currentPageIndex + 1)) {
968
+ this.onPaggingNext();
969
+ }
970
+ }
971
+ onPaggingBack() {
972
+ const prevPageIndex = this.getPrevShowedPage();
973
+ if (prevPageIndex != null) {
974
+ this.fCtrls.currentPageIndex.setValue(prevPageIndex);
975
+ }
976
+ }
977
+ onUpdateAnswers(model) {
978
+ model.forEach(elem => {
979
+ this.onUpdateAnswer(elem);
980
+ });
981
+ }
982
+ onUpdateAnswer(model) {
983
+ const index = this.fCtrls.questionArray.value.findIndex(x => x.questionId == model.QuestionId);
984
+ var questionGroup = this.fCtrls.questionArray.controls[index];
985
+ questionGroup.controls.isValid.setValue(model.IsValid);
986
+ if (questionGroup.value.questionType == this.questionTypeEnum.TextInput) {
987
+ questionGroup.patchValue({
988
+ answerId: model.SurveyAnswerId,
989
+ answerText: model.Answer
990
+ });
991
+ }
992
+ else if (questionGroup.value.questionType == this.questionTypeEnum.CheckBox || questionGroup.value.questionType == this.questionTypeEnum.DropDownMulti) {
993
+ questionGroup.controls.answerIdArr.setValue(model.Answer);
994
+ }
995
+ else {
996
+ questionGroup.controls.answerId.setValue(model.Answer);
997
+ }
998
+ if (this.fCtrls.ruleQuestionArray.value.findIndex(x => x.questionId == model.QuestionId) > -1) {
999
+ this.checkRules();
1000
+ }
1001
+ }
1002
+ loadQuestions(survey) {
1003
+ survey.surveyPages.forEach((page, pageIndex) => {
1004
+ page.surveyQuestionGroups.forEach(group => {
1005
+ group.surveyQuestions.forEach(question => {
1006
+ if (question.questionTypeId != 6) {
1007
+ this.fCtrls.questionArray.push(this._formBuilder.group({
1008
+ surveyPageIndex: pageIndex,
1009
+ questionId: [question.questionId],
1010
+ questionType: [question.questionTypeId],
1011
+ isMatrixGroup: [false],
1012
+ answerId: [null],
1013
+ answerIdArr: [null],
1014
+ answerText: [null],
1015
+ isRequired: [question.isRequired],
1016
+ isValid: [null],
1017
+ isDisabled: [question.isReadOnly],
1018
+ isShow: [question.isVisable],
1019
+ isDisabled_default: [question.isReadOnly],
1020
+ isShow_default: [question.isVisable]
1021
+ }));
1022
+ }
1023
+ else {
1024
+ this.fCtrls.questionArray.push(this._formBuilder.group({
1025
+ surveyPageIndex: pageIndex,
1026
+ questionId: [question.questionId],
1027
+ questionType: [question.questionTypeId],
1028
+ isMatrixGroup: [true],
1029
+ answerId: [null],
1030
+ answerIdArr: [null],
1031
+ answerText: [null],
1032
+ isRequired: [question.isRequired],
1033
+ isValid: [null],
1034
+ isDisabled: [question.isReadOnly],
1035
+ isShow: [question.isVisable],
1036
+ isDisabled_default: [question.isReadOnly],
1037
+ isShow_default: [question.isVisable],
1038
+ }));
1039
+ question.surveySubQuestions.forEach(subQuestion => {
1040
+ this.fCtrls.questionArray.push(this._formBuilder.group({
1041
+ surveyPageIndex: pageIndex,
1042
+ questionId: [subQuestion.questionId],
1043
+ questionType: [subQuestion.questionTypeId],
1044
+ isMatrixGroup: [false],
1045
+ answerId: [null],
1046
+ answerIdArr: [null],
1047
+ answerText: [null],
1048
+ isRequired: [question.isRequired],
1049
+ isValid: [null],
1050
+ isDisabled: [subQuestion.isReadOnly],
1051
+ isShow: [subQuestion.isVisable],
1052
+ isDisabled_default: [subQuestion.isReadOnly],
1053
+ isShow_default: [subQuestion.isVisable]
1054
+ }));
1055
+ });
1056
+ }
1057
+ });
1058
+ });
1059
+ });
1060
+ survey.surveyRules.forEach(rule => {
1061
+ rule.ruleExps.forEach(ruleExp => {
1062
+ this.fCtrls.ruleQuestionArray.push(this._formBuilder.group({
1063
+ questionId: ruleExp.questionId
1064
+ }));
1065
+ });
1066
+ });
1067
+ }
1068
+ haveInValidateQuestions() {
1069
+ const currentPageIndex = this.fCtrls.currentPageIndex.value;
1070
+ var invalidRecords = this.fCtrls.questionArray.value.filter(x => x.surveyPageIndex == currentPageIndex
1071
+ && x.isRequired == true && x.isValid != true
1072
+ && x.isDisabled == false && x.isShow == true && x.isMatrixGroup != true);
1073
+ if (invalidRecords.length > 0) {
1074
+ $(`#survey-page_${currentPageIndex}`).addClass('survey-page_submitted');
1075
+ }
1076
+ if (invalidRecords.length > 0) {
1077
+ console.log(invalidRecords);
1078
+ }
1079
+ return invalidRecords.length > 0;
1080
+ }
1081
+ checkRules() {
1082
+ this.surveyData.surveyRules.forEach(rule => {
1083
+ this._checkRuleExpsUsecase.execute({
1084
+ ruleExps: rule.ruleExps,
1085
+ questions: this.fCtrls.questionArray.value
1086
+ }).subscribe(result => {
1087
+ var isPassed = result.exprestionResultArr.filter(x => x == false).length == 0;
1088
+ if (isPassed) {
1089
+ rule.ruleResultQuestions.forEach(resultQuestion => {
1090
+ const index = this.fCtrls.questionArray.value.findIndex(x => x.questionId == resultQuestion.questionId);
1091
+ var questionGroup = this.fCtrls.questionArray.at(index);
1092
+ if (rule.logicActionId == LogicActionEnum.Show) {
1093
+ questionGroup.controls.isShow.setValue(true);
1094
+ }
1095
+ else if (rule.logicActionId == LogicActionEnum.Hide) {
1096
+ questionGroup.controls.isShow.setValue(false);
1097
+ }
1098
+ else if (rule.logicActionId == LogicActionEnum.Enable) {
1099
+ questionGroup.controls.isDisabled.setValue(false);
1100
+ }
1101
+ else if (rule.logicActionId == LogicActionEnum.Disable) {
1102
+ questionGroup.controls.isDisabled.setValue(true);
1103
+ }
1104
+ else if (rule.logicActionId == LogicActionEnum.SetAnswer) {
1105
+ }
1106
+ });
1107
+ }
1108
+ else {
1109
+ rule.ruleResultQuestions.forEach(resultQuestion => {
1110
+ const index = this.fCtrls.questionArray.value.findIndex(x => x.questionId == resultQuestion.questionId);
1111
+ var questionGroup = this.fCtrls.questionArray.at(index);
1112
+ questionGroup.patchValue({
1113
+ isShow: questionGroup.value.isShow_default,
1114
+ isDisabled: questionGroup.value.isDisabled_default
1115
+ });
1116
+ });
1117
+ }
1118
+ });
1119
+ });
1120
+ }
1121
+ getNextShowedPage() {
1122
+ var currentPageIndex = this.fCtrls.currentPageIndex.value;
1123
+ var showedPages = this.showedSurveyPages;
1124
+ var nextShowedPages = showedPages.filter(x => x > currentPageIndex);
1125
+ if (nextShowedPages.length > 0) {
1126
+ return nextShowedPages[0];
1127
+ }
1128
+ return null;
1129
+ }
1130
+ getPrevShowedPage() {
1131
+ var currentPageIndex = this.fCtrls.currentPageIndex.value;
1132
+ var showedPages = this.showedSurveyPages;
1133
+ var prevShowedPages = showedPages.filter(x => x < currentPageIndex);
1134
+ if (prevShowedPages.length > 0) {
1135
+ return prevShowedPages[prevShowedPages.length - 1];
1136
+ }
1137
+ return null;
1138
+ }
1139
+ 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 }); }
1140
+ 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\" *ngIf=\"surveyData != null\">\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 #questionBooleanTemplate [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 #questionTextTemplate [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 #questionRadioButtonTemplate [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 #questionDropdownTemplate [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-dropdown-multi-template [setQuestion]=\"question\" (emitter)=\"onUpdateAnswer($event)\"\r\n *ngIf=\"question.questionTypeId == questionTypeEnum.DropDownMulti\"\r\n [isShow]=\" (question|filterQuestion : fCtrls.questionArray.value).isShow\"\r\n [isDisabled]=\"(question|filterQuestion : fCtrls.questionArray.value).isDisabled\"></lib-question-dropdown-multi-template>\r\n \r\n <lib-question-check-box-template #questionCheckBoxTemplate [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 #questionMatrixTemplate [setQuestion]=\"question\" (emitter)=\"onUpdateAnswer($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 fw-bold\" >\r\n <span>{{curruntShowedSurveyPages}}</span>\r\n <span class=\"ms-2 me-2\">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}\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: "component", type: QuestionDropdownMultiTemplateComponent, selector: "lib-question-dropdown-multi-template", inputs: ["isShow", "isDisabled", "setQuestion"], outputs: ["emitter"] }, { kind: "pipe", type: FilterQuestionPipe, name: "filterQuestion" }] }); }
1141
+ }
1142
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: SurveryLibComponent, decorators: [{
1143
+ type: Component,
1144
+ args: [{ selector: 'lib-survery-lib', template: "<div class=\"survay-card\" *ngIf=\"surveyData != null\">\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 #questionBooleanTemplate [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 #questionTextTemplate [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 #questionRadioButtonTemplate [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 #questionDropdownTemplate [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-dropdown-multi-template [setQuestion]=\"question\" (emitter)=\"onUpdateAnswer($event)\"\r\n *ngIf=\"question.questionTypeId == questionTypeEnum.DropDownMulti\"\r\n [isShow]=\" (question|filterQuestion : fCtrls.questionArray.value).isShow\"\r\n [isDisabled]=\"(question|filterQuestion : fCtrls.questionArray.value).isDisabled\"></lib-question-dropdown-multi-template>\r\n \r\n <lib-question-check-box-template #questionCheckBoxTemplate [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 #questionMatrixTemplate [setQuestion]=\"question\" (emitter)=\"onUpdateAnswer($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 fw-bold\" >\r\n <span>{{curruntShowedSurveyPages}}</span>\r\n <span class=\"ms-2 me-2\">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}\n"] }]
1145
+ }], ctorParameters: function () { return [{ type: SurveyLibService }, { type: i1.FormBuilder }, { type: CheckRuleExpsUsecase }]; }, propDecorators: { surveyResultEmit: [{
1146
+ type: Output
1147
+ }] } });
1148
+
1149
+ class DefaultQuestionAnswerPipe {
1150
+ transform(value, questionId, reloadId) {
1151
+ if (value != null) {
1152
+ return value.find(x => x.QuestionId == questionId);
1153
+ }
1154
+ return null;
1155
+ }
1156
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: DefaultQuestionAnswerPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
1157
+ static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "16.1.7", ngImport: i0, type: DefaultQuestionAnswerPipe, name: "defaultQuestionAnswer" }); }
1158
+ }
1159
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: DefaultQuestionAnswerPipe, decorators: [{
1160
+ type: Pipe,
1161
+ args: [{
1162
+ name: 'defaultQuestionAnswer'
1163
+ }]
1164
+ }] });
1165
+
1166
+ class DefaultQuestionAnswersPipe {
1167
+ transform(value, questionId, reloadId) {
1168
+ if (value != null) {
1169
+ return value.filter(x => x.ParentQuestionId == questionId);
1170
+ }
1171
+ return [];
1172
+ }
1173
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: DefaultQuestionAnswersPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
1174
+ static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "16.1.7", ngImport: i0, type: DefaultQuestionAnswersPipe, name: "defaultQuestionAnswers" }); }
1175
+ }
1176
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: DefaultQuestionAnswersPipe, decorators: [{
1177
+ type: Pipe,
1178
+ args: [{
1179
+ name: 'defaultQuestionAnswers'
1180
+ }]
1181
+ }] });
1182
+
1183
+ class SurveryLibModule {
1184
+ static forRoot() {
1185
+ return {
1186
+ ngModule: SurveryLibModule
1187
+ };
1188
+ }
1189
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: SurveryLibModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
1190
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.1.7", ngImport: i0, type: SurveryLibModule, declarations: [SurveryLibComponent,
1191
+ QuestionTextTemplateComponent,
1192
+ QuestionRadioButtonTemplateComponent,
1193
+ QuestionCheckBoxTemplateComponent,
1194
+ QuestionDropdownTemplateComponent,
1195
+ QuestionMatrixTemplateComponent,
1196
+ QuestionBooleanTemplateComponent,
1197
+ QuestionDropdownMultiTemplateComponent,
1198
+ FilterQuestionPipe,
1199
+ DefaultQuestionAnswerPipe,
1200
+ DefaultQuestionAnswersPipe], imports: [CommonModule, HttpClientModule, ReactiveFormsModule, FormsModule, NgsFormsModule, NgSelectModule], exports: [SurveryLibComponent] }); }
1201
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: SurveryLibModule, imports: [CommonModule, HttpClientModule, ReactiveFormsModule, FormsModule, NgsFormsModule, NgSelectModule] }); }
1202
+ }
1203
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: SurveryLibModule, decorators: [{
1204
+ type: NgModule,
1205
+ args: [{
1206
+ declarations: [
1207
+ SurveryLibComponent,
1208
+ QuestionTextTemplateComponent,
1209
+ QuestionRadioButtonTemplateComponent,
1210
+ QuestionCheckBoxTemplateComponent,
1211
+ QuestionDropdownTemplateComponent,
1212
+ QuestionMatrixTemplateComponent,
1213
+ QuestionBooleanTemplateComponent,
1214
+ QuestionDropdownMultiTemplateComponent,
1215
+ FilterQuestionPipe,
1216
+ DefaultQuestionAnswerPipe,
1217
+ DefaultQuestionAnswersPipe
1218
+ ],
1219
+ imports: [
1220
+ CommonModule, HttpClientModule, ReactiveFormsModule, FormsModule, NgsFormsModule, NgSelectModule
1221
+ ],
1222
+ exports: [
1223
+ SurveryLibComponent
1224
+ ]
1225
+ }]
1226
+ }] });
1227
+
1228
+ class SurveyQuestionResult {
1229
+ }
1230
+
1231
+ /*
1232
+ * Public API Surface of survery-lib
1233
+ */
1234
+
1235
+ /**
1236
+ * Generated bundle index. Do not edit.
1237
+ */
1238
+
1239
+ export { SurveryLibComponent, SurveryLibModule, SurveyLibService, SurveyQuestionResult };
1240
+ //# sourceMappingURL=survery-lib.mjs.map