Skip to content
This repository has been archived by the owner on Jun 12, 2024. It is now read-only.

fixed: loading to the wrong page if the first page contains no dn wid… #724

Merged
merged 1 commit into from
Dec 1, 2023
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
25 changes: 25 additions & 0 deletions public/js/src/module/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,31 @@ import reasons from './reasons';
import settings from './settings';
import gui from './gui';

// Contains fix for https://github.com/OpenClinica/enketo-express-oc/issues/720
// This function should be removed once PR https://github.com/enketo/enketo/pull/1286 is merged
// and published
pageModule.flipToPageContaining = function ($e) {
const e = $e[0];
const closestPage = e.closest('[role="page"]');

if (closestPage) {
this._flipTo(closestPage);
} else if (e.closest('.question')) {
// If $e is a comment question, and it is not inside a group, there will be no closestPage.
const referer = e.querySelector('[data-for]');
const ancestor = e.closest('.or-repeat, form.or');
if (referer && ancestor) {
const linkedQuestion = ancestor.querySelector(
`[name="${referer.dataset.for}"]`
);
if (linkedQuestion) {
this._flipTo(linkedQuestion.closest('[role="page"]'));
}
}
}
this.$toc.parent().find('.pages-toc__overlay').click();
};

/*
* The only thing we want to change in this function for OC,
* is to NOT flip to the next page when a repeat is the same as a page and
Expand Down
Loading