Skip to content

Commit

Permalink
Make sure survey in PropertyGridViewModel is not undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtelnov committed Feb 18, 2025
1 parent 21d0ae3 commit 0c60dd9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export class PropertyGridViewModel extends Base {

@property() hasPrev: boolean;
@property() hasNext: boolean;
@property() survey: SurveyModel;
@property() selectedElementName: string;
@property({
onSet: (newValue: boolean, target: PropertyGridViewModel) => {
Expand Down Expand Up @@ -52,7 +51,12 @@ export class PropertyGridViewModel extends Base {
});
this.onSurveyObjChanged();
}

public get survey(): SurveyModel {
return this.getPropertyValue("survey", undefined, () => this.propertyGridModel.survey);
}
public set survey(val: SurveyModel) {
this.setPropertyValue("survey", val);
}
public get rootCss(): string {
return new CssClassBuilder()
.append("spg-container")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,11 @@ test("Check object selector popup's display mode", () => {
model = new PropertyGridViewModel(propertyGrid, creator);
expect(model.objectSelectionAction.popupModel.displayMode).toEqual("overlay");
_setIsTouch(false);
});
test("Create the property grid survey on request", () => {
const creator = new CreatorTester();
const propertyGrid = creator["designerPropertyGrid"];
const model = new PropertyGridViewModel(propertyGrid, creator);
expect(model.getPropertyValue("survey")).toBeFalsy();
expect(model.survey).toBeTruthy();
});

0 comments on commit 0c60dd9

Please sign in to comment.