survery-lib 0.1.8 → 0.1.9

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 (21) hide show
  1. package/esm2022/lib/components/question-boolean-template/question-boolean-template.component.mjs +18 -17
  2. package/esm2022/lib/components/question-check-box-template/question-check-box-template.component.mjs +21 -19
  3. package/esm2022/lib/components/question-dropdown-template/question-dropdown-template.component.mjs +17 -16
  4. package/esm2022/lib/components/question-matrix-template/question-matrix-template.component.mjs +24 -19
  5. package/esm2022/lib/components/question-radio-button-template/question-radio-button-template.component.mjs +18 -17
  6. package/esm2022/lib/components/question-text-template/question-text-template.component.mjs +19 -18
  7. package/esm2022/lib/pipes/default-question-answer.pipe.mjs +2 -2
  8. package/esm2022/lib/pipes/default-question-answers.pipe.mjs +2 -2
  9. package/esm2022/lib/survery-lib.component.mjs +20 -11
  10. package/fesm2022/survery-lib.mjs +146 -132
  11. package/fesm2022/survery-lib.mjs.map +1 -1
  12. package/lib/components/question-boolean-template/question-boolean-template.component.d.ts +4 -4
  13. package/lib/components/question-check-box-template/question-check-box-template.component.d.ts +4 -4
  14. package/lib/components/question-dropdown-template/question-dropdown-template.component.d.ts +4 -4
  15. package/lib/components/question-matrix-template/question-matrix-template.component.d.ts +7 -6
  16. package/lib/components/question-radio-button-template/question-radio-button-template.component.d.ts +4 -4
  17. package/lib/components/question-text-template/question-text-template.component.d.ts +4 -4
  18. package/lib/pipes/default-question-answer.pipe.d.ts +1 -1
  19. package/lib/pipes/default-question-answers.pipe.d.ts +1 -1
  20. package/lib/survery-lib.component.d.ts +2 -0
  21. package/package.json +1 -1
@@ -1,13 +1,13 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { Injectable, EventEmitter, Component, Output, Input, Pipe, NgModule } from '@angular/core';
3
- import { Subject, of, debounceTime, distinctUntilChanged } from 'rxjs';
3
+ import { v4 } from 'uuid';
4
+ import { Subject, of, debounceTime, map, filter } from 'rxjs';
4
5
  import * as i1 from '@ng-stack/forms';
5
6
  import { NgsFormsModule } from '@ng-stack/forms';
6
- import * as i2 from '@angular/common';
7
+ import * as i3 from '@angular/common';
7
8
  import { CommonModule } from '@angular/common';
8
- import * as i3 from '@angular/forms';
9
+ import * as i4 from '@angular/forms';
9
10
  import { Validators, ReactiveFormsModule, FormsModule } from '@angular/forms';
10
- import { v4 } from 'uuid';
11
11
  import { HttpClientModule } from '@angular/common/http';
12
12
 
13
13
  var QuestionTypeEnum;
@@ -252,13 +252,9 @@ class QuestionTextTemplateComponent {
252
252
  set isDisabled(value) {
253
253
  this.toggleEnableAnswer(value);
254
254
  }
255
- set setAnswer(defaultAnswer) {
256
- if (defaultAnswer != null) {
257
- this.fCtrls.answer.setValue(defaultAnswer.AnswerText);
258
- }
259
- }
260
- constructor(_formBuilder) {
255
+ constructor(_formBuilder, _surveyLibService) {
261
256
  this._formBuilder = _formBuilder;
257
+ this._surveyLibService = _surveyLibService;
262
258
  this.emitter = new EventEmitter();
263
259
  this.isShow = true;
264
260
  this.rForm = this._formBuilder.group({
@@ -270,7 +266,9 @@ class QuestionTextTemplateComponent {
270
266
  surveyAnswerId: [null],
271
267
  answer: [null]
272
268
  });
273
- this.fCtrls.answer.valueChanges.pipe().pipe(debounceTime(500), distinctUntilChanged()).subscribe(value => {
269
+ }
270
+ ngOnInit() {
271
+ this.fCtrls.answer.valueChanges.pipe().pipe(debounceTime(200)).subscribe(value => {
274
272
  const formValue = this.rForm.value;
275
273
  this.emitter.emit({
276
274
  QuestionId: formValue.id,
@@ -279,8 +277,12 @@ class QuestionTextTemplateComponent {
279
277
  SurveyAnswerId: formValue.surveyAnswerId
280
278
  });
281
279
  });
282
- }
283
- ngOnInit() {
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
+ });
284
286
  }
285
287
  convertToFormControl(element) {
286
288
  return element;
@@ -294,13 +296,13 @@ class QuestionTextTemplateComponent {
294
296
  }
295
297
  this.fCtrls.answer.updateValueAndValidity();
296
298
  }
297
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionTextTemplateComponent, deps: [{ token: i1.FormBuilder }], target: i0.ɵɵFactoryTarget.Component }); }
298
- 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", setAnswer: "setAnswer" }, 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: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i3.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: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i3.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i3.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: i3.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }] }); }
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"] }] }); }
299
301
  }
