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

Progress bar with titles. Page name –> title fix #6925 #6950

Merged
merged 1 commit into from
Sep 14, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
(click)="isListElementClickable(index) ? clickListElement(index) : null">
<div
[class]="model.css.progressButtonsPageTitle"
[title]="page.locNavigationTitle.renderedHtml || page.name"
[title]="page.renderedNavigationTitle"
>
{{ page.locNavigationTitle.renderedHtml || page.name }}
{{ page.renderedNavigationTitle }}
</div>
<div
[class]="model.css.progressButtonsPageDescription"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
>
<div
:class="css.progressButtonsPageTitle"
:title="page.locNavigationTitle.renderedHtml || page.name"
:title="page.renderedNavigationTitle"
>
{{ page.locNavigationTitle.renderedHtml || page.name }}
{{ page.renderedNavigationTitle }}
</div>
<div
:class="css.progressButtonsPageDescription"
Expand Down
2 changes: 1 addition & 1 deletion src/knockout/components/progress/buttons.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div data-bind="css: survey.css.progressButtonsListContainer">
<ul data-bind="foreach: survey.visiblePages, css: survey.css.progressButtonsList">
<li data-bind="css: $parent.getListElementCss($index), click: $parent.isListElementClickable($index) ? $parent.clickListElement.bind($parent, $index) : null">
<div data-bind="css: css.progressButtonsPageTitle, text: locNavigationTitle.koRenderedHtml() || name, attr: { title: locNavigationTitle.koRenderedHtml() || name }"></div>
<div data-bind="css: css.progressButtonsPageTitle, text: renderedNavigationTitle, attr: { title: renderedNavigationTitle }"></div>
<div data-bind="css: css.progressButtonsPageDescription, text: locNavigationDescription.koRenderedHtml(), attr: { title: locNavigationDescription.koRenderedHtml() }"></div>
</li>
</ul>
Expand Down
3 changes: 3 additions & 0 deletions src/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ export class PageModel extends PanelModelBase implements IPage {
this.locNavigationTitle.strChanged();
this.locNavigationDescription.strChanged();
}
public get renderedNavigationTitle(): string {
return this.locNavigationTitle.renderedHtml || this.title || this.name;
}
public get passed(): boolean {
return this.getPropertyValue("passed", false);
}
Expand Down
7 changes: 5 additions & 2 deletions src/panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,18 +327,21 @@ export class PanelModelBase extends SurveyElement<Question>
(this.showDescription && this.isDesignMode &&
settings.designMode.showEmptyDescriptions);
}
public localeChanged() {
public localeChanged(): void {
super.localeChanged();
for (var i = 0; i < this.elements.length; i++) {
(<Base>(<any>this.elements[i])).localeChanged();
}
}
public locStrsChanged() {
public locStrsChanged(): void {
super.locStrsChanged();
for (var i = 0; i < this.elements.length; i++) {
this.elements[i].locStrsChanged();
}
}
public get renderedNavigationTitle(): string {
return this.title || this.name;
}
/**
* Returns a character or text string that indicates a required panel/page.
* @see SurveyModel.requiredText
Expand Down
4 changes: 2 additions & 2 deletions src/react/reactSurveyProgressButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ export class SurveyProgressButtons extends SurveyNavigationBase {
>
<div
className={this.css.progressButtonsPageTitle}
title={page.navigationTitle || page.name}
title={page.renderedNavigationTitle}
>
{page.navigationTitle || page.name}
{page.renderedNavigationTitle}
</div>
<div
className={this.css.progressButtonsPageDescription}
Expand Down
2 changes: 1 addition & 1 deletion src/surveyToc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function createTOCListModel(survey: SurveyModel, onAction?: () => void) {
var items = (pagesSource || []).map(page => {
return new Action({
id: page.name,
title: ((<any>page)["navigationTitle"]) || page.title || page.name,
title: page.renderedNavigationTitle,
action: () => {
if (typeof document !== undefined && !!document.activeElement) {
!!(<any>document.activeElement).blur && (<any>document.activeElement).blur();
Expand Down
4 changes: 2 additions & 2 deletions src/vue/progressButtons.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
>
<div
:class="css.progressButtonsPageTitle"
:title="page.locNavigationTitle.renderedHtml || page.name"
:title="page.renderedNavigationTitle"
>
{{ page.locNavigationTitle.renderedHtml || page.name }}
{{ page.renderedNavigationTitle }}
</div>
<div
:class="css.progressButtonsPageDescription"
Expand Down
15 changes: 15 additions & 0 deletions tests/surveytests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,21 @@ QUnit.test(
);
}
);
QUnit.test("PageModel.renderedNavigationTitle", function (assert) {
const survey = new SurveyModel({
pages: [
{ name: "page1" },
{ name: "page2", title: "Page 2" },
{ name: "page3", title: "Page 3", navigationTitle: "NavPage 3" },
{ name: "page4", navigationTitle: "NavPage 4" },
]
});
assert.equal(survey.pages[0].renderedNavigationTitle, "page1", "page1");
assert.equal(survey.pages[1].renderedNavigationTitle, "Page 2", "page2");
assert.equal(survey.pages[2].renderedNavigationTitle, "NavPage 3", "page3");
assert.equal(survey.pages[3].renderedNavigationTitle, "NavPage 4", "page4");
});

QUnit.test("PageModel passed property", function (assert) {
var json = {
pages: [
Expand Down
Loading