Skip to content

Commit

Permalink
Api/9291 prop showmode (#9292)
Browse files Browse the repository at this point in the history
* Rename the showMode property fix #3607

* Include correct issue id, fix #9291

* Add default value for displayMode attribute
  • Loading branch information
andrewtelnov authored Jan 14, 2025
1 parent 5a903db commit 25ded7a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
13 changes: 12 additions & 1 deletion packages/survey-core/src/jsonobject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ export interface IJsonPropertyInfo {
visibleIndex?: number;
nextToProperty?: string;
overridingProperty?: string;
displayMode?: string;
showMode?: string;
maxLength?: number;
maxValue?: any;
Expand Down Expand Up @@ -272,6 +273,7 @@ export class JsonObjectProperty implements IObject, IJsonPropertyInfo {
"nextToProperty",
"overridingProperty",
"showMode",
"displayMode",
"dependedProperties",
"visibleIf",
"enableIf",
Expand Down Expand Up @@ -314,7 +316,13 @@ export class JsonObjectProperty implements IObject, IJsonPropertyInfo {
public visibleIndex: number = -1;
public nextToProperty: string;
public overridingProperty: string;
public showMode: string;
public displayMode: string = "column";
public get showMode(): string {
return this.displayMode;
}
public set showMode(val: string) {
this.displayMode = val;
}
public availableInMatrixColumn: boolean;
public maxLength: number = -1;
public maxValue: any;
Expand Down Expand Up @@ -921,6 +929,9 @@ export class JsonMetadataClass {
if (!Helpers.isValueEmpty(propInfo.showMode)) {
prop.showMode = propInfo.showMode;
}
if (!Helpers.isValueEmpty(propInfo.displayMode)) {
prop.displayMode = propInfo.displayMode;
}
if (!Helpers.isValueEmpty(propInfo.maxValue)) {
prop.maxValue = propInfo.maxValue;
}
Expand Down
21 changes: 20 additions & 1 deletion packages/survey-core/tests/surveyserializationtests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -848,4 +848,23 @@ QUnit.test("An infinitive loop occurs at e.removePosFromObj Bug#8224", function
Serializer.removeClass("exampleComponentQuestion");
Serializer.removeClass("exampleOptions");
ComponentCollection.Instance.clear();
});
});
QUnit.test("property showMode -> displayMode, #9291", function (assert) {
Serializer.addProperty("question", { name: "prop1", showMode: "form" });
Serializer.addProperty("question", { name: "prop2", displayMode: "form" });
Serializer.addProperty("question", { name: "prop3" });

const prop1 = Serializer.findProperty("question", "prop1");
const prop2 = Serializer.findProperty("question", "prop2");
const prop3 = Serializer.findProperty("question", "prop3");
assert.equal(prop1.showMode, "form", "prop1.showMode");
assert.equal(prop1.displayMode, "form", "prop1.displayMode");
assert.equal(prop2.showMode, "form", "prop2.showMode");
assert.equal(prop2.displayMode, "form", "prop2.displayMode");
assert.equal(prop3.showMode, "column", "prop3.showMode");
assert.equal(prop3.displayMode, "column", "prop3.displayMode");

Serializer.removeProperty("question", "prop1");
Serializer.removeProperty("question", "prop2");
Serializer.removeProperty("question", "prop3");
});

0 comments on commit 25ded7a

Please sign in to comment.