300
302
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionTextTemplateComponent, decorators: [{
301
303
  type: Component,
302
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>" }]
303
- }], ctorParameters: function () { return [{ type: i1.FormBuilder }]; }, propDecorators: { emitter: [{
305
+ }], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: SurveyLibService }]; }, propDecorators: { emitter: [{
304
306
  type: Output
305
307
  }], isShow: [{
306
308
  type: Input
@@ -310,8 +312,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImpor
310
312
  type: Input
311
313
  }], isDisabled: [{
312
314
  type: Input
313
- }], setAnswer: [{
314
- type: Input
315
315
  }] } });
316
316
 
317
317
  class QuestionRadioButtonTemplateComponent {
@@ -344,15 +344,9 @@ class QuestionRadioButtonTemplateComponent {
344
344
  this.isShow = value.isVisable;
345
345
  this.isDisabled = value.isReadOnly;
346
346
  }
347
- set setAnswer(defaultAnswer) {
348
- if (defaultAnswer != null) {
349
- this.fCtrls.answer.setValue(defaultAnswer.AnswerId);
350
- const groupIndex = this.fCtrls.answerArray.value.findIndex(x => x.id == defaultAnswer.AnswerId);
351
- this.fCtrls.answerArray.at(groupIndex).controls.isSelected.setValue(true);
352
- }
353
- }
354
- constructor(_formBuilder) {
347
+ constructor(_formBuilder, _surveyLibService) {
355
348
  this._formBuilder = _formBuilder;
349
+ this._surveyLibService = _surveyLibService;
356
350
  this.elemId = v4();
357
351
  this.emitter = new EventEmitter();
358
352
  this.isShow = true;
@@ -368,7 +362,8 @@ class QuestionRadioButtonTemplateComponent {
368
362
  });
369
363
  }
370
364
  ngOnInit() {
371
- this.fCtrls.answer.valueChanges.pipe().pipe(debounceTime(500), distinctUntilChanged()).subscribe(value => {
365
+ this.fCtrls.answer.valueChanges.pipe().pipe(debounceTime(200)).subscribe(value => {
366
+ console.log(value);
372
367
  const formValue = this.rForm.value;
373
368
  this.emitter.emit({
374
369
  QuestionId: formValue.id,
@@ -377,6 +372,13 @@ class QuestionRadioButtonTemplateComponent {
377
372
  });
378
373
  });
379
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
+ });
380
382
  }
381
383
  onChangeAnswer(item) {
382
384
  this.fCtrls.answer.setValue(item.id);
@@ -384,13 +386,13 @@ class QuestionRadioButtonTemplateComponent {
384
386
  convertToFormControl(element) {
385
387
  return element;
386
388
  }
387
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionRadioButtonTemplateComponent, deps: [{ token: i1.FormBuilder }], target: i0.ɵɵFactoryTarget.Component }); }
388
- 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", setAnswer: "setAnswer" }, 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: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] }); }
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"] }] }); }
389
391
  }
390
392
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionRadioButtonTemplateComponent, decorators: [{
391
393
  type: Component,
392
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" }]
393
- }], ctorParameters: function () { return [{ type: i1.FormBuilder }]; }, propDecorators: { emitter: [{
395
+ }], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: SurveyLibService }]; }, propDecorators: { emitter: [{
394
396
  type: Output
395
397
  }], isShow: [{
396
398
  type: Input
@@ -398,8 +400,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImpor
398
400
  type: Input
399
401
  }], setQuestion: [{
400
402
  type: Input
401
- }], setAnswer: [{
402
- type: Input
403
403
  }] } });
