Skip to content

Commit

Permalink
make allowCompleteSurveyAutomatic prop serializable (#7914)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtelnov authored Mar 1, 2024
1 parent 241175c commit ddb86f5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/survey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1678,7 +1678,7 @@ export class SurveyModel extends SurveyElementCore
* @see [`settings.autoAdvanceDelay`](https://surveyjs.io/form-library/documentation/api-reference/settings#autoAdvanceDelay)
*/
public get allowCompleteSurveyAutomatic(): boolean {
return this.getPropertyValue("allowCompleteSurveyAutomatic", true);
return this.getPropertyValue("allowCompleteSurveyAutomatic");
}
public set allowCompleteSurveyAutomatic(val: boolean) {
this.setPropertyValue("allowCompleteSurveyAutomatic", val);
Expand Down Expand Up @@ -7847,6 +7847,10 @@ Serializer.addClass("survey", [
obj.setPropertyValue("goNextPageAutomatic", value);
}
},
{
name: "allowCompleteSurveyAutomatic:boolean", default: true,
visibleIf: (obj: any): boolean => obj.goNextPageAutomatic === true
},
{
name: "clearInvisibleValues",
default: "onComplete",
Expand Down
20 changes: 20 additions & 0 deletions tests/surveytests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4179,6 +4179,26 @@ QUnit.test(
assert.equal(survey.state, "completed");
}
);
QUnit.test("goNextPageAutomatic and allowCompleteSurveyAutomatic=false", function (assert) {
const emptySurvey = new SurveyModel();
assert.equal(emptySurvey.allowCompleteSurveyAutomatic, true, "allowCompleteSurveyAutomatic value # 1");
const survey = new SurveyModel({
pages: [
{ elements: [{ type: "dropdown", name: "q1", choices: [1, 2, 3] }] },
{ elements: [{ type: "dropdown", name: "q2", choices: [1, 2, 3] }] }
],
goNextPageAutomatic: true,
allowCompleteSurveyAutomatic: false
});
assert.equal(survey.allowCompleteSurveyAutomatic, false, "allowCompleteSurveyAutomatic value # 2");
const q1 = survey.getQuestionByName("q1");
const q2 = survey.getQuestionByName("q2");
assert.equal(survey.currentPageNo, 0, "curPage #1");
q1.value = 1;
assert.equal(survey.currentPageNo, 1, "curPage #2");
q2.value = 1;
assert.equal(survey.currentPageNo, 1, "curPage #2");
});

QUnit.test("goNextPageAutomatic and checkbox wiht valueName bug #70", function (
assert
Expand Down

0 comments on commit ddb86f5

Please sign in to comment.