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

Fix: _loopStyle bad configuration (fixes #62) #63

Merged
merged 2 commits into from
Apr 23, 2024
Merged
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
30 changes: 8 additions & 22 deletions js/PageNavModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,30 +142,16 @@ class PageNavModel extends ComponentModel {

getPages() {
const loopStyle = this.get('_loopStyle');
if (!loopStyle) return [];

let loop = false;
let descendants;
let currentMenu;

switch (loopStyle) {
case 'allPages':
loop = true;
descendants = Adapt.course.getAllDescendantModels(true);
break;
default:
currentMenu = this.getCurrentMenu();
descendants = currentMenu.getAllDescendantModels(true);
}

if (loop) {
// Create a double copy to allow loop searching
let descendants = (loopStyle === 'allPages')
? Adapt.course.getAllDescendantModels(true)
// For siblings and none
: this.getCurrentMenu().getAllDescendantModels(true);
const isLooping = Boolean(loopStyle && loopStyle !== 'none');
if (isLooping) {
// Create a double copy to allow loop searching to fall over the end
descendants = descendants.concat(descendants);
oliverfoster marked this conversation as resolved.
Show resolved Hide resolved
}

return descendants.filter(model => {
return model.get('_type') === 'page';
});
return descendants.filter(model => model.get('_type') === 'page');
}

getClose() {
Expand Down