404
404
 
405
405
  class QuestionCheckBoxTemplateComponent {
@@ -432,18 +432,9 @@ class QuestionCheckBoxTemplateComponent {
432
432
  this.isShow = value.isVisable;
433
433
  this.isDisabled = value.isReadOnly;
434
434
  }
435
- set setAnswer(defaultAnswer) {
436
- if (defaultAnswer != null) {
437
- const distinctArray = defaultAnswer.AnswerIdArr.filter((n, i) => defaultAnswer.AnswerIdArr.indexOf(n) === i);
438
- this.fCtrls.answer.setValue(distinctArray);
439
- defaultAnswer.AnswerIdArr.forEach(answerId => {
440
- const groupIndex = this.fCtrls.answerArray.value.findIndex(x => x.id == answerId);
441
- this.fCtrls.answerArray.at(groupIndex).controls.isSelected.setValue(true);
442
- });
443
- }
444
- }
445
- constructor(_formBuilder) {
435
+ constructor(_formBuilder, _surveyLibService) {
446
436
  this._formBuilder = _formBuilder;
437
+ this._surveyLibService = _surveyLibService;
447
438
  this.elemId = v4();
448
439
  this.emitter = new EventEmitter();
449
440
  this.isShow = true;
@@ -459,7 +450,7 @@ class QuestionCheckBoxTemplateComponent {
459
450
  });
460
451
  }
461
452
  ngOnInit() {
462
- this.fCtrls.answer.valueChanges.subscribe(value => {
453
+ this.fCtrls.answer.valueChanges.pipe().pipe(debounceTime(200)).subscribe(value => {
463
454
  const formValue = this.rForm.value;
464
455
  this.emitter.emit({
465
456
  QuestionId: formValue.id,
@@ -468,6 +459,17 @@ class QuestionCheckBoxTemplateComponent {
468
459
  });
469
460
  });
470
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
+ });
471
473
  }
472
474
  onChangeAnswer(item, event) {
473
475
  var answerArr = this.fCtrls.answer.value || [];
@@ -483,13 +485,13 @@ class QuestionCheckBoxTemplateComponent {
483
485
  convertToFormControl(element) {
484
486
  return element;
485
487
  }
486
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionCheckBoxTemplateComponent, deps: [{ token: i1.FormBuilder }], target: i0.ɵɵFactoryTarget.Component }); }
487
- 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", setAnswer: "setAnswer" }, 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: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] }); }
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"] }] }); }
488
490
  }
489
491
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionCheckBoxTemplateComponent, decorators: [{
490
492
  type: Component,
491
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" }]
492
- }], ctorParameters: function () { return [{ type: i1.FormBuilder }]; }, propDecorators: { emitter: [{
494
+ }], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: SurveyLibService }]; }, propDecorators: { emitter: [{
493
495
  type: Output
494
496
  }], isShow: [{
495
497
  type: Input
@@ -497,8 +499,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImpor
497
499
  type: Input
498
500
  }], setQuestion: [{
499
501
  type: Input
500
- }], setAnswer: [{
501
- type: Input
502
502
  }] } });
503
503
 
