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

SurveyModel: Misc renamings - sendResultOnPageNext, maxOthersLength, lazyRendering #9222

Merged
merged 6 commits into from
Jan 7, 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
6 changes: 3 additions & 3 deletions functionalTests/dxService/runSurveyOneTime.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const initSurvey = ClientFunction(framework => {
"surveyElement"
);
survey.clientId = document.getElementById("clientId").value;
survey.sendResultOnPageNext = document.getElementById(
survey.partialSendEnabled = document.getElementById(
"sendResultOnPageNext"
).checked;
survey.onComplete.add(function(s) {
Expand Down Expand Up @@ -111,7 +111,7 @@ const initSurvey = ClientFunction(framework => {
clientId: document.getElementById("clientId").value
});
document.getElementById("clientIdContainer").style.display = "none";
survey.sendResultOnPageNext = document.getElementById(
survey.partialSendEnabled = document.getElementById(
"sendResultOnPageNext"
).checked;
window["ReactDOMClient"].createRoot(document.getElementById("surveyElement")).render(
Expand All @@ -132,7 +132,7 @@ const initSurvey = ClientFunction(framework => {
"surveyContainer"
);
survey.clientId = document.getElementById("clientId").value;
survey.sendResultOnPageNext = document.getElementById(
survey.partialSendEnabled = document.getElementById(
"sendResultOnPageNext"
).checked;
survey.onComplete.add(surveyComplete);
Expand Down
6 changes: 6 additions & 0 deletions packages/survey-core/docs/surveyjs_definition.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@
"sendResultOnPageNext": {
"type": "boolean"
},
"partialSendEnabled": {
"type": "boolean"
},
"surveyShowDataSaving": {
"type": "boolean"
},
Expand Down Expand Up @@ -137,6 +140,9 @@
"maxOthersLength": {
"type": "number"
},
"maxCommentLength": {
"type": "number"
},
"goNextPageAutomatic": {
"type": [
"boolean",
Expand Down
4 changes: 4 additions & 0 deletions packages/survey-core/src/base-interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,11 @@ export interface ISurvey extends ITextProcessor, ISurveyErrorOwner {
storeOthersAsComment: boolean;

maxTextLength: number;
/**
* @deprecated Use `maxCommentLength` instead.
*/
maxOthersLength: number;
maxCommentLength: number;
clearValueOnDisableItems: boolean;

timeLimitPerPage: number;
Expand Down
2 changes: 1 addition & 1 deletion packages/survey-core/src/question.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1331,7 +1331,7 @@ export class Question extends SurveyElement<Question>
}
public getOthersMaxLength(): any {
if (!this.survey) return null;
return this.survey.maxOthersLength > 0 ? this.survey.maxOthersLength : null;
return this.survey.maxCommentLength > 0 ? this.survey.maxCommentLength : null;
}
protected onCreating(): void { }
public getFirstQuestionToFocus(withError: boolean): Question {
Expand Down
64 changes: 47 additions & 17 deletions packages/survey-core/src/survey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export class SurveyModel extends SurveyElementCore
*/
public onStarted: EventBase<SurveyModel, {}> = this.addEvent<SurveyModel, {}>();
/**
* An event that is raised to save incomplete survey results. Enable the [`sendResultOnPageNext`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#sendResultOnPageNext) property for this event to occur.
* An event that is raised to save incomplete survey results. Enable the [`partialSendEnabled`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#partialSendEnabled) property for this event to occur.
*
* For information on event handler parameters, refer to descriptions within the interface.
*
Expand Down Expand Up @@ -1333,7 +1333,7 @@ export class SurveyModel extends SurveyElementCore
return new CssClassBuilder().append(main)
.append(btn).toString();
}
private lazyRenderingValue: boolean;
private lazyRenderingEnabledValue: boolean;
@property() showBrandInfo: boolean;
@property() enterKeyAction: "moveToNextEditor" | "loseFocus" | "default";
/**
Expand All @@ -1346,19 +1346,29 @@ export class SurveyModel extends SurveyElementCore
* [View Demo](https://surveyjs.io/form-library/examples/survey-lazy/ (linkStyle))
* @see [settings.lazyRender](https://surveyjs.io/form-library/documentation/api-reference/settings#lazyRender)
*/
public get lazyRendering(): boolean {
return this.lazyRenderingValue === true;
public get lazyRenderingEnabled(): boolean {
return this.lazyRenderingEnabledValue === true;
}
public set lazyRendering(val: boolean) {
if (this.lazyRendering === val) return;
this.lazyRenderingValue = val;
public set lazyRenderingEnabled(val: boolean) {
if (this.lazyRenderingEnabled === val) return;
this.lazyRenderingEnabledValue = val;
const page: PageModel = this.currentPage;
if (!!page) {
page.updateRows();
}
}
/**
* Obsolete. Use the [`lazyRenderingEnabled`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#lazyRenderingEnabled) property instead.
* @deprecated
*/
public get lazyRendering(): boolean {
return this.lazyRenderingEnabled;
}
public set lazyRendering(val: boolean) {
this.lazyRenderingEnabled = val;
}
public get isLazyRendering(): boolean {
return this.lazyRendering || settings.lazyRender.enabled;
return this.lazyRenderingEnabled || settings.lazyRender.enabled;
}
@property() lazyRenderingFirstBatchSizeValue: number;
public get lazyRenderingFirstBatchSize(): number {
Expand Down Expand Up @@ -1464,11 +1474,21 @@ export class SurveyModel extends SurveyElementCore
*
* Alternatively, you can handle the [`onCurrentPageChanged`](#onCurrentPageChanged) and [`onValueChanged`](#onValueChanged) events, as shown in the following demo: [Continue an Incomplete Survey](https://surveyjs.io/form-library/examples/survey-editprevious/).
*/
public get partialSendEnabled(): boolean {
return this.getPropertyValue("partialSendEnabled");
}
public set partialSendEnabled(val: boolean) {
this.setPropertyValue("partialSendEnabled", val);
}
/**
* Obsolete. Use the [`partialSend`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#partialSend) property instead.
* @deprecated
*/
public get sendResultOnPageNext(): boolean {
return this.getPropertyValue("sendResultOnPageNext");
return this.partialSendEnabled;
}
public set sendResultOnPageNext(val: boolean) {
this.setPropertyValue("sendResultOnPageNext", val);
this.partialSendEnabled = val;
}
/**
* Specifies whether to show progress when the survey sends data to [SurveyJS Service](https://api.surveyjs.io).
Expand Down Expand Up @@ -1721,7 +1741,7 @@ export class SurveyModel extends SurveyElementCore
* Default value: `true`
*
* Respondents can leave comments when they select "Other" in choice-based questions, such as Dropdown or Checkboxes. Comment values are saved in a separate property. The property name is composed of the question `name` and [`commentSuffix`](#commentSuffix). However, you can use the question `name` as a key to store the comment value instead. Disable the `storeOthersAsComment` property in this case.
* @see maxOthersLength
* @see maxCommentLength
*/
public get storeOthersAsComment(): boolean {
return this.getPropertyValue("storeOthersAsComment");
Expand All @@ -1735,7 +1755,7 @@ export class SurveyModel extends SurveyElementCore
* Default value: 0 (unlimited)
*
* You can override this setting for individual questions if you specify their [`maxLength`](https://surveyjs.io/form-library/documentation/api-reference/text-entry-question-model#maxLength) property.
* @see maxOthersLength
* @see maxCommentLength
*/
public get maxTextLength(): number {
return this.getPropertyValue("maxTextLength");
Expand All @@ -1749,11 +1769,21 @@ export class SurveyModel extends SurveyElementCore
* Default value: 0 (unlimited)
* @see maxTextLength
*/
public get maxCommentLength(): number {
return this.getPropertyValue("maxCommentLength");
}
public set maxCommentLength(val: number) {
this.setPropertyValue("maxCommentLength", val);
}
/**
* Obsolete. Use the [`maxCommentLength`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#maxCommentLength) property instead.
* @deprecated
*/
public get maxOthersLength(): number {
return this.getPropertyValue("maxOthersLength");
return this.maxCommentLength;
}
public set maxOthersLength(val: number) {
this.setPropertyValue("maxOthersLength", val);
this.maxCommentLength = val;
}

/**
Expand Down Expand Up @@ -4849,7 +4879,7 @@ export class SurveyModel extends SurveyElementCore
var curPage = this.currentPage;
this.checkOnPageTriggers(false);
if (!this.isCompleted) {
if (this.sendResultOnPageNext) {
if (this.partialSendEnabled) {
this.sendResult(this.surveyPostId, this.clientId, true);
}
if (curPage === this.currentPage) {
Expand Down Expand Up @@ -8188,7 +8218,7 @@ Serializer.addClass("survey", [
{ name: "surveyPostId", visible: false },
{ name: "surveyShowDataSaving:boolean", visible: false },
"cookieName",
"sendResultOnPageNext:boolean",
{ name: "partialSendEnabled:boolean", alternativeName: "sendResultOnPageNext" },
{
name: "showNavigationButtons",
default: "bottom",
Expand Down Expand Up @@ -8281,7 +8311,7 @@ Serializer.addClass("survey", [
{ name: "mode", default: "edit", choices: ["edit", "display"] },
{ name: "storeOthersAsComment:boolean", default: true },
{ name: "maxTextLength:number", default: 0, minValue: 0 },
{ name: "maxOthersLength:number", default: 0, minValue: 0 },
{ name: "maxCommentLength:number", default: 0, minValue: 0, alternativeName: "maxOthersLength" },
{
name: "goNextPageAutomatic:boolean",
onSetValue: function (obj: any, value: any) {
Expand Down
4 changes: 2 additions & 2 deletions packages/survey-core/tests/jsonSchemaTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ QUnit.test("generate survey schema", function (assert) {
assert.equal(schema.title, "SurveyJS Library json schema");
assert.equal(schema.properties.surveyId.type, "string", "surveyId is string");
assert.equal(
schema.properties.sendResultOnPageNext.type,
schema.properties.partialSendEnabled.type,
"boolean",
"sendResultOnPageNext is boolean"
"partialSendEnabled is boolean"
);
assert.deepEqual(schema.properties.title,
{ "oneOf": [
Expand Down
24 changes: 12 additions & 12 deletions packages/survey-core/tests/paneltests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,7 @@ QUnit.test("Panel.startLazyRendering isNeedRender=true", function (assert) {
try {
settings.lazyRowsRenderingStartRow = 0;
const survey = new SurveyModel(json);
survey.lazyRendering = true;
survey.lazyRenderingEnabled = true;
const panel: PanelModel = <PanelModel>survey.getAllPanels()[0];
const page = survey.currentPage;
assert.equal(panel.rows.length, 2);
Expand Down Expand Up @@ -1028,7 +1028,7 @@ QUnit.test("row.isNeedRender & settings.lazyRowsRenderingStartRow", function (
settings.lazyRowsRenderingStartRow = 2;
try {
const survey = new SurveyModel(json);
survey.lazyRendering = true;
survey.lazyRenderingEnabled = true;
const page: PageModel = survey.currentPage;
assert.equal(page.rows.length, 3, "There are 3 rows");
assert.equal(page.rows[0].isNeedRender, true, "isNeedRender rows[0]");
Expand Down Expand Up @@ -1078,7 +1078,7 @@ QUnit.test(
settings.lazyRowsRenderingStartRow = 2;
try {
const survey = new SurveyModel(json);
survey.lazyRendering = true;
survey.lazyRenderingEnabled = true;
survey.setDesignMode(true);
const page1: PageModel = survey.pages[0];
assert.equal(page1.rows.length, 3, "There are 3 rows");
Expand Down Expand Up @@ -1674,7 +1674,7 @@ QUnit.test(
settings.lazyRowsRenderingStartRow = 2;
try {
const survey = new SurveyModel(json);
survey.lazyRendering = true;
survey.lazyRenderingEnabled = true;
const page1: PageModel = survey.pages[0];
assert.equal(page1.rows.length, 3, "There are 3 rows");
assert.equal(page1.rows[0].isNeedRender, true, "isNeedRender rows[0]");
Expand Down Expand Up @@ -2901,7 +2901,7 @@ QUnit.test("row.isNeedRender for panels", function (assert) {
settings.lazyRowsRenderingStartRow = 0;
try {
const survey = new SurveyModel(json);
survey.lazyRendering = true;
survey.lazyRenderingEnabled = true;
const page1: PageModel = survey.pages[0];
assert.equal(page1.rows.length, 2, "There are 2 rows");
assert.equal(page1.rows[0].isNeedRender, true, "isNeedRender page1 rows[0]");
Expand Down Expand Up @@ -2949,7 +2949,7 @@ QUnit.test("getAllRows for page", function (assert) {
settings.lazyRowsRenderingStartRow = 0;
try {
const survey = new SurveyModel(json);
survey.lazyRendering = true;
survey.lazyRenderingEnabled = true;
const page1: PageModel = survey.pages[0];
const allPageRows = page1.getAllRows();

Expand Down Expand Up @@ -2997,7 +2997,7 @@ QUnit.test("forceRenderRows for page", async function (assert) {
settings.lazyRowsRenderingStartRow = 0;
try {
const survey = new SurveyModel(json);
survey.lazyRendering = true;
survey.lazyRenderingEnabled = true;
survey.getAllQuestions().forEach(q => {
q.supportOnElementRerenderedEvent = true;
q.onElementRerenderedEventEnabled = true;
Expand Down Expand Up @@ -3058,7 +3058,7 @@ QUnit.test("forceRenderElement for page the exact element, gap = 0", async funct
settings.lazyRowsRenderingStartRow = 0;
try {
const survey = new SurveyModel(json);
survey.lazyRendering = true;
survey.lazyRenderingEnabled = true;
survey.getAllQuestions().forEach(q => {
q.supportOnElementRerenderedEvent = true;
q.onElementRerenderedEventEnabled = true;
Expand Down Expand Up @@ -3118,7 +3118,7 @@ QUnit.test("forceRenderElement for page with one prev element, gap = 1", async f
settings.lazyRowsRenderingStartRow = 0;
try {
const survey = new SurveyModel(json);
survey.lazyRendering = true;
survey.lazyRenderingEnabled = true;
survey.getAllQuestions().forEach(q => {
q.supportOnElementRerenderedEvent = true;
q.onElementRerenderedEventEnabled = true;
Expand Down Expand Up @@ -3194,7 +3194,7 @@ QUnit.test("row.isNeedRender for nested panels", function (assert) {
settings.lazyRowsRenderingStartRow = 0;
try {
const survey = new SurveyModel(json);
survey.lazyRendering = true;
survey.lazyRenderingEnabled = true;
const page1: PageModel = survey.pages[0];
const allPageRows = page1.getAllRows();
assert.equal(allPageRows.length, 7, "7 rows with panels");
Expand Down Expand Up @@ -3278,7 +3278,7 @@ QUnit.test("row.isNeedRender for nested panels - complex", function (assert) {
settings.lazyRowsRenderingStartRow = 0;
try {
const survey = new SurveyModel(json);
survey.lazyRendering = true;
survey.lazyRenderingEnabled = true;
const page1: PageModel = survey.pages[0];
const allPageRows = page1.getAllRows();
assert.equal(allPageRows.length, 7, "7 rows with panels");
Expand Down Expand Up @@ -3342,7 +3342,7 @@ QUnit.test("row.isNeedRender panel dynamic different modes - ordinary and design
settings.lazyRowsRenderingStartRow = 0;
try {
const survey = new SurveyModel(json);
survey.lazyRendering = true;
survey.lazyRenderingEnabled = true;
const page1: PageModel = survey.pages[0];

let allPageRows = page1.getAllRows();
Expand Down
2 changes: 1 addition & 1 deletion packages/survey-core/tests/surveytests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14941,7 +14941,7 @@ QUnit.test("survey.isLazyRendering", function (assert) {
assert.equal(survey.isLazyRendering, true, "set in settings");
settings.lazyRowsRendering = false;
assert.equal(survey.isLazyRendering, false, "Not set 2");
survey.lazyRendering = true;
survey.lazyRenderingEnabled = true;
assert.equal(survey.isLazyRendering, true, "set in survey");
});
QUnit.test("getSize", function (assert) {
Expand Down
2 changes: 1 addition & 1 deletion tests/markup/etalon_checkbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ registerMarkupTests(
snapshot: "checkbox-other",
},
{
name: "Test checkbox question markup Other option with maxOthersLength",
name: "Test checkbox question markup Other option with maxCommentLength",
json: {
"maxOthersLength": 15,
questions: [
Expand Down
Loading