Skip to content

Commit 5110781

Browse files
committed
2 parents 0648fdb + 45ddeb9 commit 5110781

File tree

26 files changed

+199
-43
lines changed

26 files changed

+199
-43
lines changed

legacy-pipelines/build-packages.yml

+10-10
Original file line numberDiff line numberDiff line change
@@ -342,16 +342,16 @@ jobs:
342342
# read about the problem with git output ($env:GIT_REDIRECT_STDERR = '2>&1') :
343343
# https://github.com/microsoft/azure-pipelines-yaml/issues/248
344344
# https://stackoverflow.com/questions/58485585/azure-pipeline-powershell-and-git-on-windows-server-2019-gives-error-in-output
345-
- powershell: |
346-
cd $(Build.SourcesDirectory)/service
347-
git pull origin master
348-
git fetch origin master --tags --force
349-
git checkout master
350-
git add surveyjs.io/App_Data/DocsEditor
351-
git commit -m "updated survey-creator docs [azurepipelines skip]"
352-
git pull origin master
353-
git push origin master
354-
displayName: "Git surveyjs/service push updated docs"
345+
# - powershell: |
346+
# cd $(Build.SourcesDirectory)/service
347+
# git pull origin master
348+
# git fetch origin master --tags --force
349+
# git checkout master
350+
# git add surveyjs.io/App_Data/DocsEditor
351+
# git commit -m "updated survey-creator docs [azurepipelines skip]"
352+
# git pull origin master
353+
# git push origin master
354+
# displayName: "Git surveyjs/service push updated docs"
355355

356356
- job: CreatorV2React
357357
dependsOn: CreatorV2Core

packages/survey-creator-angular/CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5+
### [1.12.26](https://github.com/surveyjs/survey-creator/compare/v1.12.25...v1.12.26) (2025-03-04)
6+
57
### [1.12.25](https://github.com/surveyjs/survey-creator/compare/v1.12.24...v1.12.25) (2025-02-25)
68

79
### [1.12.24](https://github.com/surveyjs/survey-creator/compare/v1.12.23...v1.12.24) (2025-02-20)

packages/survey-creator-angular/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "survey-creator-angular",
3-
"version": "1.12.25",
3+
"version": "1.12.26",
44
"description": "Use SurveyJS Creator to create or edit JSON for SurveyJS Form Library.",
55
"homepage": "https://surveyjs.io/Overview/Survey-Creator",
66
"license": "https://surveyjs.io/Licenses#SurveyCreator",

packages/survey-creator-core/CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5+
### [1.12.26](https://github.com/surveyjs/survey-creator/compare/v1.12.25...v1.12.26) (2025-03-04)
6+
57
### [1.12.25](https://github.com/surveyjs/survey-creator/compare/v1.12.24...v1.12.25) (2025-02-25)
68

79
### [1.12.24](https://github.com/surveyjs/survey-creator/compare/v1.12.23...v1.12.24) (2025-02-20)

packages/survey-creator-core/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "1.12.25",
2+
"version": "1.12.26",
33
"name": "survey-creator-core",
44
"homepage": "https://surveyjs.io/Overview/Survey-Creator",
55
"license": "SEE LICENSE IN LICENSE",

packages/survey-creator-core/src/components/string-editor.ts