504
504
  class QuestionDropdownTemplateComponent {
@@ -524,13 +524,9 @@ class QuestionDropdownTemplateComponent {
524
524
  this.isShow = value.isVisable;
525
525
  this.isDisabled = value.isReadOnly;
526
526
  }
527
- set setAnswer(defaultAnswer) {
528
- if (defaultAnswer != null) {
529
- this.fCtrls.answer.setValue(defaultAnswer.AnswerId);
530
- }
531
- }
532
- constructor(_formBuilder) {
527
+ constructor(_formBuilder, _surveyLibService) {
533
528
  this._formBuilder = _formBuilder;
529
+ this._surveyLibService = _surveyLibService;
534
530
  this.emitter = new EventEmitter();
535
531
  this.isShow = true;
536
532
  this.isDisabled = false;
@@ -544,7 +540,7 @@ class QuestionDropdownTemplateComponent {
544
540
  });
545
541
  }
546
542
  ngOnInit() {
547
- this.fCtrls.answer.valueChanges.pipe().pipe(debounceTime(500), distinctUntilChanged()).subscribe(value => {
543
+ this.fCtrls.answer.valueChanges.pipe().pipe(debounceTime(200)).subscribe(value => {
548
544
  const formValue = this.rForm.value;
549
545
  this.emitter.emit({
550
546
  QuestionId: formValue.id,
@@ -553,17 +549,23 @@ class QuestionDropdownTemplateComponent {
553
549
  });
554
550
  });
555
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
+ });
556
558
  }
557
559
  convertToFormControl(element) {
558
560
  return element;
559
561
  }
560
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionDropdownTemplateComponent, deps: [{ token: i1.FormBuilder }], target: i0.ɵɵFactoryTarget.Component }); }
561
- 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", setAnswer: "setAnswer" }, 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: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i3.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i3.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i3.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i3.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }] }); }
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"] }] }); }
562
564
  }
563
565
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionDropdownTemplateComponent, decorators: [{
564
566
  type: Component,
565
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" }]
566
- }], ctorParameters: function () { return [{ type: i1.FormBuilder }]; }, propDecorators: { emitter: [{
568
+ }], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: SurveyLibService }]; }, propDecorators: { emitter: [{
567
569
  type: Output
568
570
  }], isShow: [{
569
571
  type: Input
@@ -571,8 +573,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImpor
571
573
  type: Input
572
574
  }], setQuestion: [{
573
575
  type: Input
574
- }], setAnswer: [{
575
- type: Input
576
576
  }] } });
577
577
 
