Skip to content
Draft
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
1 change: 1 addition & 0 deletions packages/survey-core/src/base-interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ export interface ISurvey extends ITextProcessor, ISurveyErrorOwner {
updateNavigationElements(): void;
currentSingleElement: IElement;
supportsNestedSingleInput(question: IQuestion): boolean;
updateNestedSingleQuestions(question: IQuestion, nestedQuestions: Array<IQuestion>): void;
areEmptyElementsHidden: boolean;
isLoadingFromJson: boolean;
isUpdateValueTextOnTyping: boolean;
Expand Down
8 changes: 7 additions & 1 deletion packages/survey-core/src/question.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,12 @@ export class Question extends SurveyElement<Question>
}
public getSingleInputAddText(): string {
const q = this.currentSingleInputQuestion;
return !!q && !!q.singleInputSummary ? q.getSingleInputAddTextCore() : undefined;
if (!q) return undefined;
if (!!q.singleInputSummary) return q.getSingleInputAddTextCore();
const qs = this.getSingleInputQuestions();
const len = Array.isArray(qs) ? qs.length : 0;
if (len > 0 && qs[len - 1] === q) return this.getSingleInputAddTextCore();
return undefined;
}
public singleInputAddItem(checkErrors?: boolean): void {
if (!checkErrors || this.validateSingleInput()) {
Expand Down Expand Up @@ -1206,6 +1211,7 @@ export class Question extends SurveyElement<Question>
const question = this.getPropertyValue("singleInputQuestion");
if (question === this) return [this];
const res = this.getSingleInputQuestionsCore(question, !question || !this.isSingleInputSummaryShown);
this.survey?.updateNestedSingleQuestions(this, res);
res.forEach(q => { if (q !== this)this.onSingleInputQuestionAdded(q); });
return res;
}
Expand Down
5 changes: 4 additions & 1 deletion packages/survey-core/src/survey-events-api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IAction } from "./actions/action";
import { Base } from "./base";
import { IDropdownMenuOptions, IElement, IPanel, ISurveyElement, IValueItemCustomPropValues } from "./base-interfaces";
import { IDropdownMenuOptions, IElement, IPanel, IQuestion, ISurveyElement, IValueItemCustomPropValues } from "./base-interfaces";
import { ItemValue } from "./itemvalue";
import { PageModel } from "./page";
import { PanelModel, PanelModelBase } from "./panel";
Expand Down Expand Up @@ -1102,6 +1102,9 @@ export interface GetExpressionDisplayValueEvent extends GetQuestionDisplayValueE
export interface CheckSingleInputPerPageModeEvent extends QuestionEventMixin {
enabled: boolean;
}
export interface UpdateSingleInputNestedQuestionsEvent extends QuestionEventMixin {
nestedQuestions: Array<Question>;
}

