Skip to content

Commit c05a3e8

Browse files
committed
Refactor image picker choices editor
1 parent c07852b commit c05a3e8

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

packages/survey-creator-core/src/property-grid/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ export class PropertyJSONGenerator {
624624
const propName = this.getClasPropName();
625625
if (!!propName) {
626626
className = this.obj.getType();
627-
if (this.obj.isDescendantOf("itemvalue") && className !== "imageitemvalue") className += "[]";
627+
if (this.obj.isDescendantOf("itemvalue")) className += "[]";
628628
className += "@" + propName;
629629
}
630630
var properties = new SurveyQuestionProperties(this.obj, null,

packages/survey-creator-core/src/question-editor/definition.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,9 @@ const defaultProperties: ISurveyPropertiesDefinition = {
369369
properties: [{ name: "visibleIf" }, { name: "enableIf" }],
370370
tabs: [{ name: "general" }]
371371
},
372+
"imageitemvalue[]@choices": {
373+
properties: ["value", "text", "visibleIf", "enableIf", "imageLink"]
374+
},
372375
"itemvalue[]@rows": {
373376
properties: [{ name: "visibleIf" }, { name: "enableIf" }],
374377
tabs: [{ name: "general" }]

packages/survey-creator-core/tests/property-grid/property-grid-matrices.tests.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import {
33
QuestionMatrixModel, QuestionMultipleTextModel, QuestionRatingModel, QuestionTextModel, QuestionBooleanModel, Serializer, SurveyModel,
44
SurveyTriggerRunExpression, UrlConditionItem, settings as surveySettings,
55
ItemValue,
6-
QuestionCheckboxModel
6+
QuestionCheckboxModel,
7+
QuestionImagePickerModel
78
} from "survey-core";
89
import { PropertyGridModelTester } from "./property-grid.base";
910
import { PropertyGridEditorMatrixMutlipleTextItems } from "../../src/property-grid/matrices";
@@ -470,6 +471,24 @@ test("QuestionCheckbox choices placeholder", () => {
470471
row.getQuestionByName("value").value = "item111";
471472
expect(row.getQuestionByName("text").placeholder).toBe("item111");
472473
});
474+
test("ImagePicker choices columns & detail panel", () => {
475+
const question = new QuestionImagePickerModel("q1");
476+
question.choices = ["item1"];
477+
var propertyGrid = new PropertyGridModelTester(question);
478+
var choicesQuestion = <QuestionMatrixDynamicModel>(
479+
propertyGrid.survey.getQuestionByName("choices")
480+
);
481+
expect(choicesQuestion).toBeTruthy();
482+
expect(choicesQuestion.columns).toHaveLength(3);
483+
expect(choicesQuestion.columns[0].name).toBe("value");
484+
expect(choicesQuestion.columns[1].name).toBe("text");
485+
expect(choicesQuestion.columns[2].name).toBe("imageLink");
486+
const row = choicesQuestion.visibleRows[0];
487+
row.showDetailPanel();
488+
expect(row.detailPanel.questions).toHaveLength(5);
489+
const imageLinkQuestion = row.detailPanel.getQuestionByName("imageLink");
490+
expect(imageLinkQuestion).toBeTruthy();
491+
});
473492
test("Triggers property editor, Bug #4454", () => {
474493
var survey = new SurveyModel();
475494
const completeTrigger = new SurveyTriggerComplete();

0 commit comments

Comments
 (0)