578
578
  class QuestionMatrixTemplateComponent {
@@ -598,7 +598,7 @@ class QuestionMatrixTemplateComponent {
598
598
  group.controls.answer.addValidators([Validators.required]);
599
599
  group.controls.answer.updateValueAndValidity();
600
600
  }
601
- group.controls.answer.valueChanges.pipe().pipe(debounceTime(500), distinctUntilChanged()).subscribe(value => {
601
+ group.controls.answer.valueChanges.pipe().pipe(debounceTime(200)).subscribe(value => {
602
602
  const formValue = this.rForm.value;
603
603
  this.emitter.emit({
604
604
  QuestionId: group.value.subQuestionId,
@@ -611,16 +611,9 @@ class QuestionMatrixTemplateComponent {
611
611
  this.isShow = value.isVisable;
612
612
  this.isDisabled = value.isReadOnly;
613
613
  }
614
- set setAnswers(defaultAnswerArr) {
615
- this.fCtrls.subQuestionArray.controls.forEach(group => {
616
- var answer = defaultAnswerArr.find(x => x.QuestionId == group.value.subQuestionId);
617
- if (answer != null) {
618
- group.controls.answer.setValue(answer.AnswerId);
619
- }
620
- });
621
- }
622
- constructor(_formBuilder) {
614
+ constructor(_formBuilder, _surveyLibService) {
623
615
  this._formBuilder = _formBuilder;
616
+ this._surveyLibService = _surveyLibService;
624
617
  this.elemId = v4();
625
618
  this.emitter = new EventEmitter();
626
619
  this.isShow = true;
@@ -631,6 +624,19 @@ class QuestionMatrixTemplateComponent {
631
624
  subQuestionArray: this._formBuilder.array([])
632
625
  });
633
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
+ }
634
640
  onChangeAnswer(question, answer) {
635
641
  const index = this.fCtrls.subQuestionArray.value.findIndex(x => x.subQuestionId == question.subQuestionId);
636
642
  var subQuestionGroup = this.fCtrls.subQuestionArray.controls[index];
@@ -644,13 +650,13 @@ class QuestionMatrixTemplateComponent {
644
650
  convertToFormControl(element) {
645
651
  return element;
646
652
  }
647
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionMatrixTemplateComponent, deps: [{ token: i1.FormBuilder }], target: i0.ɵɵFactoryTarget.Component }); }
648
- 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", setAnswers: "setAnswers" }, 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: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i3.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i3.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i3.FormArrayName, selector: "[formArrayName]", inputs: ["formArrayName"] }] }); }
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"] }] }); }
649
655
  }
650
656
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionMatrixTemplateComponent, decorators: [{
651
657
  type: Component,
652
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>" }]
653
- }], ctorParameters: function () { return [{ type: i1.FormBuilder }]; }, propDecorators: { emitter: [{
659
+ }], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: SurveyLibService }]; }, propDecorators: { emitter: [{
654
660
  type: Output
655
661
  }], isShow: [{
656
662
  type: Input
@@ -658,8 +664,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImpor
658
664
  type: Input
659
665
  }], setQuestion: [{
660
666
  type: Input
661
- }], setAnswers: [{
662
- type: Input
663
667
  }] } });
664
668
 
665
669
  class QuestionBooleanTemplateComponent {
@@ -692,15 +696,9 @@ class QuestionBooleanTemplateComponent {
692
696
  this.isShow = value.isVisable;
693
697
  this.isDisabled = value.isReadOnly;
694
698
  }
695
- set setAnswer(defaultAnswer) {
696
- if (defaultAnswer != null) {
697
- this.fCtrls.answer.setValue(defaultAnswer.AnswerId);
698
- const groupIndex = this.fCtrls.answerArray.value.findIndex(x => x.id == defaultAnswer.AnswerId);
699
- this.fCtrls.answerArray.at(groupIndex).controls.isSelected.setValue(true);
700
- }
701
- }
702
- constructor(_formBuilder) {
699
+ constructor(_formBuilder, _surveyLibService) {
703
700
  this._formBuilder = _formBuilder;
701
+ this._surveyLibService = _surveyLibService;
704
702
  this.elemId = v4();
705
703
  this.emitter = new EventEmitter();
706
704
  this.isShow = true;
@@ -716,7 +714,7 @@ class QuestionBooleanTemplateComponent {
716
714
  });
717
715
  }
718
716
  ngOnInit() {
719
- this.fCtrls.answer.valueChanges.pipe().pipe(debounceTime(500), distinctUntilChanged()).subscribe(value => {
717
+ this.fCtrls.answer.valueChanges.pipe().pipe(debounceTime(200)).subscribe(value => {
720
718
  const formValue = this.rForm.value;
721
719
  this.emitter.emit({
722
720
  QuestionId: formValue.id,
@@ -725,6 +723,14 @@ class QuestionBooleanTemplateComponent {
725
723
  });
726
724
  });
727
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
+ });
728
734
  }
729
735
  onChangeAnswer(item) {
730
736
  this.fCtrls.answer.setValue(item.id);
@@ -732,13 +738,13 @@ class QuestionBooleanTemplateComponent {
732
738
  convertToFormControl(element) {
733
739
  return element;
734
740
  }
735
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionBooleanTemplateComponent, deps: [{ token: i1.FormBuilder }], target: i0.ɵɵFactoryTarget.Component }); }
736
- 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", setAnswer: "setAnswer" }, 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: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] }); }
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"] }] }); }
737
743
  }
738
744
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionBooleanTemplateComponent, decorators: [{
739
745
  type: Component,
740
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" }]
741
- }], ctorParameters: function () { return [{ type: i1.FormBuilder }]; }, propDecorators: { emitter: [{
747
+ }], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: SurveyLibService }]; }, propDecorators: { emitter: [{
742
748
  type: Output
743
749
  }], isShow: [{
744
750
  type: Input
@@ -746,8 +752,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImpor
746
752
  type: Input
747
753
  }], setQuestion: [{
748
754
  type: Input
749
- }], setAnswer: [{
750
- type: Input
751
755
  }] } });
752
756
 
753
757
  class FilterQuestionPipe {
@@ -764,40 +768,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImpor
764
768
  }]
765
769
  }] });
766
770
 
