From e04d0a62b9a5e782aa81635dd8a166d73d5050f6 Mon Sep 17 00:00:00 2001 From: Andrew Telnov Date: Sun, 2 Jul 2023 18:50:25 +0300 Subject: [PATCH 1/2] Add supportCamera boolean property into file question #6463 --- .../src/questions/file.component.html | 1 + src/knockout/templates/question-file.html | 2 +- src/question_file.ts | 5 +++++ src/react/reactquestion_file.tsx | 1 + src/vue/file.vue | 1 + tests/markup/etalon_file.ts | 15 +++++++++++++++ tests/markup/snapshots/file-camera.snap.html | 14 ++++++++++++++ 7 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 tests/markup/snapshots/file-camera.snap.html diff --git a/packages/survey-angular-ui/src/questions/file.component.html b/packages/survey-angular-ui/src/questions/file.component.html index 25840b5878..20840bb9ee 100644 --- a/packages/survey-angular-ui/src/questions/file.component.html +++ b/packages/survey-angular-ui/src/questions/file.component.html @@ -13,6 +13,7 @@ [attr.multiple]="model.multipleRendered" [attr.title]="model.inputTitle" [attr.accept]="model.acceptedTypes" + [attr.capture]="model.renderCapture" />
- + diff --git a/src/question_file.ts b/src/question_file.ts index bfee5f1417..533d1b6702 100644 --- a/src/question_file.ts +++ b/src/question_file.ts @@ -40,6 +40,7 @@ export class QuestionFileModel extends Question { @property({ defaultValue: 0 }) indexToShow: number; @property({ defaultValue: false }) containsMultiplyFiles: boolean; + @property() supportCamera: boolean; public mobileFileNavigator: ActionContainer = new ActionContainer(); protected prevFileAction: Action; @@ -240,6 +241,9 @@ export class QuestionFileModel extends Question { } ); } + public get renderCapture(): string { + return this.supportCamera ? "camera" : undefined; + } get multipleRendered() { return this.allowMultiple ? "multiple" : undefined; @@ -608,6 +612,7 @@ Serializer.addClass( { name: "correctAnswer", visible: false }, { name: "validators", visible: false }, { name: "needConfirmRemoveFile:boolean" }, + { name: "supportCamera:switch", visible: false } ], function () { return new QuestionFileModel(""); diff --git a/src/react/reactquestion_file.tsx b/src/react/reactquestion_file.tsx index 823fcab433..0de7aacfa3 100644 --- a/src/react/reactquestion_file.tsx +++ b/src/react/reactquestion_file.tsx @@ -56,6 +56,7 @@ export class SurveyQuestionFile extends SurveyQuestionElementBase { multiple={this.question.allowMultiple} title={this.question.inputTitle} accept={this.question.acceptedTypes} + capture={this.question.renderCapture} /> ); return ( diff --git a/src/vue/file.vue b/src/vue/file.vue index 2943f8fa82..51778c741c 100644 --- a/src/vue/file.vue +++ b/src/vue/file.vue @@ -14,6 +14,7 @@ :multiple="question.multipleRendered" v-bind:title="question.inputTitle" v-bind:accept="question.acceptedTypes" + :capture="question.renderCapture" /> + +
+
+ Drag and drop a file here or click the button below and choose a file to upload. +
+ + No file chosen +
+
+
+
\ No newline at end of file From b555cbcf3ecc4151ef97d50d714be65f5430df24 Mon Sep 17 00:00:00 2001 From: Andrew Telnov Date: Mon, 3 Jul 2023 15:25:41 +0300 Subject: [PATCH 2/2] Change property name #6463 --- src/question_file.ts | 6 +++--- tests/markup/etalon_file.ts | 2 +- tests/markup/snapshots/file-camera.snap.html | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/question_file.ts b/src/question_file.ts index 533d1b6702..48b7e2eec1 100644 --- a/src/question_file.ts +++ b/src/question_file.ts @@ -40,7 +40,7 @@ export class QuestionFileModel extends Question { @property({ defaultValue: 0 }) indexToShow: number; @property({ defaultValue: false }) containsMultiplyFiles: boolean; - @property() supportCamera: boolean; + @property() allowCameraAccess: boolean; public mobileFileNavigator: ActionContainer = new ActionContainer(); protected prevFileAction: Action; @@ -242,7 +242,7 @@ export class QuestionFileModel extends Question { ); } public get renderCapture(): string { - return this.supportCamera ? "camera" : undefined; + return this.allowCameraAccess ? "user" : undefined; } get multipleRendered() { @@ -612,7 +612,7 @@ Serializer.addClass( { name: "correctAnswer", visible: false }, { name: "validators", visible: false }, { name: "needConfirmRemoveFile:boolean" }, - { name: "supportCamera:switch", visible: false } + { name: "allowCameraAccess:switch", category: "general" } ], function () { return new QuestionFileModel(""); diff --git a/tests/markup/etalon_file.ts b/tests/markup/etalon_file.ts index c9a4b5e0bd..fa51d06328 100644 --- a/tests/markup/etalon_file.ts +++ b/tests/markup/etalon_file.ts @@ -518,7 +518,7 @@ registerMarkupTests( type: "file", title: "Question title", titleLocation: "hidden", - supportCamera: true + allowCameraAccess: true } ] }, diff --git a/tests/markup/snapshots/file-camera.snap.html b/tests/markup/snapshots/file-camera.snap.html index 40930aff25..d92a14ddb1 100644 --- a/tests/markup/snapshots/file-camera.snap.html +++ b/tests/markup/snapshots/file-camera.snap.html @@ -1,5 +1,5 @@
- +
Drag and drop a file here or click the button below and choose a file to upload.