Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
OlgaLarina committed Feb 7, 2025
1 parent 03f78dc commit 76a7c37
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,7 @@ export class PropertyGridViewModel extends Base {
let titleName = this.getTitle();
this.selectedElementName = titleName;
this.objectSelectionAction.tooltip = titleName;
if (!this.propertyGridModel.showOneCategoryInPropertyGrid) {
this.objectSelectionAction.title = titleName;
}
this.objectSelectionAction.title = this.propertyGridModel.showOneCategoryInPropertyGrid ? "" : titleName;
}
private getTitle(): string {
var obj = this.getSelectedObj();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { settings } from "../../src/creator-settings";

test("Generate and update title correctly", () => {
const creator = new CreatorTester();
creator.showOneCategoryInPropertyGrid = false;
creator.JSON = {
elements: [
{
Expand All @@ -41,6 +42,27 @@ test("Generate and update title correctly", () => {
propertyGrid.survey.getQuestionByName("name").value = "Q2";
expect(model.objectSelectionAction.title).toEqual("Question:Q2");
});
test("showOneCategoryInPropertyGrid: Generate and update title correctly", () => {
const creator = new CreatorTester();
creator.JSON = { elements: [{ type: "text", name: "question1" }] };
const propertyGrid = creator["designerPropertyGrid"];
const model = new PropertyGridViewModel(propertyGrid, creator);
expect(model.objectSelectionAction.tooltip).toEqual("Survey");
propertyGrid.obj = creator.survey.getQuestionByName("question1");
expect(model.objectSelectionAction.tooltip).toEqual("question1");
propertyGrid.survey.getQuestionByName("name").value = "Q1";
expect(model.objectSelectionAction.tooltip).toEqual("Q1");
propertyGrid.options.getObjectDisplayName = (
obj: Base,
area: string,
reason: string,
displayName: string
) => {
return "Question:" + obj["name"];
};
propertyGrid.survey.getQuestionByName("name").value = "Q2";
expect(model.objectSelectionAction.tooltip).toEqual("Question:Q2");
});
test("Prev/next correctly, including columns via actions", () => {
const creator = new CreatorTester();
creator.propertyGridNavigationMode = "accordion";
Expand Down
15 changes: 0 additions & 15 deletions packages/survey-creator-core/tests/side-bar.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,19 +229,4 @@ test("Toggle for Creator Settings", () => {
expect(tabs[0].active).toBe(true);
expect(creatorSettingAction.active).toBe(false);
expect(creator.sidebar.activePage).toEqual("propertyGrid");
});

test("showOneCategoryInPropertyGrid: update objectSelectionAction title, after rename question", () => {
const creator = new CreatorTester();
const designerPlugin = creator.getPlugin("designer") as TabDesignerPlugin;
expect(creator.sidebar.activePage).toEqual("propertyGridPlaceholder");

creator.clickToolboxItem({ type: "text" });
expect(creator.sidebar.activePage).toEqual("propertyGrid");
expect(designerPlugin.propertyGridViewModel.objectSelectionAction.title).toEqual("General");
expect(designerPlugin.propertyGridViewModel.objectSelectionAction.tooltip).toEqual("question1");

designerPlugin.propertyGridViewModel.survey.findQuestionByName("name").value = "q1";
expect(designerPlugin.propertyGridViewModel.objectSelectionAction.title).toEqual("General");
expect(designerPlugin.propertyGridViewModel.objectSelectionAction.tooltip).toEqual("q1");
});

0 comments on commit 76a7c37

Please sign in to comment.