Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
novikov82 committed Feb 27, 2024
2 parents 5d856a7 + 8d3a824 commit 0f7928b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 14 deletions.
35 changes: 21 additions & 14 deletions packages/survey-creator-core/src/question-editor/properties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,13 @@ export class SurveyQuestionProperties {
for (var i = definitions.length - 1; i >= 0; i--) {
var defItem = definitions[i];
for (var j = !!defItem.tabs ? defItem.tabs.length - 1 : -1; j >= 0; j--) {
if (addedProperties.indexOf(defItem.tabs[j].name) > -1) continue;
if (this.addPropertyIntoTab(defItem.tabs[j], true)) {
addedProperties.push(defItem.tabs[j].name);
const defTab = defItem.tabs[j];
if (addedProperties.indexOf(defTab.name) > -1) {
this.setTabProperties(defTab);
} else {
if (this.addPropertyIntoTab(defTab, true)) {
addedProperties.push(defTab.name);
}
}
}
for (
Expand Down Expand Up @@ -184,17 +188,7 @@ export class SurveyQuestionProperties {
isTab: boolean = false
): boolean {
if (isTab) {
let tab = this.getTabOrCreate(defProperty.name);
if (defProperty.index > 0) {
tab.index = defProperty.index;
}
tab.parentName = defProperty.parent;
if (defProperty.visible === false) {
tab.visible = false;
}
if (!!defProperty.title) {
tab.title = defProperty.title;
}
this.setTabProperties(defProperty);
}
var isString = typeof defProperty == "string";
var name = !isString ? defProperty.name : defProperty;
Expand Down Expand Up @@ -222,6 +216,19 @@ export class SurveyQuestionProperties {
tab.properties.unshift(propertyDefinition);
return true;
}
private setTabProperties(defProperty: any): void {
let tab = this.getTabOrCreate(defProperty.name);
if (defProperty.index > 0) {
tab.index = defProperty.index;
}
tab.parentName = defProperty.parent;
if (defProperty.visible === false) {
tab.visible = false;
}
if (!!defProperty.title) {
tab.title = defProperty.title;
}
}
private movePropertiesToNextProperties(
properties: Array<SurveyQuestionEditorPropertyDefinition>
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3197,4 +3197,19 @@ test("Set property name into correct category", () => {
expect(validationQuestion.name).toEqual("validation");
expect(validationQuestion.parent.name).toEqual("general");
Serializer.removeProperty("question", "validation");
});
test("Set correct property grid category", () => {
Serializer.addProperty("question", {
name: "validation",
category: "cust_category",
categoryIndex: 1
});
const creator = new CreatorTester();
creator.JSON = { elements: [{ type: "text", name: "q1" }] };
const q = creator.survey.getQuestionByName("q1");
const propertyGrid = new PropertyGridModelTester(q);
const panel = propertyGrid.survey.getPanelByName("cust_category");
expect(panel).toBeTruthy();
expect(propertyGrid.survey.getAllPanels().indexOf(panel)).toEqual(1);
Serializer.removeProperty("question", "validation");
});

0 comments on commit 0f7928b

Please sign in to comment.