Skip to content

Commit 35341ab

Browse files
authored
A custom new page name localization string (ed.newPageName) is ignore… (#6697)
* A custom new page name localization string (ed.newPageName) is ignored when pages are added via a property grid collection editor fix #6687 * Fix unit tests * Fix unit tests
1 parent 0832d84 commit 35341ab

File tree

5 files changed

+31
-4
lines changed

5 files changed

+31
-4
lines changed

packages/survey-creator-core/src/property-grid/matrices.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ export class PropertyGridEditorMatrixPages extends PropertyGridEditorMatrix {
687687
return "name";
688688
}
689689
protected getBaseValue(prop: JsonObjectProperty): string {
690-
return "page";
690+
return editorLocalization.getString("ed.newPageName");
691691
}
692692
protected getAllowRowDragDrop(prop: JsonObjectProperty): boolean { return true; }
693693
}

packages/survey-creator-core/tests/creator-base-v1.tests.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -936,8 +936,8 @@ test("creator.onAddPanel and undo-redo manager, Bug#972", () => {
936936
});
937937

938938
test("SurveyPropertyConditionEditor, set correct locale into internal survey, Bug #953", () => {
939-
editorLocalization.currentLocale = "de";
940939
const creator = new CreatorTester();
940+
editorLocalization.currentLocale = "de";
941941
creator.JSON = {
942942
elements: [
943943
{ name: "q1", type: "text" },
@@ -955,8 +955,8 @@ test("SurveyPropertyConditionEditor, set correct locale into internal survey, Bu
955955
editorLocalization.currentLocale = "";
956956
});
957957
test("creator.onSurveyInstanceCreated, can pass ConditionEditor as model", () => {
958-
editorLocalization.currentLocale = "de";
959958
const creator = new CreatorTester();
959+
editorLocalization.currentLocale = "de";
960960
creator.JSON = {
961961
elements: [
962962
{ name: "q1", type: "text" },

packages/survey-creator-core/tests/creator-tester.ts

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ const dummyQuestion = new QuestionLinkValueModel("q1");
1010
export class CreatorTester extends SurveyCreatorModel {
1111
constructor(options: ICreatorOptions = {}, options2?: ICreatorOptions) {
1212
super(options, options2);
13+
//Reset the locale to the default one from the previous tests
14+
this.locale = "";
1315
this.autoSaveDelay = 0;
1416
this.onSurveyInstanceCreated.add((creator, options) => {
1517
options.survey.getRendererForString = (element: Base, name: string): any => {

packages/survey-creator-core/tests/property-grid/property-grid.tests.ts

+25
Original file line numberDiff line numberDiff line change
@@ -3327,6 +3327,31 @@ test("check pages editor respects onPageAdding", () => {
33273327
expect(creator.survey.pages.length).toBe(1);
33283328
settings.defaultNewSurveyJSON = savedNewJSON;
33293329
});
3330+
test("Localication and survey.pages property, Bug#6687", () => {
3331+
const deutschStrings: any = {
3332+
ed: {
3333+
newPageName: "Seite"
3334+
}
3335+
};
3336+
editorLocalization.locales["de"] = deutschStrings;
3337+
const creator = new CreatorTester();
3338+
creator.locale = "de";
3339+
creator.JSON = {};
3340+
const propertyGrid = new PropertyGridModelTester(creator.survey);
3341+
const pagesQuestion = <QuestionMatrixDynamicModel>(
3342+
propertyGrid.survey.getQuestionByName("pages")
3343+
);
3344+
const propertyEditor = new PropertyGridEditorMatrixPages();
3345+
const options = { titleActions: [], question: pagesQuestion };
3346+
propertyEditor.onGetQuestionTitleActions(creator.survey, options, creator);
3347+
const addNewPageAction = options.titleActions[0] as IAction;
3348+
3349+
expect(creator.survey.pages.length).toBe(0);
3350+
addNewPageAction.action!();
3351+
3352+
expect(creator.survey.pages.length).toBe(1);
3353+
expect(creator.survey.pages[0].name).toBe("Seite1");
3354+
});
33303355
test("panellayoutcolumns doesn't have adding button", () => {
33313356
const creator = new CreatorTester();
33323357
creator.JSON = {

packages/survey-creator-core/tests/tabs/test.tests.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1075,8 +1075,8 @@ test("The Preview Survey button text is not translated Bug#6016", (): any => {
10751075
expect(loc).toBeTruthy();
10761076
if (!loc.ed) loc.ed = {};
10771077
loc.ed.testSurveyAgain = deText;
1078-
editorLocalization.currentLocale = "en";
10791078
const creator: CreatorTester = new CreatorTester();
1079+
editorLocalization.currentLocale = "en";
10801080
expect(creator.locale).toBe("en");
10811081
const testPlugin: TabTestPlugin = <TabTestPlugin>creator.getPlugin("test");
10821082
expect(testPlugin.model).toBeFalsy();

0 commit comments

Comments
 (0)