767
- class DefaultQuestionAnswerPipe {
768
- transform(value, questionId) {
769
- if (value != null) {
770
- return value.find(x => x.QuestionId == questionId);
771
- }
772
- return null;
773
- }
774
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: DefaultQuestionAnswerPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
775
- static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "16.1.7", ngImport: i0, type: DefaultQuestionAnswerPipe, name: "defaultQuestionAnswer" }); }
776
- }
777
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: DefaultQuestionAnswerPipe, decorators: [{
778
- type: Pipe,
779
- args: [{
780
- name: 'defaultQuestionAnswer'
781
- }]
782
- }] });
783
-
784
- class DefaultQuestionAnswersPipe {
785
- transform(value, questionId) {
786
- if (value != null) {
787
- return value.filter(x => x.ParentQuestionId == questionId);
788
- }
789
- return [];
790
- }
791
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: DefaultQuestionAnswersPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
792
- static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "16.1.7", ngImport: i0, type: DefaultQuestionAnswersPipe, name: "defaultQuestionAnswers" }); }
793
- }
794
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: DefaultQuestionAnswersPipe, decorators: [{
795
- type: Pipe,
796
- args: [{
797
- name: 'defaultQuestionAnswers'
798
- }]
799
- }] });
800
-
801
771
  class SurveryLibComponent {
802
772
  get fCtrls() {
803
773
  return this.rForm.controls;
@@ -805,6 +775,9 @@ class SurveryLibComponent {
805
775
  get questionTypeEnum() {
806
776
  return QuestionTypeEnum;
807
777
  }
778
+ get isFirstPage() {
779
+ return this.fCtrls.currentPageIndex.value == 0;
780
+ }
808
781
  get isLastPage() {
809
782
  return this.fCtrls.currentPageIndex.value == (this.surveyData?.surveyPages.length - 1);
810
783
  }
@@ -827,6 +800,7 @@ class SurveryLibComponent {
827
800
  this._surveyLibService = _surveyLibService;
828
801
  this._formBuilder = _formBuilder;
829
802
  this._checkRuleExpsUsecase = _checkRuleExpsUsecase;
803
+ this.reloadDefaultAnswerId = v4();
830
804
  this.surveyResultEmit = new EventEmitter();
831
805
  this.rForm = this._formBuilder.group({
832
806
  currentPageIndex: [0],
@@ -836,17 +810,23 @@ class SurveryLibComponent {
836
810
  }
837
811
  ngOnInit() {
838
812
  this._surveyLibService.surveyDataObsrv.subscribe(survey => {
839
- this.surveyData = survey;
813
+ this.fCtrls.questionArray.clear();
814
+ this.fCtrls.ruleQuestionArray.clear();
815
+ this.surveyData = null;
840
816
  if (survey != null) {
817
+ this.surveyData = survey;
841
818
  this.loadQuestions(survey);
842
819
  }
843
- else {
844
- this.fCtrls.questionArray.clear();
845
- }
846
820
  });
847
821
  this._surveyLibService.surveyAnswersObsrv.subscribe(value => {
848
- this.defaultAnswers = value.defaultAnswers;
849
- this.fCtrls.currentPageIndex.setValue(value.currentpage);
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);
850
830
  });
851
831
  }
852
832
  onPaggingNext() {
@@ -1033,15 +1013,49 @@ class SurveryLibComponent {
1033
1013
  });
1034
1014
  }
1035
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 }); }
1036
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", type: SurveryLibComponent, selector: "lib-survery-lib", outputs: { surveyResultEmit: "surveyResultEmit" }, ngImport: i0, template: "<div class=\"survay-card\">\r\n <div *ngFor=\"let surveyPage of surveyData?.surveyPages; let surveyPageIndex = index\"\r\n [attr.id]=\"'survey-page_'+surveyPageIndex\" [ngClass]=\"{'d-none': surveyPageIndex != fCtrls.currentPageIndex.value}\">\r\n <ng-container *ngFor=\"let item of surveyPage.surveyQuestionGroups\">\r\n <div class=\"survay-card\">\r\n <div class=\"survay-card-body\">\r\n <div class=\"survay-group\">\r\n <div class=\"title\">\r\n <h2 class=\"group-title\">\r\n {{item.questionGroupName}}\r\n </h2>\r\n <span class=\"group-sub-title \">\r\n {{item.questionGroupDescription}}\r\n </span>\r\n </div>\r\n <ng-container *ngFor=\"let question of item.surveyQuestions\">\r\n <lib-question-boolean-template #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\"\r\n [setAnswer]=\"(defaultAnswers|defaultQuestionAnswer :question.questionId)\"></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\"\r\n [setAnswer]=\"(defaultAnswers|defaultQuestionAnswer :question.questionId)\"></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\"\r\n [setAnswer]=\"(defaultAnswers|defaultQuestionAnswer :question.questionId)\"></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\"\r\n [setAnswer]=\"(defaultAnswers|defaultQuestionAnswer :question.questionId)\"></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\"\r\n [setAnswer]=\"(defaultAnswers|defaultQuestionAnswer :question.questionId)\"></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\"\r\n [setAnswers]=\"(defaultAnswers|defaultQuestionAnswers :question.questionId)\"></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: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: QuestionTextTemplateComponent, selector: "lib-question-text-template", inputs: ["isShow", "isTextArea", "setQuestion", "isDisabled", "setAnswer"], outputs: ["emitter"] }, { kind: "component", type: QuestionRadioButtonTemplateComponent, selector: "lib-question-radio-button-template", inputs: ["isShow", "isDisabled", "setQuestion", "setAnswer"], outputs: ["emitter"] }, { kind: "component", type: QuestionCheckBoxTemplateComponent, selector: "lib-question-check-box-template", inputs: ["isShow", "isDisabled", "setQuestion", "setAnswer"], outputs: ["emitter"] }, { kind: "component", type: QuestionDropdownTemplateComponent, selector: "lib-question-dropdown-template", inputs: ["isShow", "isDisabled", "setQuestion", "setAnswer"], outputs: ["emitter"] }, { kind: "component", type: QuestionMatrixTemplateComponent, selector: "lib-question-matrix-template", inputs: ["isShow", "isDisabled", "setQuestion", "setAnswers"], outputs: ["emitter"] }, { kind: "component", type: QuestionBooleanTemplateComponent, selector: "lib-question-boolean-template", inputs: ["isShow", "isDisabled", "setQuestion", "setAnswer"], outputs: ["emitter"] }, { kind: "pipe", type: FilterQuestionPipe, name: "filterQuestion" }, { kind: "pipe", type: DefaultQuestionAnswerPipe, name: "defaultQuestionAnswer" }, { kind: "pipe", type: DefaultQuestionAnswersPipe, name: "defaultQuestionAnswers" }] }); }
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" }] }); }
1037
1017
  }
