survery-lib 0.1.9 → 0.1.11

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