From 82153591721b137d02a1d03d230e02fc70b5f080 Mon Sep 17 00:00:00 2001 From: Andrew Crowther Date: Thu, 4 Dec 2025 14:09:23 -0500 Subject: [PATCH 1/6] CARDS-2813: Improve progress bar progression - Remove buffer for current page - Add a half page pagging to the start and end to show some progress on the first page and when saving --- .../src/questionnaire/FormPagination.jsx | 36 +++++++++++-------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/modules/data-entry/src/main/frontend/src/questionnaire/FormPagination.jsx b/modules/data-entry/src/main/frontend/src/questionnaire/FormPagination.jsx index f7e73f7bff..f74691909e 100644 --- a/modules/data-entry/src/main/frontend/src/questionnaire/FormPagination.jsx +++ b/modules/data-entry/src/main/frontend/src/questionnaire/FormPagination.jsx @@ -77,7 +77,11 @@ function FormPagination (props) { let [ activePage, setActivePage ] = useState(0); let [ direction, setDirection ] = useState(1); let [ nextActivePage, setNextActivePage ] = useState(); + let [ progress, setProgress ] = useState(0); const DIRECTION_NEXT = 1, DIRECTION_PREV = -1; + // The amount of the progress bar that should be complete on page 1 and incomplete on an unsaved last page + // Expressed as a multiple of a normal page size + const PROGRESS_BAR_PADDING = 0.5; let previousEntryType; let questionIndex = 0; @@ -207,6 +211,19 @@ function FormPagination (props) { } }, [saveInProgress, pendingSubmission, disableProgress, nextActivePage, direction, activePage]); + useEffect(() => { + if (activePage != null && pages != null) { + // The pagination should be divided into multiple sections: + // - lastValidPage() sections for page by page progress + // - 1 padding section for the initial progress on the first page + // - 1 padding section for when the last page has been saved + // The MaterialUI progress bar expects progress to be out of 100 + const pageSize = 100 / (lastValidPage() + (2 * PROGRESS_BAR_PADDING)); + const paddingSize = pageSize * PROGRESS_BAR_PADDING; + setProgress(paddingSize + (pageSize * activePage) + (savedLastPage ? paddingSize : 0)) + } + }, [activePage, pages, savedLastPage]) + let saveButton =