survery-lib 2.1.52 → 2.1.54
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/esm2022/lib/components/question-file-template/question-file-template.component.mjs +15 -3
- package/esm2022/lib/core/states/survey-store/question.selector.mjs +2 -2
- package/esm2022/lib/core/states/survey-store/survey.reducer.mjs +3 -4
- 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/services/survey-lib.service.mjs +19 -19
- package/esm2022/shared/dtos/default-question-answers.dto.mjs +1 -1
- package/esm2022/shared/dtos/survey-answer.dto.mjs +1 -1
- package/esm2022/shared/form-interfaces/question-file-template.form-interface.mjs +1 -1
- package/fesm2022/survery-lib.mjs +37 -26
- package/fesm2022/survery-lib.mjs.map +1 -1
- package/package.json +1 -1
- package/shared/dtos/default-question-answers.dto.d.ts +8 -8
- package/shared/dtos/survey-answer.dto.d.ts +1 -0
- package/shared/form-interfaces/question-file-template.form-interface.d.ts +1 -0
package/fesm2022/survery-lib.mjs
CHANGED
|
@@ -167,7 +167,7 @@ const questionAnswers = createSelector(selectSurveyData, (state) => selectAll$1(
|
|
|
167
167
|
AnswerText: answerText,
|
|
168
168
|
AnswerIdArr: x.answerIdArr,
|
|
169
169
|
AnswerLevelId: x.answerLevelId,
|
|
170
|
-
AnswerFile: x.answerFile
|
|
170
|
+
AnswerFile: x.answerFile?.map(x => ({ byteArr: x.byteArr, name: x.name, id: x.id })),
|
|
171
171
|
PassedRuleQuestionId: x.passedRuleQuestionId
|
|
172
172
|
};
|
|
173
173
|
}
|
|
@@ -282,42 +282,42 @@ class SurveyLibService {
|
|
|
282
282
|
}
|
|
283
283
|
setsurveyAnswers(model) {
|
|
284
284
|
model.defaultAnswers.forEach(answer => {
|
|
285
|
-
if (answer.
|
|
286
|
-
answer.
|
|
285
|
+
if (answer.questionType == QuestionTypeEnum.TextInput ||
|
|
286
|
+
answer.questionType == QuestionTypeEnum.FeedBack) {
|
|
287
287
|
this._Store.dispatch(surveyActions.updateQuestionAnswer({
|
|
288
|
-
questionId: answer.
|
|
289
|
-
answer: answer.
|
|
288
|
+
questionId: answer.questionId,
|
|
289
|
+
answer: answer.answerText,
|
|
290
290
|
isValid: true
|
|
291
291
|
}));
|
|
292
292
|
}
|
|
293
|
-
else if (answer.
|
|
293
|
+
else if (answer.questionType == QuestionTypeEnum.File) {
|
|
294
294
|
this._Store.dispatch(surveyActions.updateQuestionFileAnswer({
|
|
295
|
-
questionId: answer.
|
|
296
|
-
fileArr: answer.
|
|
295
|
+
questionId: answer.questionId,
|
|
296
|
+
fileArr: answer.fileArr.map(x => ({ byteArr: null, name: x.name, id: x.id })),
|
|
297
297
|
isValid: true
|
|
298
298
|
}));
|
|
299
299
|
}
|
|
300
|
-
else if (answer.
|
|
301
|
-
|| answer.
|
|
300
|
+
else if (answer.questionType == QuestionTypeEnum.CheckBox
|
|
301
|
+
|| answer.questionType == QuestionTypeEnum.DropDownMulti) {
|
|
302
302
|
this._Store.dispatch(surveyActions.updateQuestionAnswer({
|
|
303
|
-
questionId: answer.
|
|
304
|
-
answer: answer.
|
|
303
|
+
questionId: answer.questionId,
|
|
304
|
+
answer: answer.answerIdArr,
|
|
305
305
|
isValid: true
|
|
306
306
|
}));
|
|
307
307
|
}
|
|
308
|
-
else if (answer.
|
|
308
|
+
else if (answer.questionType == QuestionTypeEnum.Institutions) {
|
|
309
309
|
this._Store.dispatch(surveyActions.updateInstitutionQuestionAnswer({
|
|
310
|
-
questionId: answer.
|
|
311
|
-
answer: answer.
|
|
312
|
-
answerId: answer.
|
|
313
|
-
answerLevelId: answer.
|
|
310
|
+
questionId: answer.questionId,
|
|
311
|
+
answer: answer.answerText,
|
|
312
|
+
answerId: answer.answerId,
|
|
313
|
+
answerLevelId: answer.answerLevelId,
|
|
314
314
|
isValid: true
|
|
315
315
|
}));
|
|
316
316
|
}
|
|
317
317
|
else {
|
|
318
318
|
this._Store.dispatch(surveyActions.updateQuestionAnswer({
|
|
319
|
-
questionId: answer.
|
|
320
|
-
answer: answer.
|
|
319
|
+
questionId: answer.questionId,
|
|
320
|
+
answer: answer.answerId,
|
|
321
321
|
isValid: true
|
|
322
322
|
}));
|
|
323
323
|
}
|
|
@@ -2305,7 +2305,8 @@ class QuestionFileTemplateComponent {
|
|
|
2305
2305
|
typeId: value.questionAllInfo.questionTypeId,
|
|
2306
2306
|
description: value.questionAllInfo.questionDescription,
|
|
2307
2307
|
isDisabled: value.questionAllInfo.isReadOnly,
|
|
2308
|
-
isShow: value.questionAllInfo.isVisable
|
|
2308
|
+
isShow: value.questionAllInfo.isVisable,
|
|
2309
|
+
numberOfFiles: value.questionAllInfo.surveyAnswers[0]?.numberOfFiles
|
|
2309
2310
|
});
|
|
2310
2311
|
if (value.isShow == true) {
|
|
2311
2312
|
this.fCtrls.isShow.setValue(value.isShow);
|
|
@@ -2323,7 +2324,7 @@ class QuestionFileTemplateComponent {
|
|
|
2323
2324
|
this.fCtrls.fileArr.updateValueAndValidity();
|
|
2324
2325
|
}
|
|
2325
2326
|
var question = this.questionArr().find(x => x.questionId == value.questionId);
|
|
2326
|
-
if (question?.
|
|
2327
|
+
if (question?.answerFile) {
|
|
2327
2328
|
this.rForm.patchValue({
|
|
2328
2329
|
fileArr: question.answerFile.map(x => ({ fileBase64: null, name: x.name, byteArr: null, id: x.id })),
|
|
2329
2330
|
isDisabled: question.isDisabled,
|
|
@@ -2351,6 +2352,7 @@ class QuestionFileTemplateComponent {
|
|
|
2351
2352
|
isShow: new FormControl(true),
|
|
2352
2353
|
isMultiple: new FormControl(false),
|
|
2353
2354
|
acceptedTypes: new FormControl(''),
|
|
2355
|
+
numberOfFiles: new FormControl(null)
|
|
2354
2356
|
});
|
|
2355
2357
|
}
|
|
2356
2358
|
ngOnInit() {
|
|
@@ -2390,6 +2392,16 @@ class QuestionFileTemplateComponent {
|
|
|
2390
2392
|
}
|
|
2391
2393
|
onFileSelect(event) {
|
|
2392
2394
|
const input = event.target;
|
|
2395
|
+
if (input.files && input.files.length > this.fCtrls.numberOfFiles.value) {
|
|
2396
|
+
if (this.isArabicLang) {
|
|
2397
|
+
alert(`يمكنك تحميل ما يصل إلى ${this.fCtrls.numberOfFiles.value} ملفات فقط.`);
|
|
2398
|
+
}
|
|
2399
|
+
else {
|
|
2400
|
+
alert(`You can only upload up to ${this.fCtrls.numberOfFiles.value} files.`);
|
|
2401
|
+
}
|
|
2402
|
+
this.fileInputRef.nativeElement.value = '';
|
|
2403
|
+
return;
|
|
2404
|
+
}
|
|
2393
2405
|
if (input.files && input.files.length > 0) {
|
|
2394
2406
|
this.fCtrls.fileArr.setValue([]);
|
|
2395
2407
|
for (let index = 0; index < input.files.length; index++) {
|
|
@@ -2625,7 +2637,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImpor
|
|
|
2625
2637
|
class DefaultQuestionAnswerPipe {
|
|
2626
2638
|
transform(value, questionId, reloadId) {
|
|
2627
2639
|
if (value != null) {
|
|
2628
|
-
return value.find(x => x.
|
|
2640
|
+
return value.find(x => x.questionId == questionId);
|
|
2629
2641
|
}
|
|
2630
2642
|
return null;
|
|
2631
2643
|
}
|
|
@@ -2642,7 +2654,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImpor
|
|
|
2642
2654
|
class DefaultQuestionAnswersPipe {
|
|
2643
2655
|
transform(value, questionId, reloadId) {
|
|
2644
2656
|
if (value != null) {
|
|
2645
|
-
return value.filter(x => x.
|
|
2657
|
+
return value.filter(x => x.parentQuestionId == questionId);
|
|
2646
2658
|
}
|
|
2647
2659
|
return [];
|
|
2648
2660
|
}
|
|
@@ -2721,14 +2733,13 @@ const _surveyReducer = createReducer(initialSurveyState, on(surveyActions.loadSu
|
|
|
2721
2733
|
}), on(surveyActions.updateQuestionFileAnswer, (state, props) => {
|
|
2722
2734
|
const question = selectAll(state.questionArr).find(x => x.questionId == props.questionId);
|
|
2723
2735
|
if (question) {
|
|
2724
|
-
var updateModel;
|
|
2725
2736
|
if (question.questionType == QuestionTypeEnum.File) {
|
|
2726
|
-
updateModel = {
|
|
2737
|
+
var updateModel = {
|
|
2727
2738
|
id: props.questionId,
|
|
2728
2739
|
changes: {
|
|
2729
2740
|
answerId: question.questionAllInfo.surveyAnswers[0].answerId,
|
|
2730
2741
|
answerText: null,
|
|
2731
|
-
answerFile: props.fileArr
|
|
2742
|
+
answerFile: props.fileArr?.map(x => ({ byteArr: x.byteArr, name: x.name, id: x.id })),
|
|
2732
2743
|
isValid: props.isValid
|
|
2733
2744
|
}
|
|
2734
2745
|
};
|