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
@@ -0,0 +1,111 @@
1
+ import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
2
+ import { FormControl, Validators } from '@angular/forms';
3
+ import { FormBuilder, FormGroup } from '@ng-stack/forms';
4
+ import { SurveyAnswerDto } from '../../../shared/dtos/survey-answer.dto';
5
+ import { SurveyQuestionDto } from '../../../shared/dtos/survey-question.dto';
6
+ import { QuestionTypeEnum } from '../../../shared/enums/question-type.enum';
7
+ import {
8
+ AnswerChildOfQuestionRadioButtonTemplateFormInterface,
9
+ QuestionRadioButtonTemplateFormInterface
10
+ } from '../../../shared/form-interfaces/question-radio-button-template.form-interface';
11
+ import { QuestionTextTemplateFormInterface } from '../../../shared/form-interfaces/question-text-template.form-interface';
12
+ import { debounceTime, distinctUntilChanged, filter, map } from 'rxjs';
13
+ import { v4 as guidGenerator } from 'uuid';
14
+ import { QuestionAnswerModel } from '../../../shared/models/question-answer.model';
15
+ import { DefaultQuestionAnswerDto } from '../../../shared/dtos/default-question-answers.dto';
16
+ import { SurveyLibService } from '../../services/survey-lib.service';
17
+
18
+ @Component({
19
+ selector: 'lib-question-radio-button-template',
20
+ templateUrl: './question-radio-button-template.component.html',
21
+ styleUrls: ['./question-radio-button-template.component.scss']
22
+ })
23
+ export class QuestionRadioButtonTemplateComponent implements OnInit {
24
+ elemId = guidGenerator() as string;
25
+ surveyQuestion: SurveyQuestionDto;
26
+ rForm: FormGroup<QuestionRadioButtonTemplateFormInterface>;
27
+
28
+ get fCtrls() {
29
+ return this.rForm.controls;
30
+ }
31
+
32
+ get questionTypeEnum() {
33
+ return QuestionTypeEnum;
34
+ }
35
+
36
+ @Output() emitter = new EventEmitter<QuestionAnswerModel>();
37
+
38
+ @Input() isShow: boolean = true;
39
+ @Input() isDisabled: boolean = false;
40
+ @Input() set setQuestion(value: SurveyQuestionDto) {
41
+ this.surveyQuestion = value;
42
+ this.rForm.patchValue({
43
+ id: value.questionId,
44
+ name: value.questionName,
45
+ title: value.questionTitle,
46
+ typeId: value.questionTypeId,
47
+ description: value.questionDescription
48
+ });
49
+
50
+ value.surveyAnswers.forEach(surveryAnswer => {
51
+ this.fCtrls.answerArray.push(this._formBuilder.group<AnswerChildOfQuestionRadioButtonTemplateFormInterface>({
52
+ id: [surveryAnswer.answerId],
53
+ title: [surveryAnswer.answerTitle],
54
+ isSelected: [false]
55
+ }))
56
+ })
57
+
58
+ if (value.isRequired == true) {
59
+ this.fCtrls.answer.addValidators([Validators.required]);
60
+ this.fCtrls.answer.updateValueAndValidity();
61
+ }
62
+
63
+ this.isShow = value.isVisable;
64
+ this.isDisabled = value.isReadOnly;
65
+ }
66
+
67
+ constructor(private _formBuilder: FormBuilder, private _surveyLibService: SurveyLibService) {
68
+ this.rForm = this._formBuilder.group<QuestionRadioButtonTemplateFormInterface>({
69
+ id: [null],
70
+ name: [null],
71
+ title: [null],
72
+ typeId: [null],
73
+ description: [null],
74
+ answer: [null],
75
+ answerArray: this._formBuilder.array<AnswerChildOfQuestionRadioButtonTemplateFormInterface>([])
76
+ });
77
+ }
78
+
79
+ ngOnInit(): void {
80
+ this.fCtrls.answer.valueChanges.pipe().pipe(debounceTime(200)).subscribe(value => {
81
+ console.log(value);
82
+ const formValue = this.rForm.value;
83
+ this.emitter.emit({
84
+ QuestionId: formValue.id,
85
+ IsValid: this.fCtrls.answer.valid,
86
+ Answer: value
87
+ })
88
+ });
89
+
90
+ this.fCtrls.answer.setValue(null);
91
+
92
+ this._surveyLibService.surveyAnswersObsrv.pipe(map(x => x.defaultAnswers.filter(x => x.QuestionId == this.fCtrls.id.value)))
93
+ .pipe(filter(x => x.length > 0)).pipe(map(x => x.at(0)))
94
+ .subscribe(answer => {
95
+ this.fCtrls.answer.setValue(answer.AnswerId);
96
+
97
+ const groupIndex = this.fCtrls.answerArray.value.findIndex(x => x.id == answer.AnswerId);
98
+ if (groupIndex > -1) {
99
+ this.fCtrls.answerArray.at(groupIndex).controls.isSelected.setValue(true);
100
+ }
101
+ });
102
+ }
103
+
104
+ onChangeAnswer(item: AnswerChildOfQuestionRadioButtonTemplateFormInterface) {
105
+ this.fCtrls.answer.setValue(item.id);
106
+ }
107
+
108
+ convertToFormControl(element: any) {
109
+ return element as FormControl;
110
+ }
111
+ }
@@ -0,0 +1,13 @@
1
+ <div class="quastion" [formGroup]="rForm" [attr.id]="'question_'+fCtrls.id.value"
2
+ [ngClass]="{'invalid-question': fCtrls.answer.invalid , 'd-none':isShow != true}">
3
+ <h3 class="quastion-title ">
4
+ {{fCtrls.title.value}}
5
+ </h3>
6
+ <div class="text-quastion">
7
+ <input class="form-control" type="text" [formControl]="convertToFormControl(fCtrls.answer)"
8
+ [disabled]="isDisabled" *ngIf="isTextArea == false else textAreaTemplate">
9
+ <ng-template #textAreaTemplate>
10
+ <textarea class="form-control" rows="5" [formControl]="convertToFormControl(fCtrls.answer)"
11
+ [disabled]="isDisabled" ></textarea>
12
+ </ng-template>
13
+ </div>
@@ -0,0 +1,21 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { QuestionTextTemplateComponent } from './question-text-template.component';
4
+
5
+ describe('QuestionTextTemplateComponent', () => {
6
+ let component: QuestionTextTemplateComponent;
7
+ let fixture: ComponentFixture<QuestionTextTemplateComponent>;
8
+
9
+ beforeEach(() => {
10
+ TestBed.configureTestingModule({
11
+ declarations: [QuestionTextTemplateComponent]
12
+ });
13
+ fixture = TestBed.createComponent(QuestionTextTemplateComponent);
14
+ component = fixture.componentInstance;
15
+ fixture.detectChanges();
16
+ });
17
+
18
+ it('should create', () => {
19
+ expect(component).toBeTruthy();
20
+ });
21
+ });
@@ -0,0 +1,105 @@
1
+ import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
2
+ import { FormControl, Validators } from '@angular/forms';
3
+ import { FormBuilder, FormGroup, FormControl as FormControlStack, ValidatorsModel } from '@ng-stack/forms';
4
+ import { SurveyQuestionDto } from '../../../shared/dtos/survey-question.dto';
5
+ import { QuestionTypeEnum } from '../../../shared/enums/question-type.enum';
6
+ import { QuestionTextTemplateFormInterface } from '../../../shared/form-interfaces/question-text-template.form-interface';
7
+ import { debounceTime, distinctUntilChanged, filter, map } from 'rxjs';
8
+ import { QuestionAnswerModel } from '../../../shared/models/question-answer.model';
9
+ import { DefaultQuestionAnswerDto } from '../../../shared/dtos/default-question-answers.dto';
10
+ import { SurveyLibService } from '../../services/survey-lib.service';
11
+
12
+ @Component({
13
+ selector: 'lib-question-text-template',
14
+ templateUrl: './question-text-template.component.html',
15
+ styleUrls: ['./question-text-template.component.scss']
16
+ })
17
+ export class QuestionTextTemplateComponent implements OnInit {
18
+
19
+ rForm: FormGroup<QuestionTextTemplateFormInterface>;
20
+
21
+ get fCtrls() {
22
+ return this.rForm.controls;
23
+ }
24
+
25
+ get questionTypeEnum() {
26
+ return QuestionTypeEnum;
27
+ }
28
+
29
+ @Output() emitter = new EventEmitter<QuestionAnswerModel>();
30
+
31
+ @Input() isShow: boolean = true;
32
+ @Input() isTextArea: boolean;
33
+ @Input() set setQuestion(value: SurveyQuestionDto) {
34
+ this.rForm.patchValue({
35
+ id: value.questionId,
36
+ name: value.questionName,
37
+ title: value.questionTitle,
38
+ typeId: value.questionTypeId,
39
+ description: value.questionDescription
40
+ });
41
+
42
+ if (value.surveyAnswers[0]?.answerId != null && value.surveyAnswers[0]?.answerId != undefined) {
43
+ this.fCtrls.surveyAnswerId.setValue(value.surveyAnswers[0].answerId);
44
+ }
45
+
46
+ if (value.isRequired == true) {
47
+ this.fCtrls.answer.addValidators([Validators.required]);
48
+ this.fCtrls.answer.updateValueAndValidity();
49
+ }
50
+
51
+ this.isShow = value.isVisable;
52
+ this.toggleEnableAnswer(value.isReadOnly);
53
+ }
54
+
55
+ @Input() set isDisabled(value: boolean) {
56
+ this.toggleEnableAnswer(value);
57
+ }
58
+
59
+
60
+ constructor(private _formBuilder: FormBuilder , private _surveyLibService:SurveyLibService) {
61
+ this.rForm = this._formBuilder.group<QuestionTextTemplateFormInterface>({
62
+ id: [null],
63
+ name: [null],
64
+ title: [null],
65
+ typeId: [null],
66
+ description: [null],
67
+ surveyAnswerId: [null],
68
+ answer: [null]
69
+ });
70
+ }
71
+
72
+ ngOnInit(): void {
73
+ this.fCtrls.answer.valueChanges.pipe().pipe(debounceTime(200)).subscribe(value => {
74
+ const formValue = this.rForm.value;
75
+ this.emitter.emit({
76
+ QuestionId: formValue.id,
77
+ IsValid: this.fCtrls.answer.valid,
78
+ Answer: value,
79
+ SurveyAnswerId: formValue.surveyAnswerId
80
+ })
81
+ });
82
+
83
+ this.fCtrls.answer.setValue(null);
84
+
85
+ this._surveyLibService.surveyAnswersObsrv.pipe(map(x=> x.defaultAnswers.filter(x=>x.QuestionId == this.fCtrls.id.value)))
86
+ .pipe(filter(x=>x.length > 0)).pipe(map(x=> x.at(0)))
87
+ .subscribe(answer=>{
88
+ this.fCtrls.answer.setValue(answer.AnswerText);
89
+ });
90
+ }
91
+
92
+ convertToFormControl(element: any) {
93
+ return element as FormControl;
94
+ }
95
+
96
+ private toggleEnableAnswer(isReadOnly: boolean) {
97
+ if (isReadOnly == true) {
98
+ this.fCtrls.answer.disable()
99
+ } else {
100
+ this.fCtrls.answer.enable()
101
+ }
102
+ this.fCtrls.answer.updateValueAndValidity();
103
+ }
104
+
105
+ }
@@ -0,0 +1,8 @@
1
+ import { DefaultQuestionAnswerPipe } from './default-question-answer.pipe';
2
+
3
+ describe('DefaultQuestionAnswerPipe', () => {
4
+ it('create an instance', () => {
5
+ const pipe = new DefaultQuestionAnswerPipe();
6
+ expect(pipe).toBeTruthy();
7
+ });
8
+ });
@@ -0,0 +1,18 @@
1
+ import { Pipe, PipeTransform } from '@angular/core';
2
+ import { DefaultQuestionAnswerDto } from '../../shared/dtos/default-question-answers.dto';
3
+ import { QuestionTypeEnum } from '../../shared/enums/question-type.enum';
4
+
5
+ @Pipe({
6
+ name: 'defaultQuestionAnswer'
7
+ })
8
+ export class DefaultQuestionAnswerPipe implements PipeTransform {
9
+
10
+ transform(value: DefaultQuestionAnswerDto[], questionId: number , reloadId): DefaultQuestionAnswerDto {
11
+ if (value != null) {
12
+ return value.find(x => x.QuestionId == questionId);
13
+ }
14
+
15
+ return null;
16
+ }
17
+
18
+ }
@@ -0,0 +1,8 @@
1
+ import { DefaultQuestionAnswersPipe } from './default-question-answers.pipe';
2
+
3
+ describe('DefaultQuestionAnswersPipe', () => {
4
+ it('create an instance', () => {
5
+ const pipe = new DefaultQuestionAnswersPipe();
6
+ expect(pipe).toBeTruthy();
7
+ });
8
+ });
@@ -0,0 +1,17 @@
1
+ import { Pipe, PipeTransform } from '@angular/core';
2
+ import { DefaultQuestionAnswerDto } from '../../shared/dtos/default-question-answers.dto';
3
+
4
+ @Pipe({
5
+ name: 'defaultQuestionAnswers'
6
+ })
7
+ export class DefaultQuestionAnswersPipe implements PipeTransform {
8
+
9
+ transform(value: DefaultQuestionAnswerDto[], questionId: any , reloadId): DefaultQuestionAnswerDto[] {
10
+ if (value != null) {
11
+ return value.filter(x => x.ParentQuestionId == questionId);
12
+ }
13
+
14
+ return [];
15
+ }
16
+
17
+ }
@@ -0,0 +1,8 @@
1
+ import { FilterQuestionPipe } from './filter-question.pipe';
2
+
3
+ describe('FilterQuestionPipe', () => {
4
+ it('create an instance', () => {
5
+ const pipe = new FilterQuestionPipe();
6
+ expect(pipe).toBeTruthy();
7
+ });
8
+ });
@@ -0,0 +1,14 @@
1
+ import { Pipe, PipeTransform } from '@angular/core';
2
+ import { SurveyQuestionDto } from '../../shared/dtos/survey-question.dto';
3
+ import { QuestionChildOfSurveryLibFormInterface } from '../../shared/form-interfaces/survery-lib.form-interface';
4
+
5
+ @Pipe({
6
+ name: 'filterQuestion'
7
+ })
8
+ export class FilterQuestionPipe implements PipeTransform {
9
+
10
+ transform(value: SurveyQuestionDto, questionArr: QuestionChildOfSurveryLibFormInterface[]): QuestionChildOfSurveryLibFormInterface {
11
+ return questionArr.find(x=>x.questionId == value.questionId);
12
+ }
13
+
14
+ }
@@ -0,0 +1,16 @@
1
+ import { TestBed } from '@angular/core/testing';
2
+
3
+ import { SurveyLibService } from './survey-lib.service';
4
+
5
+ describe('SurveyLibService', () => {
6
+ let service: SurveyLibService;
7
+
8
+ beforeEach(() => {
9
+ TestBed.configureTestingModule({});
10
+ service = TestBed.inject(SurveyLibService);
11
+ });
12
+
13
+ it('should be created', () => {
14
+ expect(service).toBeTruthy();
15
+ });
16
+ });
@@ -0,0 +1,31 @@
1
+ import { Injectable } from '@angular/core';
2
+ import { BehaviorSubject, Subject } from 'rxjs';
3
+ import { SurveyDto } from '../../shared/dtos/survey.dto';
4
+ import { surveyAnswersSubjectDto } from '../../shared/dtos/survey-answers-subject.dto';
5
+
6
+ @Injectable({
7
+ providedIn: 'root'
8
+ })
9
+ export class SurveyLibService {
10
+
11
+ private surveyDataSubject: Subject<SurveyDto> = new Subject<SurveyDto>();
12
+ private surveyAnswersSubject: Subject<surveyAnswersSubjectDto> = new Subject<surveyAnswersSubjectDto>();
13
+
14
+ get surveyDataObsrv() {
15
+ return this.surveyDataSubject.asObservable();
16
+ }
17
+
18
+ get surveyAnswersObsrv() {
19
+ return this.surveyAnswersSubject.asObservable();
20
+ }
21
+
22
+ constructor() { }
23
+
24
+ setSurveyData(survey: SurveyDto) {
25
+ this.surveyDataSubject.next(survey);
26
+ }
27
+
28
+ setsurveyAnswers(model: surveyAnswersSubjectDto) {
29
+ this.surveyAnswersSubject.next(model);
30
+ }
31
+ }
@@ -0,0 +1,21 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { SurveryLibComponent } from './survery-lib.component';
4
+
5
+ describe('SurveryLibComponent', () => {
6
+ let component: SurveryLibComponent;
7
+ let fixture: ComponentFixture<SurveryLibComponent>;
8
+
9
+ beforeEach(() => {
10
+ TestBed.configureTestingModule({
11
+ declarations: [SurveryLibComponent]
12
+ });
13
+ fixture = TestBed.createComponent(SurveryLibComponent);
14
+ component = fixture.componentInstance;
15
+ fixture.detectChanges();
16
+ });
17
+
18
+ it('should create', () => {
19
+ expect(component).toBeTruthy();
20
+ });
21
+ });