From f64eec866a0f9dd6c17e0cdff0a3032ed531cf33 Mon Sep 17 00:00:00 2001 From: tsv2013 Date: Thu, 19 Oct 2023 15:05:47 +0300 Subject: [PATCH] Fixed file question properties visibility Fixed #7192 - File Upload: The "Preview images" checkbox should be visible only if the "Show preview area" checkbox is selected Fixed #7193 - File Upload: Hide "Allow camera access" from Property Grid --- src/question_file.ts | 11 +++++++++-- tests/questionFileTests.ts | 11 +++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/question_file.ts b/src/question_file.ts index aca2db6ee2..39a31b6e09 100644 --- a/src/question_file.ts +++ b/src/question_file.ts @@ -989,7 +989,14 @@ Serializer.addClass( { name: "showCommentArea:switch", layout: "row", visible: true, category: "general" }, { name: "showPreview:boolean", default: true }, "allowMultiple:boolean", - { name: "allowImagesPreview:boolean", default: true }, + { + name: "allowImagesPreview:boolean", + default: true, + dependsOn: "showPreview", + visibleIf: (obj: any) => { + return !!obj.showPreview; + }, + }, "imageHeight", "imageWidth", "acceptedTypes", @@ -1000,7 +1007,7 @@ Serializer.addClass( { name: "correctAnswer", visible: false }, { name: "validators", visible: false }, { name: "needConfirmRemoveFile:boolean" }, - { name: "allowCameraAccess:switch", category: "general" }, + { name: "allowCameraAccess:switch", category: "general", visible: false }, { name: "sourceType", choices: ["file", "camera", "file-camera"], default: "file", category: "general", visible: true } ], function () { diff --git a/tests/questionFileTests.ts b/tests/questionFileTests.ts index 8426e1b28d..bd33320a03 100644 --- a/tests/questionFileTests.ts +++ b/tests/questionFileTests.ts @@ -1682,4 +1682,15 @@ QUnit.test("QuestionFile check renderedPlaceholder in different modes", function assert.equal(q1.renderedPlaceholder, "camera_mod_placeholder"); q1.setPropertyValue("currentMode", "file-camera"); assert.equal(q1.renderedPlaceholder, "both_mod_placeholder"); +}); +QUnit.test("QuestionFile allowImagesPreview and allowCameraAccess", function (assert) { + const prop1 = Serializer.getProperty("file", "allowImagesPreview"); + assert.deepEqual(Serializer.getProperty("file", "showPreview").getDependedProperties(), [prop1.name]); + const q1 = new QuestionFileModel("q1"); + q1.showPreview = true; + assert.equal(prop1.isVisible(undefined, q1), true); + q1.showPreview = false; + assert.equal(prop1.isVisible(undefined, q1), false); + const prop2 = Serializer.getProperty("file", "allowCameraAccess"); + assert.equal(prop2.visible, false); }); \ No newline at end of file