export interface MultipleTextItemAddedEvent extends QuestionEventMixin {
/**
Expand Down
16 changes: 8 additions & 8 deletions packages/survey-core/src/survey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,9 @@ import {
DynamicPanelItemValueChangedEvent, DynamicPanelValueChangedEvent, DynamicPanelValueChangingEvent,
DynamicPanelGetTabTitleEvent, DynamicPanelCurrentIndexChangedEvent, CheckAnswerCorrectEvent, DragDropAllowEvent, ScrollToTopEvent, GetQuestionTitleActionsEvent,
GetPanelTitleActionsEvent, GetPageTitleActionsEvent, GetPanelFooterActionsEvent, GetMatrixRowActionsEvent, GetExpressionDisplayValueEvent, CheckSingleInputPerPageModeEvent,
ServerValidateQuestionsEvent, MultipleTextItemAddedEvent, MatrixColumnAddedEvent, GetQuestionDisplayValueEvent, PopupVisibleChangedEvent, ChoicesSearchEvent,
OpenFileChooserEvent, OpenDropdownMenuEvent, ResizeEvent,
GetTitleActionsEventMixin, ProgressTextEvent, ScrollingElementToTopEvent, IsAnswerCorrectEvent,
LoadChoicesFromServerEvent,
ProcessTextValueEvent,
CreateCustomChoiceItemEvent,
MatrixRowDragOverEvent,
ExpressionRunningEvent
UpdateSingleInputNestedQuestionsEvent, ServerValidateQuestionsEvent, MultipleTextItemAddedEvent, MatrixColumnAddedEvent, GetQuestionDisplayValueEvent,
PopupVisibleChangedEvent, ChoicesSearchEvent, OpenFileChooserEvent, OpenDropdownMenuEvent, ResizeEvent, GetTitleActionsEventMixin, ProgressTextEvent, ScrollingElementToTopEvent,
IsAnswerCorrectEvent, LoadChoicesFromServerEvent, ProcessTextValueEvent, CreateCustomChoiceItemEvent, MatrixRowDragOverEvent, ExpressionRunningEvent
} from "./survey-events-api";
import { QuestionMatrixDropdownModelBase } from "./question_matrixdropdownbase";
import { QuestionMatrixDynamicModel } from "./question_matrixdynamic";
Expand Down Expand Up @@ -977,6 +972,7 @@ export class SurveyModel extends SurveyElementCore
public onGetExpressionDisplayValue: EventBase<SurveyModel, GetExpressionDisplayValueEvent> = this.addEvent<SurveyModel, GetExpressionDisplayValueEvent>();

public onCheckSingleInputPerPageMode: EventBase<SurveyModel, CheckSingleInputPerPageModeEvent> = this.addEvent<SurveyModel, CheckSingleInputPerPageModeEvent>();
public onUpdateNestedSingleInputQuestions: EventBase<SurveyModel, UpdateSingleInputNestedQuestionsEvent> = this.addEvent<SurveyModel, UpdateSingleInputNestedQuestionsEvent>();

/**
* An event that is raised after the visibility of a popup is changed.
Expand Down Expand Up @@ -4938,6 +4934,10 @@ export class SurveyModel extends SurveyElementCore
this.onCheckSingleInputPerPageMode.fire(this, options);
return options.enabled;
}
public updateNestedSingleQuestions(question: IQuestion, nestedQuestions: Array<IQuestion>): void {
const options: any = { question: question, nestedQuestions: nestedQuestions };
this.onUpdateNestedSingleInputQuestions.fire(this, options);
}
private changeCurrentSingleElementOnVisibilityChanged(): void {
const el = this.currentSingleElement;
if (!el || el.isVisible) return;
Expand Down
35 changes: 34 additions & 1 deletion packages/survey-core/tests/inputPerPageTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2396,4 +2396,37 @@ QUnit.skip("singleInput bradscrum navigation for 3 level dynamic panels", assert
assert.equal(actions[0].title, "Panel 2", "actions[0] title, #3");
assert.equal(actions[1].title, "Panel 2", "actions[1] title, #3");
actions[0].action();
});
});
QUnit.test("Do not show summary page on request, Issue#10435", assert => {
const survey = new SurveyModel();
survey.onUpdateNestedSingleInputQuestions.add((_, opt) => {
const question = opt.nestedQuestions;
for (let i = question.length - 1; i >= 0; i--) {
if (question[i] === opt.question) {
question.splice(i, 1);
}
}
});
survey.fromJSON({
elements: [
{ type: "paneldynamic", name: "panel", panelCount: 1, templateElements: [
{ type: "text", name: "q1" },
{ type: "text", name: "q2" }]
},
{ type: "text", name: "q3" }
],
questionsOnPageMode: "inputPerPage"
});
const addBtn = survey.navigationBar.getActionById("sv-singleinput-add");
const panel = <QuestionPanelDynamicModel>survey.getQuestionByName("panel");
assert.equal(survey.currentSingleQuestion.name, "panel", "currentSingleQuestion is panel, #1");
assert.equal(panel.singleInputQuestion.name, "q1", "singleInputQuestion is q1, #1");
assert.equal(addBtn.visible, false, "addBtn.visible, #1");
survey.performNext();
assert.equal(panel.getSingleInputAddText(), "Add new", "getSingleInputAddText, #2");
assert.equal(panel.singleInputQuestion.name, "q2", "singleInputQuestion is q2, #2");
assert.equal(addBtn.visible, true, "addBtn.visible, #2");
survey.performNext();
assert.equal(survey.currentSingleQuestion.name, "q3", "currentSingleQuestion is q3, #3");
assert.equal(addBtn.visible, false, "addBtn.visible, #3");
});