Skip to content

Commit

Permalink
Merge pull request #7194 from surveyjs/bug/file-properties
Browse files Browse the repository at this point in the history
Fixed file question properties visibility
  • Loading branch information
dk981234 authored Oct 19, 2023
2 parents 33512c9 + f64eec8 commit 08cf2d0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/question_file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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 () {
Expand Down
11 changes: 11 additions & 0 deletions tests/questionFileTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

0 comments on commit 08cf2d0

Please sign in to comment.