+12-7
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,11 @@ export class StringEditorViewModelBase extends Base {
256256
super();
257257
this.locString = locString;
258258
this.checkMarkdownToTextConversion(this.locString.owner, this.locString.name);
259+
this.creator?.onLocaleChanded.add(this.onLocaleChanged);
259260
}
260-
261+
private onLocaleChanged = () => {
262+
this.resetPropertyValue("placeholderValue");
263+
};
261264
public afterRender() {
262265
if (this.connector.focusOnEditor) {
263266
if (this.activate()) this.connector.focusOnEditor = false;
@@ -271,6 +274,7 @@ export class StringEditorViewModelBase extends Base {
271274
}
272275

273276
public dispose(): void {
277+
this.creator?.onLocaleChanded.remove(this.onLocaleChanged);
274278
super.dispose();
275279
this.detachFromUI();
276280
}
@@ -422,9 +426,8 @@ export class StringEditorViewModelBase extends Base {
422426
private getClearedText(target: HTMLElement): string {
423427
const html = target.innerHTML;
424428
const text = target.innerText;
425-
if(!this.creator) return this.locString.hasHtml ? html : text;
426429
let mdText = null;
427-
if (!this.editAsText) {
430+
if (!this.editAsText && this.creator) {
428431
const options = {
429432
element: <Base><any>this.locString.owner,
430433
text: <any>null,
@@ -438,9 +441,11 @@ export class StringEditorViewModelBase extends Base {
438441
if (mdText) {
439442
clearedText = mdText;
440443
} else {
441-
let txt = this.locString.hasHtml && !this.editAsText ? html : text;
442-
if (!this.locString.allowLineBreaks) txt = clearNewLines(txt);
443-
clearedText = txt;
444+
clearedText = this.locString.hasHtml && !this.editAsText ? html : text;
445+
const txt = clearNewLines(clearedText);
446+
if (!this.locString.allowLineBreaks || !txt) {
447+
clearedText = txt;
448+
}
444449
}
445450
const owner = this.locString.owner as any;
446451

@@ -451,7 +456,7 @@ export class StringEditorViewModelBase extends Base {
451456
newValue: clearedText,
452457
doValidation: false
453458
};
454-
this.creator.onValueChangingCallback(changingOptions);
459+
if (this.creator) this.creator.onValueChangingCallback(changingOptions);
455460
return changingOptions.newValue;
456461
}
457462
private getErrorTextOnChanged(clearedText: string): string {

packages/survey-creator-core/src/components/tabs/logic-items.ts

+12-7
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,22 @@ export class SurveyLogicAction {
4444
public apply(expression: string, isRenaming: boolean = false): void {
4545
if (!!this.element && !!this.logicType) {
4646
this.element[this.logicType.propertyName] = expression;
47-
if (
48-
!expression &&
49-
Serializer.isDescendantOf(this.element.getType(), "surveytrigger")
50-
) {
51-
var index = this.survey.triggers.indexOf(<SurveyTrigger>this.element);
52-
if (index > -1) {
53-
this.survey.triggers.splice(index, 1);
47+
if (!expression) {
48+
if(Serializer.isDescendantOf(this.element.getType(), "surveytrigger")) {
49+
this.removeElement(this.survey.triggers, this.element);
50+
}
51+
if(Serializer.isDescendantOf(this.element.getType(), "htmlconditionitem")) {
52+
this.removeElement(this.survey.completedHtmlOnCondition, this.element);
5453
}
5554
}
5655
}
5756
}
57+
private removeElement(items: Array<any>, element: any): void {
58+
var index = items.indexOf(this.element);
59+
if (index > -1) {
60+
items.splice(index, 1);
61+
}
62+
}
5863
public renameQuestion(oldName: string, newName: string): void {
5964
if (!this.element) return;
6065
var names = this.questionNames;

packages/survey-creator-core/src/creator-settings.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {
22
StylesManager, Base, IAction, ItemValue,
33
JsonObjectProperty, MatrixDropdownColumn, Question,
4-
SurveyModel, ILocalizableString, PopupBaseViewModel, SurveyElement
4+
SurveyModel, ILocalizableString, PopupBaseViewModel, PageModel
55
} from "survey-core";
66

77
/**
@@ -333,6 +333,7 @@ export interface ISurveyCreatorOptions {
333333
context?: { element: Base, item?: any, elementType?: string, propertyName?: string }
334334
): void;
335335
translationLocalesOrder: Array<string>;
336+
canAddPage(pageToAdd?: PageModel): boolean;
336337
}
337338

338339
export class EmptySurveyCreatorOptions implements ISurveyCreatorOptions {
@@ -487,6 +488,7 @@ export class EmptySurveyCreatorOptions implements ISurveyCreatorOptions {
487488
doMachineTranslation(fromLocale: string, toLocale: string, strings: Array<string>, callback: (translated: Array<string>) => void): void { }
488489
chooseFiles(input: HTMLInputElement, callback: (files: File[]) => void, context?: { element: Base, item?: any, elementType?: string, propertyName?: string }): void { }
489490
translationLocalesOrder: Array<string> = [];
491+
canAddPage(pageToAdd?: PageModel): boolean { return true; }
490492
}
491493

492494
StylesManager.applyTheme("defaultV2");

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

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Base, ComputedUpdater, IAction, ISurveyData, ItemValue, JsonMetadata, JsonMetadataClass, JsonObjectProperty, MatrixDropdownColumn, MatrixDropdownRowModelBase, MatrixDynamicRowModel, PanelModel, Question, QuestionHtmlModel, QuestionMatrixDropdownModelBase, QuestionMatrixDropdownRenderedRow, QuestionMatrixDynamicModel, QuestionRatingModel, renamedIcons, Serializer, SurveyElement } from "survey-core";
1+
import { Base, ComputedUpdater, IAction, ISurveyData, ItemValue, JsonMetadata, JsonMetadataClass, JsonObjectProperty, MatrixDropdownColumn, MatrixDropdownRowModelBase, MatrixDynamicRowModel, PanelModel, Question, QuestionHtmlModel, QuestionMatrixDropdownModelBase, QuestionMatrixDropdownRenderedRow, QuestionMatrixDynamicModel, QuestionRatingModel, renamedIcons, Serializer, SurveyElement, SurveyModel } from "survey-core";
22
import { editorLocalization } from "../editorLocalization";
33
import { SurveyQuestionProperties } from "../question-editor/properties";
44
import { ISurveyCreatorOptions, settings } from "../creator-settings";
@@ -12,7 +12,6 @@ import {
1212
} from "./index";
1313
import { updateMatixActionsClasses, updateMatrixRemoveAction } from "../utils/actions";
1414
import { QuestionRatingAdornerViewModel } from "../components/question-rating";
15-
import { CreatorBase } from "../creator-base";
1615
import { ISurveyPropertyGridDefinition } from "../question-editor/definition";
1716

1817
Serializer.addProperty("itemvalue",
@@ -669,7 +668,9 @@ export class PropertyGridEditorMatrixPages extends PropertyGridEditorMatrix {
669668
return prop.type == "surveypages";
670669
}
671670
protected addItem(creator: ISurveyCreatorOptions, obj: Base, question: QuestionMatrixDynamicModel) {
672-
(creator as CreatorBase).addPage(undefined, false);
671+
if(creator.canAddPage()) {
672+
super.addItem(creator, obj, question);
673+
}
673674
}
674675
protected getColumnClassName(obj: Base, prop: JsonObjectProperty): string {
675676
return "page@" + obj.getType();
@@ -684,7 +685,7 @@ export class PropertyGridEditorMatrixPages extends PropertyGridEditorMatrix {
684685
return "name";
685686
}
686687
protected getBaseValue(prop: JsonObjectProperty): string {
687-
return "page";
688+
return editorLocalization.getString("ed.newPageName");
688689
}
689690
protected getAllowRowDragDrop(prop: JsonObjectProperty): boolean { return true; }
690691
}

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

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

924924
test("SurveyPropertyConditionEditor, set correct locale into internal survey, Bug #953", () => {
925-
editorLocalization.currentLocale = "de";
926925
const creator = new CreatorTester();
926+
editorLocalization.currentLocale = "de";
927927
creator.JSON = {
928928
elements: [
929929
{ name: "q1", type: "text" },
@@ -941,8 +941,8 @@ test("SurveyPropertyConditionEditor, set correct locale into internal survey, Bu
941941
editorLocalization.currentLocale = "";
942942
});
943943
test("creator.onSurveyInstanceCreated, can pass ConditionEditor as model", () => {
944-
editorLocalization.currentLocale = "de";
945944
const creator = new CreatorTester();
945+
editorLocalization.currentLocale = "de";
946946
creator.JSON = {
947947
elements: [
948948
{ name: "q1", type: "text" },

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

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ export class CreatorTester extends SurveyCreatorModel {
1313
creatorSetting.defaultNewSurveyJSON = { pages: [{ name: "page1" }] };
1414
}
1515
super(options, options2);
16+
//Reset the locale to the default one from the previous tests
17+
this.locale = "";
1618
this.autoSaveDelay = 0;
1719
this.onSurveyInstanceCreated.add((creator, options) => {
1820
options.survey.getRendererForString = (element: Base, name: string): any => {

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

+59-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ import {
3333
ComponentCollection,
3434
QuestionBooleanModel,
3535
QuestionRadiogroupModel,
36-
PageModel
36+
PageModel,
37+
ActionContainer
3738
} from "survey-core";
3839
import {
3940
EmptySurveyCreatorOptions,
@@ -236,8 +237,10 @@ test("dropdown property editor, get choices on callback", () => {
236237
Serializer.removeProperty("survey", "region");
237238
});
238239
test("Serializer.addpropery, type: 'dropdown' cuts the text before dots, provided into choices. Bug#5787", (): any => {
239-
Serializer.addProperty("survey", { name: "prop1:dropdown", type: "dropdown",
240-
choices: ["Gemini 1.5 Pro", "Claude 3.5 Sonnet"] });
240+
Serializer.addProperty("survey", {
241+
name: "prop1:dropdown", type: "dropdown",
242+
choices: ["Gemini 1.5 Pro", "Claude 3.5 Sonnet"]
243+
});
241244
const survey = new SurveyModel();
242245
const propertyGrid = new PropertyGridModelTester(survey);
243246
const question = propertyGrid.survey.getQuestionByName("prop1");
@@ -3108,9 +3111,11 @@ test("Do not select page on adding new page in the property grid #5564", () => {
31083111
expect(creator.survey.pages).toHaveLength(1);
31093112
creator.selectElement(creator.survey);
31103113
const pagesQuestion = <QuestionMatrixDynamicModel>creator.propertyGrid.getQuestionByName("pages");
3114+
expect(pagesQuestion.visibleRows).toHaveLength(1);
31113115
const actions = pagesQuestion.getTitleActions();
31123116
actions[actions.length - 1].action();
31133117
expect(creator.survey.pages).toHaveLength(2);
3118+
expect(pagesQuestion.visibleRows).toHaveLength(2);
31143119
expect((<any>creator.selectedElement).pages).toHaveLength(2);
31153120
});
31163121
test("Setup correct categories for dynamic properties in components", () => {
@@ -3321,6 +3326,31 @@ test("check pages editor respects onPageAdding", () => {
33213326
expect(creator.survey.pages.length).toBe(1);
33223327
settings.defaultNewSurveyJSON = savedNewJSON;
33233328
});
3329+
test("Localication and survey.pages property, Bug#6687", () => {
3330+
const deutschStrings: any = {
3331+
ed: {
3332+
newPageName: "Seite"
3333+
}
3334+
};
3335+
editorLocalization.locales["de"] = deutschStrings;
3336+
settings.defaultNewSurveyJSON = {};
3337+
const creator = new CreatorTester(undefined, undefined, false);
3338+
creator.locale = "de";
3339+
const propertyGrid = new PropertyGridModelTester(creator.survey);
3340+
const pagesQuestion = <QuestionMatrixDynamicModel>(
3341+
propertyGrid.survey.getQuestionByName("pages")
3342+
);
3343+
const propertyEditor = new PropertyGridEditorMatrixPages();
3344+
const options = { titleActions: [], question: pagesQuestion };
3345+
propertyEditor.onGetQuestionTitleActions(creator.survey, options, creator);
3346+
const addNewPageAction = options.titleActions[0] as IAction;
3347+
3348+
expect(creator.survey.pages.length).toBe(0);
3349+
addNewPageAction.action!();
3350+
3351+
expect(creator.survey.pages.length).toBe(1);
3352+
expect(creator.survey.pages[0].name).toBe("Seite1");
3353+
});
33243354
test("Set property name into correct category", () => {
33253355
Serializer.addProperty("question", {
33263356
name: "validation",
@@ -3665,4 +3695,29 @@ test("Undo for deleting validator in multiple text item, Bug#6295", () => {
36653695
creator.undo();
36663696
expect(item1.validators).toHaveLength(1);
36673697
expect(matrix.visibleRows).toHaveLength(1);
3668-
});
3698+
});
3699+
test("Pages Collection Editor - The Trash Bin (Remove) button is unavailable when you use the Add Page button Bug#6645", () => {
3700+
const creator = new CreatorTester(undefined, undefined, false);
3701+
const propertyGrid = new PropertyGridModelTester(creator.survey, creator);
3702+
const pagesQuestion = <QuestionMatrixDynamicModel>propertyGrid.survey.getQuestionByName("pages");
3703+
const rowsCount = pagesQuestion.visibleRows.length;
3704+
const action = pagesQuestion.getTitleActions().filter(action => action.id === "add-item")[0];
3705+
expect(action).toBeTruthy();
3706+
action.action();
3707+
action.action();
3708+
expect(pagesQuestion.visibleRows).toHaveLength(rowsCount + 2);
3709+
3710+
const rows = pagesQuestion.renderedTable.rows;
3711+
expect(rows[0].isErrorsRow).toBeFalsy();
3712+
expect(rows[0].hasEndActions).toBeTruthy();
3713+
let cell = rows[0].cells[rows[0].cells.length - 1];
3714+
expect(cell.isActionsCell).toBeTruthy();
3715+
let container = <ActionContainer>cell.item.value;
3716+
expect(container.getActionById("remove-row")).toBeTruthy();
3717+
expect(rows[2].isErrorsRow).toBeFalsy();
3718+
expect(rows[2].hasEndActions).toBeTruthy();
3719+
cell = rows[2].cells[rows[2].cells.length - 1];
3720+
expect(cell.isActionsCell).toBeTruthy();
3721+
container = <ActionContainer>cell.item.value;
3722+
expect(container.getActionById("remove-row")).toBeTruthy();
3723+
});

packages/survey-creator-core/tests/string-editor.tests.ts

+34
Original file line numberDiff line numberDiff line change
@@ -1042,6 +1042,40 @@ test("Test string editor inplaceEditForValues without Creator", (): any => {
10421042
expect(q0.otherText).toEqual("Other changed");
10431043
});
10441044

1045+
test("Test string editor description clear (with EOL)", (): any => {
1046+
const survey = new SurveyModel({
1047+
"pages": [
1048+
{
1049+
"name": "page1",
1050+
"elements": [
1051+
{
1052+
"type": "radiogroup",
1053+
"title": "title",
1054+
"description": "desc",
1055+
"name": "q0",
1056+
"choices": ["i1", "i2"]
1057+
}
1058+
]
1059+
}
1060+
]
1061+
});
1062+
1063+
const q0 = survey.getQuestionByName("q0");
1064+
const itemValue = q0.choices[0];
1065+
var seChoice = new StringEditorViewModelBase(itemValue.locText);
1066+
var seDescription = new StringEditorViewModelBase(q0.locDescription);
1067+
expect(itemValue.text).toEqual("i1");
1068+
seChoice.onBlur({ target: { innerText: "new\nTitle", innerHTML: "new\nTitle", setAttribute: () => { }, removeAttribute: () => { } } });
1069+
expect(itemValue.text).toEqual("newTitle");
1070+
1071+
expect(q0.description).toEqual("desc");
1072+
seDescription.onBlur({ target: { innerText: "new\nDesc", innerHTML: "new\nDesc", setAttribute: () => { }, removeAttribute: () => { } } });
1073+
expect(q0.locDescription.text).toEqual("new\nDesc");
1074+
1075+
seDescription.onBlur({ target: { innerText: "\n", innerHTML: "\n", setAttribute: () => { }, removeAttribute: () => { } } });
1076+
expect(q0.locDescription.text).toEqual("");
1077+
});
1078+
10451079
test("StringEditor multiline paste for selectbase questions should respect creator.maximumChoicesCount", (): any => {
10461080
const creator = new CreatorTester();
10471081
creator.maximumChoicesCount = 4;

0 commit comments

Comments
 (0)