1038
1018
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: SurveryLibComponent, decorators: [{
1039
1019
  type: Component,
1040
- args: [{ selector: 'lib-survery-lib', template: "<div class=\"survay-card\">\r\n <div *ngFor=\"let surveyPage of surveyData?.surveyPages; let surveyPageIndex = index\"\r\n [attr.id]=\"'survey-page_'+surveyPageIndex\" [ngClass]=\"{'d-none': surveyPageIndex != fCtrls.currentPageIndex.value}\">\r\n <ng-container *ngFor=\"let item of surveyPage.surveyQuestionGroups\">\r\n <div class=\"survay-card\">\r\n <div class=\"survay-card-body\">\r\n <div class=\"survay-group\">\r\n <div class=\"title\">\r\n <h2 class=\"group-title\">\r\n {{item.questionGroupName}}\r\n </h2>\r\n <span class=\"group-sub-title \">\r\n {{item.questionGroupDescription}}\r\n </span>\r\n </div>\r\n <ng-container *ngFor=\"let question of item.surveyQuestions\">\r\n <lib-question-boolean-template #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\"\r\n [setAnswer]=\"(defaultAnswers|defaultQuestionAnswer :question.questionId)\"></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\"\r\n [setAnswer]=\"(defaultAnswers|defaultQuestionAnswer :question.questionId)\"></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\"\r\n [setAnswer]=\"(defaultAnswers|defaultQuestionAnswer :question.questionId)\"></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\"\r\n [setAnswer]=\"(defaultAnswers|defaultQuestionAnswer :question.questionId)\"></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\"\r\n [setAnswer]=\"(defaultAnswers|defaultQuestionAnswer :question.questionId)\"></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\"\r\n [setAnswers]=\"(defaultAnswers|defaultQuestionAnswers :question.questionId)\"></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"] }]
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"] }]
1041
1021
  }], ctorParameters: function () { return [{ type: SurveyLibService }, { type: i1.FormBuilder }, { type: CheckRuleExpsUsecase }]; }, propDecorators: { surveyResultEmit: [{
1042
1022
  type: Output
1043
1023
  }] } });
1044
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
+
1045
1059
  class SurveryLibModule {
1046
1060
  static forRoot() {
1047
1061
  return {