Skip to content

Commit

Permalink
Fixed file question properties visibility
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tsv2013 committed Oct 19, 2023
1 parent 5ca363d commit f64eec8
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 f64eec8

Please sign in to comment.