Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Grid layout columns" editor: Hide the "Add" button instead of disabl… #6517

Merged
merged 2 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/survey-creator-core/src/property-grid/matrices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ export abstract class PropertyGridEditorMatrix extends PropertyGridEditor {
protected addItem(creator: ISurveyCreatorOptions, obj: Base, question: QuestionMatrixDynamicModel) {
question.addRow();
}
protected getHasAddButton(): boolean { return true; }
public onGetQuestionTitleActions(obj: Base, options: any, creator: ISurveyCreatorOptions): void {
if(!this.getHasAddButton()) return;
const question: QuestionMatrixDynamicModel = options.question;
options.titleActions.push({
id: "add-item",
Expand Down Expand Up @@ -655,7 +657,7 @@ export class PropertyGridEditorMatrixLayoutColumns extends PropertyGridEditorMat
const q = options.cellQuestion;
q.textUpdateMode = "onTyping";
}

protected getHasAddButton(): boolean { return false; }
public onCreated(obj: Base, question: Question, prop: JsonObjectProperty, options?: ISurveyCreatorOptions, propGridDefinition?: ISurveyPropertyGridDefinition) {
super.onCreated(obj, question, prop, options, propGridDefinition);
const matrixQuestion = <QuestionMatrixDynamicModel>question;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3323,6 +3323,22 @@ test("check pages editor respects onPageAdding", () => {
expect(creator.survey.pages.length).toBe(1);
settings.defaultNewSurveyJSON = savedNewJSON;
});
test("panellayoutcolumns doesn't have adding button", () => {
const creator = new CreatorTester();
creator.JSON = {
gridLayoutEnabled: true,
elements: [{ type: "text", name: "q1" }]
};
const propertyGrid = new PropertyGridModelTester(creator.survey.pages[0]);
const gridColumnsQuestion = <QuestionMatrixDynamicModel>(propertyGrid.survey.getQuestionByName("gridLayoutColumns"));
expect(gridColumnsQuestion).toBeTruthy();
expect(gridColumnsQuestion.allowAddRows).toBeFalsy();
expect(gridColumnsQuestion.getTitleToolbar()).toBeTruthy();
const helpButton = gridColumnsQuestion.titleActions.find(a => a.id === "property-grid-help");
const addButton = gridColumnsQuestion.titleActions.find(a => a.id === "add-item");
expect(helpButton).toBeTruthy();
expect(addButton).toBeFalsy();
});
test("Set property name into correct category", () => {
Serializer.addProperty("question", {
name: "validation",
Expand Down