survery-lib 0.1.8 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -52
- package/assets/style.css +58 -58
- package/esm2022/lib/components/question-boolean-template/question-boolean-template.component.mjs +21 -18
- package/esm2022/lib/components/question-check-box-template/question-check-box-template.component.mjs +24 -20
- package/esm2022/lib/components/question-dropdown-template/question-dropdown-template.component.mjs +18 -17
- package/esm2022/lib/components/question-matrix-template/question-matrix-template.component.mjs +25 -20
- package/esm2022/lib/components/question-radio-button-template/question-radio-button-template.component.mjs +21 -18
- package/esm2022/lib/components/question-text-template/question-text-template.component.mjs +20 -19
- package/esm2022/lib/pipes/default-question-answer.pipe.mjs +2 -2
- package/esm2022/lib/pipes/default-question-answers.pipe.mjs +2 -2
- package/esm2022/lib/pipes/filter-question.pipe.mjs +1 -1
- package/esm2022/lib/services/survey-lib.service.mjs +1 -1
- package/esm2022/lib/survery-lib.component.mjs +20 -11
- package/esm2022/lib/survery-lib.module.mjs +1 -1
- package/esm2022/public-api.mjs +1 -1
- package/fesm2022/survery-lib.mjs +158 -138
- package/fesm2022/survery-lib.mjs.map +1 -1
- package/lib/components/question-boolean-template/question-boolean-template.component.d.ts +4 -4
- package/lib/components/question-check-box-template/question-check-box-template.component.d.ts +4 -4
- package/lib/components/question-dropdown-template/question-dropdown-template.component.d.ts +4 -4
- package/lib/components/question-matrix-template/question-matrix-template.component.d.ts +7 -6
- package/lib/components/question-radio-button-template/question-radio-button-template.component.d.ts +4 -4
- package/lib/components/question-text-template/question-text-template.component.d.ts +4 -4
- package/lib/pipes/default-question-answer.pipe.d.ts +1 -1
- package/lib/pipes/default-question-answers.pipe.d.ts +1 -1
- package/lib/survery-lib.component.d.ts +2 -0
- package/package.json +1 -1
package/fesm2022/survery-lib.mjs
CHANGED
|
@@ -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 {
|
|
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
|
|
7
|
+
import * as i3 from '@angular/common';
|
|
7
8
|
import { CommonModule } from '@angular/common';
|
|
8
|
-
import * as
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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"
|
|
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\"\r\n [ngClass]=\"{'invalid-question': fCtrls.answer.invalid , 'd-none':isShow != true}\">\r\n <h3 class=\"quastion-title \">\r\n {{fCtrls.title.value}}\r\n </h3>\r\n <div class=\"text-quastion\">\r\n <input class=\"form-control\" type=\"text\" [formControl]=\"convertToFormControl(fCtrls.answer)\"\r\n [disabled]=\"isDisabled\" *ngIf=\"isTextArea == false else textAreaTemplate\">\r\n <ng-template #textAreaTemplate>\r\n <textarea class=\"form-control\" rows=\"5\" [formControl]=\"convertToFormControl(fCtrls.answer)\"\r\n [disabled]=\"isDisabled\" ></textarea>\r\n </ng-template>\r\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
|
-
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: [{
|
|
304
|
+
args: [{ selector: 'lib-question-text-template', template: "<div class=\"quastion\" [formGroup]=\"rForm\" [attr.id]=\"'question_'+fCtrls.id.value\"\r\n [ngClass]=\"{'invalid-question': fCtrls.answer.invalid , 'd-none':isShow != true}\">\r\n <h3 class=\"quastion-title \">\r\n {{fCtrls.title.value}}\r\n </h3>\r\n <div class=\"text-quastion\">\r\n <input class=\"form-control\" type=\"text\" [formControl]=\"convertToFormControl(fCtrls.answer)\"\r\n [disabled]=\"isDisabled\" *ngIf=\"isTextArea == false else textAreaTemplate\">\r\n <ng-template #textAreaTemplate>\r\n <textarea class=\"form-control\" rows=\"5\" [formControl]=\"convertToFormControl(fCtrls.answer)\"\r\n [disabled]=\"isDisabled\" ></textarea>\r\n </ng-template>\r\n </div>" }]
|
|
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
|
-
|
|
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(
|
|
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,15 @@ 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
|
+
if (groupIndex > -1) {
|
|
381
|
+
this.fCtrls.answerArray.at(groupIndex).controls.isSelected.setValue(true);
|
|
382
|
+
}
|
|
383
|
+
});
|
|
380
384
|
}
|
|
381
385
|
onChangeAnswer(item) {
|
|
382
386
|
this.fCtrls.answer.setValue(item.id);
|
|
@@ -384,13 +388,13 @@ class QuestionRadioButtonTemplateComponent {
|
|
|
384
388
|
convertToFormControl(element) {
|
|
385
389
|
return element;
|
|
386
390
|
}
|
|
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"
|
|
391
|
+
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 }); }
|
|
392
|
+
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}\">\r\n <h3 class=\"quastion-title \">\r\n {{fCtrls.title.value}}\r\n </h3>\r\n <div class=\"radio-button-quastion\">\r\n <div class=\"form-check form-check-radio form-check-inline\" \r\n *ngFor=\"let item of fCtrls.answerArray.controls;let i = index\">\r\n <input class=\"form-check-input\" type=\"radio\" (change)=\"onChangeAnswer(item.value)\" [disabled]=\"isDisabled\"\r\n name=\"{{elemId}}__radio-btn-option\" id=\"{{elemId}}__radio-btn_{{i}}\" [checked]=\"item.value.isSelected == true? true : null\">\r\n <label class=\"form-check-label\" for=\"{{elemId}}__radio-btn_{{i}}\">{{item.value.title}}</label>\r\n </div>\r\n </div>\r\n</div>\r\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
393
|
}
|
|
390
394
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionRadioButtonTemplateComponent, decorators: [{
|
|
391
395
|
type: Component,
|
|
392
|
-
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: [{
|
|
396
|
+
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}\">\r\n <h3 class=\"quastion-title \">\r\n {{fCtrls.title.value}}\r\n </h3>\r\n <div class=\"radio-button-quastion\">\r\n <div class=\"form-check form-check-radio form-check-inline\" \r\n *ngFor=\"let item of fCtrls.answerArray.controls;let i = index\">\r\n <input class=\"form-check-input\" type=\"radio\" (change)=\"onChangeAnswer(item.value)\" [disabled]=\"isDisabled\"\r\n name=\"{{elemId}}__radio-btn-option\" id=\"{{elemId}}__radio-btn_{{i}}\" [checked]=\"item.value.isSelected == true? true : null\">\r\n <label class=\"form-check-label\" for=\"{{elemId}}__radio-btn_{{i}}\">{{item.value.title}}</label>\r\n </div>\r\n </div>\r\n</div>\r\n" }]
|
|
397
|
+
}], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: SurveyLibService }]; }, propDecorators: { emitter: [{
|
|
394
398
|
type: Output
|
|
395
399
|
}], isShow: [{
|
|
396
400
|
type: Input
|
|
@@ -398,8 +402,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImpor
|
|
|
398
402
|
type: Input
|
|
399
403
|
}], setQuestion: [{
|
|
400
404
|
type: Input
|
|
401
|
-
}], setAnswer: [{
|
|
402
|
-
type: Input
|
|
403
405
|
}] } });
|
|
404
406
|
|
|
405
407
|
class QuestionCheckBoxTemplateComponent {
|
|
@@ -432,18 +434,9 @@ class QuestionCheckBoxTemplateComponent {
|
|
|
432
434
|
this.isShow = value.isVisable;
|
|
433
435
|
this.isDisabled = value.isReadOnly;
|
|
434
436
|
}
|
|
435
|
-
|
|
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) {
|
|
437
|
+
constructor(_formBuilder, _surveyLibService) {
|
|
446
438
|
this._formBuilder = _formBuilder;
|
|
439
|
+
this._surveyLibService = _surveyLibService;
|
|
447
440
|
this.elemId = v4();
|
|
448
441
|
this.emitter = new EventEmitter();
|
|
449
442
|
this.isShow = true;
|
|
@@ -459,7 +452,7 @@ class QuestionCheckBoxTemplateComponent {
|
|
|
459
452
|
});
|
|
460
453
|
}
|
|
461
454
|
ngOnInit() {
|
|
462
|
-
this.fCtrls.answer.valueChanges.subscribe(value => {
|
|
455
|
+
this.fCtrls.answer.valueChanges.pipe().pipe(debounceTime(200)).subscribe(value => {
|
|
463
456
|
const formValue = this.rForm.value;
|
|
464
457
|
this.emitter.emit({
|
|
465
458
|
QuestionId: formValue.id,
|
|
@@ -468,6 +461,19 @@ class QuestionCheckBoxTemplateComponent {
|
|
|
468
461
|
});
|
|
469
462
|
});
|
|
470
463
|
this.fCtrls.answer.setValue(null);
|
|
464
|
+
this._surveyLibService.surveyAnswersObsrv
|
|
465
|
+
.pipe(map(x => x.defaultAnswers.filter(x => x.QuestionId == this.fCtrls.id.value)))
|
|
466
|
+
.pipe(filter(x => x.length > 0)).pipe(map(x => x.at(0)))
|
|
467
|
+
.subscribe(answer => {
|
|
468
|
+
const distinctArray = answer.AnswerIdArr.filter((n, i) => answer.AnswerIdArr.indexOf(n) === i);
|
|
469
|
+
this.fCtrls.answer.setValue(distinctArray);
|
|
470
|
+
answer.AnswerIdArr.forEach(answerId => {
|
|
471
|
+
const groupIndex = this.fCtrls.answerArray.value.findIndex(x => x.id == answerId);
|
|
472
|
+
if (groupIndex > -1) {
|
|
473
|
+
this.fCtrls.answerArray.at(groupIndex).controls.isSelected.setValue(true);
|
|
474
|
+
}
|
|
475
|
+
});
|
|
476
|
+
});
|
|
471
477
|
}
|
|
472
478
|
onChangeAnswer(item, event) {
|
|
473
479
|
var answerArr = this.fCtrls.answer.value || [];
|
|
@@ -483,13 +489,13 @@ class QuestionCheckBoxTemplateComponent {
|
|
|
483
489
|
convertToFormControl(element) {
|
|
484
490
|
return element;
|
|
485
491
|
}
|
|
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"
|
|
492
|
+
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 }); }
|
|
493
|
+
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}\">\r\n <h3 class=\"quastion-title \">\r\n {{fCtrls.title.value}}\r\n </h3>\r\n\r\n <div class=\"checkbox-button-quastion\">\r\n <div class=\"form-check check-box-form-check\" *ngFor=\"let item of fCtrls.answerArray.controls ;let i = index\">\r\n <input type=\"checkbox\" class=\"form-check-input\" id=\"{{elemId}}__checkbox_{{i}}\" [disabled]=\"isDisabled\"\r\n (change)=\"onChangeAnswer(item.value ,$event)\" [checked]=\"item.value.isSelected == true? true : null\">\r\n <label class=\"form-check-label \" for=\"{{elemId}}__checkbox_{{i}}\">{{item.value.title}}</label>\r\n </div>\r\n </div>\r\n</div>\r\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
494
|
}
|
|
489
495
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionCheckBoxTemplateComponent, decorators: [{
|
|
490
496
|
type: Component,
|
|
491
|
-
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: [{
|
|
497
|
+
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}\">\r\n <h3 class=\"quastion-title \">\r\n {{fCtrls.title.value}}\r\n </h3>\r\n\r\n <div class=\"checkbox-button-quastion\">\r\n <div class=\"form-check check-box-form-check\" *ngFor=\"let item of fCtrls.answerArray.controls ;let i = index\">\r\n <input type=\"checkbox\" class=\"form-check-input\" id=\"{{elemId}}__checkbox_{{i}}\" [disabled]=\"isDisabled\"\r\n (change)=\"onChangeAnswer(item.value ,$event)\" [checked]=\"item.value.isSelected == true? true : null\">\r\n <label class=\"form-check-label \" for=\"{{elemId}}__checkbox_{{i}}\">{{item.value.title}}</label>\r\n </div>\r\n </div>\r\n</div>\r\n" }]
|
|
498
|
+
}], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: SurveyLibService }]; }, propDecorators: { emitter: [{
|
|
493
499
|
type: Output
|
|
494
500
|
}], isShow: [{
|
|
495
501
|
type: Input
|
|
@@ -497,8 +503,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImpor
|
|
|
497
503
|
type: Input
|
|
498
504
|
}], setQuestion: [{
|
|
499
505
|
type: Input
|
|
500
|
-
}], setAnswer: [{
|
|
501
|
-
type: Input
|
|
502
506
|
}] } });
|
|
503
507
|
|
|
504
508
|
class QuestionDropdownTemplateComponent {
|
|
@@ -524,13 +528,9 @@ class QuestionDropdownTemplateComponent {
|
|
|
524
528
|
this.isShow = value.isVisable;
|
|
525
529
|
this.isDisabled = value.isReadOnly;
|
|
526
530
|
}
|
|
527
|
-
|
|
528
|
-
if (defaultAnswer != null) {
|
|
529
|
-
this.fCtrls.answer.setValue(defaultAnswer.AnswerId);
|
|
530
|
-
}
|
|
531
|
-
}
|
|
532
|
-
constructor(_formBuilder) {
|
|
531
|
+
constructor(_formBuilder, _surveyLibService) {
|
|
533
532
|
this._formBuilder = _formBuilder;
|
|
533
|
+
this._surveyLibService = _surveyLibService;
|
|
534
534
|
this.emitter = new EventEmitter();
|
|
535
535
|
this.isShow = true;
|
|
536
536
|
this.isDisabled = false;
|
|
@@ -544,7 +544,7 @@ class QuestionDropdownTemplateComponent {
|
|
|
544
544
|
});
|
|
545
545
|
}
|
|
546
546
|
ngOnInit() {
|
|
547
|
-
this.fCtrls.answer.valueChanges.pipe().pipe(debounceTime(
|
|
547
|
+
this.fCtrls.answer.valueChanges.pipe().pipe(debounceTime(200)).subscribe(value => {
|
|
548
548
|
const formValue = this.rForm.value;
|
|
549
549
|
this.emitter.emit({
|
|
550
550
|
QuestionId: formValue.id,
|
|
@@ -553,17 +553,23 @@ class QuestionDropdownTemplateComponent {
|
|
|
553
553
|
});
|
|
554
554
|
});
|
|
555
555
|
this.fCtrls.answer.setValue(null);
|
|
556
|
+
this._surveyLibService.surveyAnswersObsrv
|
|
557
|
+
.pipe(map(x => x.defaultAnswers.filter(x => x.QuestionId == this.fCtrls.id.value)))
|
|
558
|
+
.pipe(filter(x => x.length > 0)).pipe(map(x => x.at(0)))
|
|
559
|
+
.subscribe(answer => {
|
|
560
|
+
this.fCtrls.answer.setValue(answer.AnswerId);
|
|
561
|
+
});
|
|
556
562
|
}
|
|
557
563
|
convertToFormControl(element) {
|
|
558
564
|
return element;
|
|
559
565
|
}
|
|
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"
|
|
566
|
+
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 }); }
|
|
567
|
+
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}\">\r\n <h3 class=\"quastion-title \">\r\n {{fCtrls.title.value}}\r\n </h3>\r\n <div class=\"text-quastion\">\r\n <select class=\"form-control\" [formControl]=\"convertToFormControl(fCtrls.answer)\" [disabled]=\"isDisabled\">\r\n <option *ngFor=\"let item of surveyQuestion?.surveyAnswers\" [value]=\"item.answerId\">{{item.answerTitle}}</option>\r\n </select>\r\n </div>\r\n</div>\r\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
568
|
}
|
|
563
569
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionDropdownTemplateComponent, decorators: [{
|
|
564
570
|
type: Component,
|
|
565
|
-
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: [{
|
|
571
|
+
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}\">\r\n <h3 class=\"quastion-title \">\r\n {{fCtrls.title.value}}\r\n </h3>\r\n <div class=\"text-quastion\">\r\n <select class=\"form-control\" [formControl]=\"convertToFormControl(fCtrls.answer)\" [disabled]=\"isDisabled\">\r\n <option *ngFor=\"let item of surveyQuestion?.surveyAnswers\" [value]=\"item.answerId\">{{item.answerTitle}}</option>\r\n </select>\r\n </div>\r\n</div>\r\n" }]
|
|
572
|
+
}], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: SurveyLibService }]; }, propDecorators: { emitter: [{
|
|
567
573
|
type: Output
|
|
568
574
|
}], isShow: [{
|
|
569
575
|
type: Input
|
|
@@ -571,8 +577,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImpor
|
|
|
571
577
|
type: Input
|
|
572
578
|
}], setQuestion: [{
|
|
573
579
|
type: Input
|
|
574
|
-
}], setAnswer: [{
|
|
575
|
-
type: Input
|
|
576
580
|
}] } });
|
|
577
581
|
|
|
578
582
|
class QuestionMatrixTemplateComponent {
|
|
@@ -598,7 +602,7 @@ class QuestionMatrixTemplateComponent {
|
|
|
598
602
|
group.controls.answer.addValidators([Validators.required]);
|
|
599
603
|
group.controls.answer.updateValueAndValidity();
|
|
600
604
|
}
|
|
601
|
-
group.controls.answer.valueChanges.pipe().pipe(debounceTime(
|
|
605
|
+
group.controls.answer.valueChanges.pipe().pipe(debounceTime(200)).subscribe(value => {
|
|
602
606
|
const formValue = this.rForm.value;
|
|
603
607
|
this.emitter.emit({
|
|
604
608
|
QuestionId: group.value.subQuestionId,
|
|
@@ -611,16 +615,9 @@ class QuestionMatrixTemplateComponent {
|
|
|
611
615
|
this.isShow = value.isVisable;
|
|
612
616
|
this.isDisabled = value.isReadOnly;
|
|
613
617
|
}
|
|
614
|
-
|
|
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) {
|
|
618
|
+
constructor(_formBuilder, _surveyLibService) {
|
|
623
619
|
this._formBuilder = _formBuilder;
|
|
620
|
+
this._surveyLibService = _surveyLibService;
|
|
624
621
|
this.elemId = v4();
|
|
625
622
|
this.emitter = new EventEmitter();
|
|
626
623
|
this.isShow = true;
|
|
@@ -631,6 +628,19 @@ class QuestionMatrixTemplateComponent {
|
|
|
631
628
|
subQuestionArray: this._formBuilder.array([])
|
|
632
629
|
});
|
|
633
630
|
}
|
|
631
|
+
ngOnInit() {
|
|
632
|
+
this._surveyLibService.surveyAnswersObsrv
|
|
633
|
+
.pipe(map(x => x.defaultAnswers.filter(x => x.ParentQuestionId == this.fCtrls.id.value)))
|
|
634
|
+
.pipe(filter(x => x.length > 0))
|
|
635
|
+
.subscribe(answers => {
|
|
636
|
+
this.fCtrls.subQuestionArray.controls.forEach(group => {
|
|
637
|
+
var answer = answers.find(x => x.QuestionId == group.value.subQuestionId);
|
|
638
|
+
if (answer != null) {
|
|
639
|
+
group.controls.answer.setValue(answer.AnswerId);
|
|
640
|
+
}
|
|
641
|
+
});
|
|
642
|
+
});
|
|
643
|
+
}
|
|
634
644
|
onChangeAnswer(question, answer) {
|
|
635
645
|
const index = this.fCtrls.subQuestionArray.value.findIndex(x => x.subQuestionId == question.subQuestionId);
|
|
636
646
|
var subQuestionGroup = this.fCtrls.subQuestionArray.controls[index];
|
|
@@ -644,13 +654,13 @@ class QuestionMatrixTemplateComponent {
|
|
|
644
654
|
convertToFormControl(element) {
|
|
645
655
|
return element;
|
|
646
656
|
}
|
|
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"
|
|
657
|
+
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 }); }
|
|
658
|
+
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;\"\r\n[ngClass]=\"{'d-none':isShow != true}\">\r\n <h3 class=\"quastion-title \">\r\n {{surveyQuestion?.questionTitle}}\r\n </h3>\r\n <div class=\"matrix-question\" [formGroup]=\"rForm\">\r\n <div class=\"matrix-table\" formArrayName=\"subQuestionArray\">\r\n <div class=\"matrix-head-row\">\r\n <div class=\"matrix-col\">\r\n </div>\r\n <div class=\"matrix-col\" *ngFor=\"let answers of surveyQuestion?.surveyAnswers\">\r\n {{answers.answerTitle}}\r\n </div>\r\n </div>\r\n\r\n <div class=\"matrix-row\"\r\n *ngFor=\"let questionGroup of fCtrls.subQuestionArray.controls ;let subQuestionIndex = index\"\r\n [ngClass]=\"{'invalid-question': questionGroup.controls.answer.invalid}\">\r\n <div class=\"matrix-col matrix-sub-quastion\">\r\n {{questionGroup.value.questionTitle}}\r\n </div>\r\n <div class=\"matrix-col\" *ngFor=\"let answer of surveyQuestion?.surveyAnswers;let answerIndex = index\">\r\n <div class=\"form-check form-check-radio form-check-inline\">\r\n <input class=\"form-check-input\" type=\"radio\" name=\"{{elemId}}__radio-btn-option_{{subQuestionIndex}}\"\r\n id=\"{{elemId}}__radio-btn_{{subQuestionIndex}}_{{answerIndex}}\" (change)=\"onChangeAnswer(questionGroup.value ,answer)\"\r\n value=\"{{answer.answerId}}\" [checked]=\"answer.answerId == questionGroup.value.answer\">\r\n <label class=\"form-check-label d-md-inline d-lg-none\"\r\n for=\"{{elemId}}__radio-btn_{{subQuestionIndex}}_{{answerIndex}}\"> {{answer.answerTitle}}</label>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n </div>\r\n\r\n </div>\r\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
659
|
}
|
|
650
660
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionMatrixTemplateComponent, decorators: [{
|
|
651
661
|
type: Component,
|
|
652
|
-
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: [{
|
|
662
|
+
args: [{ selector: 'lib-question-matrix-template', template: "<div class=\"quastion\" [attr.id]=\"'question_'+fCtrls.id.value\" style=\" border-collapse: collapse;\"\r\n[ngClass]=\"{'d-none':isShow != true}\">\r\n <h3 class=\"quastion-title \">\r\n {{surveyQuestion?.questionTitle}}\r\n </h3>\r\n <div class=\"matrix-question\" [formGroup]=\"rForm\">\r\n <div class=\"matrix-table\" formArrayName=\"subQuestionArray\">\r\n <div class=\"matrix-head-row\">\r\n <div class=\"matrix-col\">\r\n </div>\r\n <div class=\"matrix-col\" *ngFor=\"let answers of surveyQuestion?.surveyAnswers\">\r\n {{answers.answerTitle}}\r\n </div>\r\n </div>\r\n\r\n <div class=\"matrix-row\"\r\n *ngFor=\"let questionGroup of fCtrls.subQuestionArray.controls ;let subQuestionIndex = index\"\r\n [ngClass]=\"{'invalid-question': questionGroup.controls.answer.invalid}\">\r\n <div class=\"matrix-col matrix-sub-quastion\">\r\n {{questionGroup.value.questionTitle}}\r\n </div>\r\n <div class=\"matrix-col\" *ngFor=\"let answer of surveyQuestion?.surveyAnswers;let answerIndex = index\">\r\n <div class=\"form-check form-check-radio form-check-inline\">\r\n <input class=\"form-check-input\" type=\"radio\" name=\"{{elemId}}__radio-btn-option_{{subQuestionIndex}}\"\r\n id=\"{{elemId}}__radio-btn_{{subQuestionIndex}}_{{answerIndex}}\" (change)=\"onChangeAnswer(questionGroup.value ,answer)\"\r\n value=\"{{answer.answerId}}\" [checked]=\"answer.answerId == questionGroup.value.answer\">\r\n <label class=\"form-check-label d-md-inline d-lg-none\"\r\n for=\"{{elemId}}__radio-btn_{{subQuestionIndex}}_{{answerIndex}}\"> {{answer.answerTitle}}</label>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n </div>\r\n\r\n </div>\r\n</div>" }]
|
|
663
|
+
}], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: SurveyLibService }]; }, propDecorators: { emitter: [{
|
|
654
664
|
type: Output
|
|
655
665
|
}], isShow: [{
|
|
656
666
|
type: Input
|
|
@@ -658,8 +668,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImpor
|
|
|
658
668
|
type: Input
|
|
659
669
|
}], setQuestion: [{
|
|
660
670
|
type: Input
|
|
661
|
-
}], setAnswers: [{
|
|
662
|
-
type: Input
|
|
663
671
|
}] } });
|
|
664
672
|
|
|
665
673
|
class QuestionBooleanTemplateComponent {
|
|
@@ -692,15 +700,9 @@ class QuestionBooleanTemplateComponent {
|
|
|
692
700
|
this.isShow = value.isVisable;
|
|
693
701
|
this.isDisabled = value.isReadOnly;
|
|
694
702
|
}
|
|
695
|
-
|
|
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) {
|
|
703
|
+
constructor(_formBuilder, _surveyLibService) {
|
|
703
704
|
this._formBuilder = _formBuilder;
|
|
705
|
+
this._surveyLibService = _surveyLibService;
|
|
704
706
|
this.elemId = v4();
|
|
705
707
|
this.emitter = new EventEmitter();
|
|
706
708
|
this.isShow = true;
|
|
@@ -716,7 +718,7 @@ class QuestionBooleanTemplateComponent {
|
|
|
716
718
|
});
|
|
717
719
|
}
|
|
718
720
|
ngOnInit() {
|
|
719
|
-
this.fCtrls.answer.valueChanges.pipe().pipe(debounceTime(
|
|
721
|
+
this.fCtrls.answer.valueChanges.pipe().pipe(debounceTime(200)).subscribe(value => {
|
|
720
722
|
const formValue = this.rForm.value;
|
|
721
723
|
this.emitter.emit({
|
|
722
724
|
QuestionId: formValue.id,
|
|
@@ -725,6 +727,16 @@ class QuestionBooleanTemplateComponent {
|
|
|
725
727
|
});
|
|
726
728
|
});
|
|
727
729
|
this.fCtrls.answer.setValue(null);
|
|
730
|
+
this._surveyLibService.surveyAnswersObsrv
|
|
731
|
+
.pipe(map(x => x.defaultAnswers.filter(x => x.QuestionId == this.fCtrls.id.value)))
|
|
732
|
+
.pipe(filter(x => x.length > 0)).pipe(map(x => x.at(0)))
|
|
733
|
+
.subscribe(answer => {
|
|
734
|
+
this.fCtrls.answer.setValue(answer.AnswerId);
|
|
735
|
+
const groupIndex = this.fCtrls.answerArray.value.findIndex(x => x.id == answer.AnswerId);
|
|
736
|
+
if (groupIndex > -1) {
|
|
737
|
+
this.fCtrls.answerArray.at(groupIndex).controls.isSelected.setValue(true);
|
|
738
|
+
}
|
|
739
|
+
});
|
|
728
740
|
}
|
|
729
741
|
onChangeAnswer(item) {
|
|
730
742
|
this.fCtrls.answer.setValue(item.id);
|
|
@@ -732,13 +744,13 @@ class QuestionBooleanTemplateComponent {
|
|
|
732
744
|
convertToFormControl(element) {
|
|
733
745
|
return element;
|
|
734
746
|
}
|
|
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"
|
|
747
|
+
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 }); }
|
|
748
|
+
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}\">\r\n <h3 class=\"quastion-title \">\r\n {{fCtrls.title.value}}\r\n </h3>\r\n <div class=\"radio-button-quastion\">\r\n <div class=\"form-check form-check-radio form-check-inline\" \r\n *ngFor=\"let item of fCtrls.answerArray.controls ;let i = index\">\r\n <input class=\"form-check-input\" type=\"radio\" (change)=\"onChangeAnswer(item.value)\" [disabled]=\"isDisabled\"\r\n name=\"{{elemId}}__radio-btn-option\" id=\"{{elemId}}__radio-btn_{{i}}\" [checked]=\"item.value.isSelected == true? true : null\">\r\n <label class=\"form-check-label\" for=\"{{elemId}}__radio-btn_{{i}}\">{{item.value.title}}</label>\r\n </div>\r\n </div>\r\n</div>\r\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
749
|
}
|
|
738
750
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: QuestionBooleanTemplateComponent, decorators: [{
|
|
739
751
|
type: Component,
|
|
740
|
-
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: [{
|
|
752
|
+
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}\">\r\n <h3 class=\"quastion-title \">\r\n {{fCtrls.title.value}}\r\n </h3>\r\n <div class=\"radio-button-quastion\">\r\n <div class=\"form-check form-check-radio form-check-inline\" \r\n *ngFor=\"let item of fCtrls.answerArray.controls ;let i = index\">\r\n <input class=\"form-check-input\" type=\"radio\" (change)=\"onChangeAnswer(item.value)\" [disabled]=\"isDisabled\"\r\n name=\"{{elemId}}__radio-btn-option\" id=\"{{elemId}}__radio-btn_{{i}}\" [checked]=\"item.value.isSelected == true? true : null\">\r\n <label class=\"form-check-label\" for=\"{{elemId}}__radio-btn_{{i}}\">{{item.value.title}}</label>\r\n </div>\r\n </div>\r\n</div>\r\n" }]
|
|
753
|
+
}], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: SurveyLibService }]; }, propDecorators: { emitter: [{
|
|
742
754
|
type: Output
|
|
743
755
|
}], isShow: [{
|
|
744
756
|
type: Input
|
|
@@ -746,8 +758,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImpor
|
|
|
746
758
|
type: Input
|
|
747
759
|
}], setQuestion: [{
|
|
748
760
|
type: Input
|
|
749
|
-
}], setAnswer: [{
|
|
750
|
-
type: Input
|
|
751
761
|
}] } });
|
|
752
762
|
|
|
753
763
|
class FilterQuestionPipe {
|
|
@@ -764,40 +774,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImpor
|
|
|
764
774
|
}]
|
|
765
775
|
}] });
|
|
766
776
|
|
|
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
777
|
class SurveryLibComponent {
|
|
802
778
|
get fCtrls() {
|
|
803
779
|
return this.rForm.controls;
|
|
@@ -805,6 +781,9 @@ class SurveryLibComponent {
|
|
|
805
781
|
get questionTypeEnum() {
|
|
806
782
|
return QuestionTypeEnum;
|
|
807
783
|
}
|
|
784
|
+
get isFirstPage() {
|
|
785
|
+
return this.fCtrls.currentPageIndex.value == 0;
|
|
786
|
+
}
|
|
808
787
|
get isLastPage() {
|
|
809
788
|
return this.fCtrls.currentPageIndex.value == (this.surveyData?.surveyPages.length - 1);
|
|
810
789
|
}
|
|
@@ -827,6 +806,7 @@ class SurveryLibComponent {
|
|
|
827
806
|
this._surveyLibService = _surveyLibService;
|
|
828
807
|
this._formBuilder = _formBuilder;
|
|
829
808
|
this._checkRuleExpsUsecase = _checkRuleExpsUsecase;
|
|
809
|
+
this.reloadDefaultAnswerId = v4();
|
|
830
810
|
this.surveyResultEmit = new EventEmitter();
|
|
831
811
|
this.rForm = this._formBuilder.group({
|
|
832
812
|
currentPageIndex: [0],
|
|
@@ -836,17 +816,23 @@ class SurveryLibComponent {
|
|
|
836
816
|
}
|
|
837
817
|
ngOnInit() {
|
|
838
818
|
this._surveyLibService.surveyDataObsrv.subscribe(survey => {
|
|
839
|
-
this.
|
|
819
|
+
this.fCtrls.questionArray.clear();
|
|
820
|
+
this.fCtrls.ruleQuestionArray.clear();
|
|
821
|
+
this.surveyData = null;
|
|
840
822
|
if (survey != null) {
|
|
823
|
+
this.surveyData = survey;
|
|
841
824
|
this.loadQuestions(survey);
|
|
842
825
|
}
|
|
843
|
-
else {
|
|
844
|
-
this.fCtrls.questionArray.clear();
|
|
845
|
-
}
|
|
846
826
|
});
|
|
847
827
|
this._surveyLibService.surveyAnswersObsrv.subscribe(value => {
|
|
848
|
-
this.defaultAnswers =
|
|
849
|
-
|
|
828
|
+
this.defaultAnswers = [];
|
|
829
|
+
if (value != null) {
|
|
830
|
+
this.defaultAnswers = [...value.defaultAnswers];
|
|
831
|
+
this.fCtrls.currentPageIndex.setValue(value.currentpage);
|
|
832
|
+
}
|
|
833
|
+
console.log(this.reloadDefaultAnswerId);
|
|
834
|
+
this.reloadDefaultAnswerId = v4();
|
|
835
|
+
console.log(this.reloadDefaultAnswerId);
|
|
850
836
|
});
|
|
851
837
|
}
|
|
852
838
|
onPaggingNext() {
|
|
@@ -1033,15 +1019,49 @@ class SurveryLibComponent {
|
|
|
1033
1019
|
});
|
|
1034
1020
|
}
|
|
1035
1021
|
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\"
|
|
1022
|
+
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
1023
|
}
|
|
1038
1024
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: SurveryLibComponent, decorators: [{
|
|
1039
1025
|
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\"
|
|
1026
|
+
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
1027
|
}], ctorParameters: function () { return [{ type: SurveyLibService }, { type: i1.FormBuilder }, { type: CheckRuleExpsUsecase }]; }, propDecorators: { surveyResultEmit: [{
|
|
1042
1028
|
type: Output
|
|
1043
1029
|
}] } });
|
|
1044
1030
|
|
|
1031
|
+
class DefaultQuestionAnswerPipe {
|
|
1032
|
+
transform(value, questionId, reloadId) {
|
|
1033
|
+
if (value != null) {
|
|
1034
|
+
return value.find(x => x.QuestionId == questionId);
|
|
1035
|
+
}
|
|
1036
|
+
return null;
|
|
1037
|
+
}
|
|
1038
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: DefaultQuestionAnswerPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
1039
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "16.1.7", ngImport: i0, type: DefaultQuestionAnswerPipe, name: "defaultQuestionAnswer" }); }
|
|
1040
|
+
}
|
|
1041
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: DefaultQuestionAnswerPipe, decorators: [{
|
|
1042
|
+
type: Pipe,
|
|
1043
|
+
args: [{
|
|
1044
|
+
name: 'defaultQuestionAnswer'
|
|
1045
|
+
}]
|
|
1046
|
+
}] });
|
|
1047
|
+
|
|
1048
|
+
class DefaultQuestionAnswersPipe {
|
|
1049
|
+
transform(value, questionId, reloadId) {
|
|
1050
|
+
if (value != null) {
|
|
1051
|
+
return value.filter(x => x.ParentQuestionId == questionId);
|
|
1052
|
+
}
|
|
1053
|
+
return [];
|
|
1054
|
+
}
|
|
1055
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: DefaultQuestionAnswersPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
1056
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "16.1.7", ngImport: i0, type: DefaultQuestionAnswersPipe, name: "defaultQuestionAnswers" }); }
|
|
1057
|
+
}
|
|
1058
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: DefaultQuestionAnswersPipe, decorators: [{
|
|
1059
|
+
type: Pipe,
|
|
1060
|
+
args: [{
|
|
1061
|
+
name: 'defaultQuestionAnswers'
|
|
1062
|
+
}]
|
|
1063
|
+
}] });
|
|
1064
|
+
|
|
1045
1065
|
class SurveryLibModule {
|
|
1046
1066
|
static forRoot() {
|
|
1047
1067
|
return {
|