Skip to content

Commit

Permalink
Actually fixed progress (not buttons navigation)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsv2013 committed May 14, 2024
1 parent 1c10bfa commit f994844
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 37 deletions.
62 changes: 31 additions & 31 deletions src/survey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7526,47 +7526,47 @@ export class SurveyModel extends SurveyElementCore
}
}
} else if (this.state === "running" && isStrCiEqual(layoutElement.id, this.progressBarComponentName)) {
const headerLayoutElement = this.findLayoutElement("advanced-header");
const advHeader = headerLayoutElement && headerLayoutElement.data as Cover;
let isBelowHeader = !advHeader || advHeader.hasBackground;
if (isStrCiEqual(this.showProgressBar, "aboveHeader")) {
isBelowHeader = false;
}
if (isStrCiEqual(this.showProgressBar, "belowHeader")) {
isBelowHeader = true;
}
if (container === "header" && !isBelowHeader) {
layoutElement.index = -150;
if (this.isShowProgressBarOnTop && !this.isShowStartingPage) {
containerLayoutElements.push(layoutElement);
}
}
if (container === "center" && isBelowHeader) {
if (!!layoutElement.index) {
delete layoutElement.index;
if (this.questionsOnPageMode != "singlePage") {
const headerLayoutElement = this.findLayoutElement("advanced-header");
const advHeader = headerLayoutElement && headerLayoutElement.data as Cover;
let isBelowHeader = !advHeader || advHeader.hasBackground;
if (isStrCiEqual(this.showProgressBar, "aboveHeader")) {
isBelowHeader = false;
}
if (this.isShowProgressBarOnTop && !this.isShowStartingPage) {
containerLayoutElements.push(layoutElement);
if (isStrCiEqual(this.showProgressBar, "belowHeader")) {
isBelowHeader = true;
}
}
if (container === "footer") {
if (this.isShowProgressBarOnBottom && !this.isShowStartingPage) {
containerLayoutElements.push(layoutElement);
if (container === "header" && !isBelowHeader) {
layoutElement.index = -150;
if (this.isShowProgressBarOnTop && !this.isShowStartingPage) {
containerLayoutElements.push(layoutElement);
}
}
}
} else if (isStrCiEqual(layoutElement.id, "buttons-navigation")) {
if (this.questionsOnPageMode != "singlePage") {
if (container === "contentTop") {
if (["top", "both"].indexOf(this.isNavigationButtonsShowing) !== -1) {
if (container === "center" && isBelowHeader) {
if (!!layoutElement.index) {
delete layoutElement.index;
}
if (this.isShowProgressBarOnTop && !this.isShowStartingPage) {
containerLayoutElements.push(layoutElement);
}
}
if (container === "contentBottom") {
if (["bottom", "both"].indexOf(this.isNavigationButtonsShowing) !== -1) {
if (container === "footer") {
if (this.isShowProgressBarOnBottom && !this.isShowStartingPage) {
containerLayoutElements.push(layoutElement);
}
}
}
} else if (isStrCiEqual(layoutElement.id, "buttons-navigation")) {
if (container === "contentTop") {
if (["top", "both"].indexOf(this.isNavigationButtonsShowing) !== -1) {
containerLayoutElements.push(layoutElement);
}
}
if (container === "contentBottom") {
if (["bottom", "both"].indexOf(this.isNavigationButtonsShowing) !== -1) {
containerLayoutElements.push(layoutElement);
}
}
} else if (this.state === "running" && isStrCiEqual(layoutElement.id, "toc-navigation") && this.showTOC) {
if (container === "left") {
if (["left", "both"].indexOf(this.tocLocation) !== -1) {
Expand Down
16 changes: 10 additions & 6 deletions tests/surveytests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19631,8 +19631,10 @@ QUnit.test("check panel's visibleRows are updated sync when running condidtions
settings.animationEnabled = false;
});

QUnit.test("getContainerContent - do not show buttons navigation in the single page mode", function (assert) {
QUnit.test("getContainerContent - do not show buttons progress in the single page mode", function (assert) {
const json = {
showNavigationButtons: "none",
showProgressBar: "auto",
pages: [
{
"elements": [
Expand All @@ -19650,21 +19652,23 @@ QUnit.test("getContainerContent - do not show buttons navigation in the single p

assert.equal(survey.questionsOnPageMode, "standard");
assert.deepEqual(getContainerContent("header"), [], "");
assert.deepEqual(getContainerContent("center"), [{
"component": "sv-progress-buttons",
"id": "progress-buttons"
}], "Progress is shown");
assert.deepEqual(getContainerContent("footer"), [], "");
assert.deepEqual(getContainerContent("contentTop"), [], "");
assert.deepEqual(getContainerContent("contentBottom"), [{
"component": "sv-action-bar",
"id": "buttons-navigation"
}], "Buttons navigation is shown");
assert.deepEqual(getContainerContent("contentBottom"), [], "");
assert.deepEqual(getContainerContent("left"), [], "");
assert.deepEqual(getContainerContent("right"), [], "");

survey.questionsOnPageMode = "singlePage";

assert.deepEqual(getContainerContent("header"), [], "");
assert.deepEqual(getContainerContent("center"), [], "Buttons progress is not shown in the single page mode");
assert.deepEqual(getContainerContent("footer"), [], "");
assert.deepEqual(getContainerContent("contentTop"), [], "");
assert.deepEqual(getContainerContent("contentBottom"), [], "No buttons navigation in the single page mode");
assert.deepEqual(getContainerContent("contentBottom"), [], "");
assert.deepEqual(getContainerContent("left"), [], "");
assert.deepEqual(getContainerContent("right"), [], "");
});

0 comments on commit f994844

Please sign in to comment.