diff --git a/src/renderer/src/main.js b/src/renderer/src/main.js
index e4ba94e44..a59d39390 100644
--- a/src/renderer/src/main.js
+++ b/src/renderer/src/main.js
@@ -8,10 +8,11 @@ import "./assets/nav";
import "./scripts/client";
import "./scripts/globals";
import "./scripts/guided-mode/buttons/radioButtons";
-import "./scripts/guided-mode/pageNavigation/pageLoading";
+import "./scripts/guided-mode/pages/pageLoading";
import "./scripts/guided-mode/pages/curationPreparation/openPage";
import "./scripts/guided-mode/pages/openPage";
import "./scripts/guided-mode/guided-curate-dataset";
+import "./scripts/guided-mode/pages/navigate";
import "./scripts/others/renderer";
import "./scripts/metadata-files/submission";
import "./scripts/manage-dataset/manage-dataset";
diff --git a/src/renderer/src/scripts/guided-mode/guided-curate-dataset.js b/src/renderer/src/scripts/guided-mode/guided-curate-dataset.js
index c50e1a439..ca6f675c1 100644
--- a/src/renderer/src/scripts/guided-mode/guided-curate-dataset.js
+++ b/src/renderer/src/scripts/guided-mode/guided-curate-dataset.js
@@ -1,7 +1,7 @@
// // sourcery skip: merge-nested-ifs
import { existingDataset, modifyDataset } from "../../assets/lotties/lotties";
-import { guidedSetNavLoadingState } from "./pageNavigation/pageLoading";
+import { guidedSetNavLoadingState } from "./pages/pageLoading";
import { guidedSaveProgress, savePageChanges } from "./pages/savePageChanges";
import { openPage } from "./pages/openPage";
import {
@@ -9,7 +9,7 @@ import {
guidedResetSkippedPages,
guidedSkipPage,
guidedUnSkipPage,
-} from "./pageNavigation/pageSkipping";
+} from "./pages/pageSkipping";
import { resetLazyLoading, guidedUnLockSideBar } from "../../assets/nav";
import determineDatasetLocation from "../analytics/analytics-utils";
import { clientError, userErrorMessage } from "../others/http-error-handler/error-handler";
@@ -532,65 +532,6 @@ for (const infoDropdown of Array.from(infoDropdowns)) {
});
}
-const guidedSaveAndExit = async () => {
- if (!window.sodaJSONObj["digital-metadata"]["name"]) {
- // If a progress file has not been created, then we don't need to save anything
- guidedTransitionToHome();
- return;
- }
- const { value: returnToGuidedHomeScreen } = await Swal.fire({
- title: "Are you sure?",
- text: `Exiting Guided Mode will discard any changes you have made on the
- current page. You will be taken back to the homescreen, where you will be able
- to continue the current dataset you are curating which will be located under datasets
- in progress.`,
- icon: "warning",
- showCancelButton: true,
- confirmButtonColor: "#3085d6",
- cancelButtonColor: "#d33",
- confirmButtonText: "Exit guided mode",
- heightAuto: false,
- backdrop: "rgba(0,0,0,0.4)",
- });
- if (returnToGuidedHomeScreen) {
- const currentPageID = window.CURRENT_PAGE.id;
-
- try {
- await savePageChanges(currentPageID);
- } catch (error) {
- const pageWithErrorName = window.CURRENT_PAGE.dataset.pageName;
-
- const { value: continueWithoutSavingCurrPageChanges } = await Swal.fire({
- title: "The current page was not able to be saved before exiting",
- html: `The following error${
- error.length > 1 ? "s" : ""
- } occurred when attempting to save the ${pageWithErrorName} page:
-
-
-
- ${error.map((error) => `- ${error.message}
`).join("")}
-
-
- Would you like to exit without saving the changes to the current page?`,
- icon: "info",
- showCancelButton: true,
- confirmButtonText: "Yes, exit without saving",
- cancelButtonText: "No, address errors before saving",
- focusCancel: true,
- heightAuto: false,
- backdrop: "rgba(0,0,0, 0.4)",
- width: 700,
- });
- if (continueWithoutSavingCurrPageChanges) {
- guidedTransitionToHome();
- } else {
- return;
- }
- }
- guidedTransitionToHome();
- }
-};
-
//Initialize description tagify variables as null
//to make them accessible to functions outside of $(document).ready
let guidedDatasetKeywordsTagify = null;
@@ -657,21 +598,6 @@ const guidedTransitionFromHome = async () => {
guidedResetSkippedPages();
};
-const guidedTransitionToHome = () => {
- guidedUnLockSideBar();
- window.guidedPrepareHomeScreen();
-
- document.getElementById("guided-home").classList.remove("hidden");
- // Hide all of the parent tabs
- const guidedParentTabs = Array.from(document.querySelectorAll(".guided--parent-tab"));
- for (const guidedParentTab of guidedParentTabs) {
- guidedParentTab.classList.add("hidden");
- }
- window.CURRENT_PAGE = undefined;
-
- document.getElementById("guided-footer-div").classList.add("hidden");
-};
-
const readDirAsync = async (path) => {
let result = await window.fs.readdir(path);
return result;
@@ -10023,118 +9949,6 @@ $("#guided-save-banner-image").click(async () => {
}
});
-const getNextPageNotSkipped = (currentPageID) => {
- const parentContainer = document.getElementById(currentPageID).closest(".guided--parent-tab");
- const siblingPages = getNonSkippedGuidedModePages(parentContainer).map((page) => page.id);
-
- const currentPageIndex = siblingPages.indexOf(currentPageID);
- if (currentPageIndex != siblingPages.length - 1) {
- return document.getElementById(siblingPages[currentPageIndex + 1]);
- } else {
- const nextParentContainer = parentContainer.nextElementSibling;
- return getNonSkippedGuidedModePages(nextParentContainer)[0];
- }
-};
-
-//next button click handler
-$("#guided-next-button").on("click", async function () {
- console.log("Next button clicked");
- //Get the ID of the current page to handle actions on page leave (next button pressed)
- window.pageBeingLeftID = window.CURRENT_PAGE.id;
-
- if (window.pageBeingLeftID === "guided-dataset-generation-tab") {
- guidedUnSkipPage("guided-dataset-dissemination-tab");
- await openPage("guided-dataset-dissemination-tab");
- return;
- }
-
- try {
- console.log("About to save");
- await savePageChanges(window.pageBeingLeftID);
- console.log("Past save changes");
-
- //Mark page as completed in JSONObj so we know what pages to load when loading local saves
- //(if it hasn't already been marked complete)
- if (!window.sodaJSONObj["completed-tabs"].includes(window.pageBeingLeftID)) {
- window.sodaJSONObj["completed-tabs"].push(window.pageBeingLeftID);
- }
-
- //NAVIGATE TO NEXT PAGE + CHANGE ACTIVE TAB/SET ACTIVE PROGRESSION TAB
- //if more tabs in parent tab, go to next tab and update capsule
- let targetPage = getNextPageNotSkipped(window.CURRENT_PAGE.id);
- let targetPageID = targetPage.id;
-
- console.log("Navigating to next page", targetPageID);
-
- await openPage(targetPageID);
- } catch (error) {
- window.log.error(error);
- if (Array.isArray(error)) {
- error.map((error) => {
- // get the total number of words in error.message
- if (error.type === "notyf") {
- window.notyf.open({
- duration: "7000",
- type: "error",
- message: error.message,
- });
- }
-
- if (error.type === "swal") {
- Swal.fire({
- icon: "error",
- title: error.title,
- html: error.message,
- width: 600,
- heightAuto: false,
- backdrop: "rgba(0,0,0, 0.4)",
- confirmButtonText: `OK`,
- focusConfirm: true,
- allowOutsideClick: false,
- });
- }
- });
- }
- }
-});
-
-// Save and exit button click handlers
-document.getElementById("guided-button-save-and-exit").addEventListener("click", async () => {
- await guidedSaveAndExit();
-});
-
-const getPrevPageNotSkipped = (currentPageID) => {
- const parentContainer = document.getElementById(currentPageID).closest(".guided--parent-tab");
- const siblingPages = getNonSkippedGuidedModePages(parentContainer).map((page) => page.id);
- const currentPageIndex = siblingPages.indexOf(currentPageID);
- if (currentPageIndex != 0) {
- return document.getElementById(siblingPages[currentPageIndex - 1]);
- } else {
- const prevParentContainer = parentContainer.previousElementSibling;
- const prevParentContainerPages = getNonSkippedGuidedModePages(prevParentContainer);
- return prevParentContainerPages[prevParentContainerPages.length - 1];
- }
-};
-
-//back button click handler
-$("#guided-back-button").on("click", async () => {
- window.pageBeingLeftID = window.CURRENT_PAGE.id;
- const targetPage = getPrevPageNotSkipped(window.pageBeingLeftID);
-
- // If the target page when clicking the back button does not exist, then we are on the first not skipped page.
- // In this case, we want to save and exit guided mode.
- if (!targetPage) {
- await guidedSaveAndExit();
- return;
- }
-
- // Get the id of the target page
- const targetPageID = targetPage.id;
-
- // open the target page
- await openPage(targetPageID);
-});
-
//tagify initializations
const guidedOtherFundingSourcesInput = document.getElementById("guided-ds-other-funding");
guidedOtherFundingsourcesTagify = new Tagify(guidedOtherFundingSourcesInput, {
diff --git a/src/renderer/src/scripts/guided-mode/pages/curationPreparation/openPage.js b/src/renderer/src/scripts/guided-mode/pages/curationPreparation/openPage.js
index 316a66c8c..365ad80b9 100644
--- a/src/renderer/src/scripts/guided-mode/pages/curationPreparation/openPage.js
+++ b/src/renderer/src/scripts/guided-mode/pages/curationPreparation/openPage.js
@@ -9,7 +9,7 @@ import api from "../../../others/api/api";
import { clientError } from "../../../others/http-error-handler/error-handler";
import { guidedShowOptionalRetrySwal } from "../../swals/helperSwals";
import { userErrorMessage } from "../../../others/http-error-handler/error-handler";
-import { setPageLoadingState } from "../../pageNavigation/pageLoading";
+import { setPageLoadingState } from "../pageLoading.js";
import { setSelectedEntities } from "../../../../stores/slices/datasetContentSelectorSlice.js";
import client from "../../../client";
diff --git a/src/renderer/src/scripts/guided-mode/pages/curationPreparation/savePage.js b/src/renderer/src/scripts/guided-mode/pages/curationPreparation/savePage.js
index 96b9027fa..557420884 100644
--- a/src/renderer/src/scripts/guided-mode/pages/curationPreparation/savePage.js
+++ b/src/renderer/src/scripts/guided-mode/pages/curationPreparation/savePage.js
@@ -1,4 +1,4 @@
-import { guidedSkipPage, guidedUnSkipPage } from "../../pageNavigation/pageSkipping";
+import { guidedSkipPage, guidedUnSkipPage } from "../pageSkipping";
import useGlobalStore from "../../../../stores/globalStore";
let homeDir = await window.electron.ipcRenderer.invoke("get-app-path", "home");
diff --git a/src/renderer/src/scripts/guided-mode/pages/datasetStructure/openPage.js b/src/renderer/src/scripts/guided-mode/pages/datasetStructure/openPage.js
new file mode 100644
index 000000000..b540ae3d4
--- /dev/null
+++ b/src/renderer/src/scripts/guided-mode/pages/datasetStructure/openPage.js
@@ -0,0 +1,19 @@
+import { guidedSkipPage, guidedUnSkipPage } from "../pageSkipping";
+
+export const openPageDatasetStructure = async (targetPageID) => {
+ if (targetPageID === "guided-dataset-structure-intro-tab") {
+ // Handle whether or not the spreadsheet importation page should be skipped
+ // Note: this is done here to centralize the logic for skipping the page
+ // The page is unskipped only if the user has not added any subjects,
+ // indicated that they will be adding subjects, and the user is not starting from Pennsieve
+ if (
+ window.getExistingSubjectNames().length === 0 &&
+ window.sodaJSONObj["starting-point"]["type"] != "bf" &&
+ window.sodaJSONObj["button-config"]["dataset-contains-subjects"] === "yes"
+ ) {
+ guidedUnSkipPage("guided-subject-structure-spreadsheet-importation-tab");
+ } else {
+ guidedSkipPage("guided-subject-structure-spreadsheet-importation-tab");
+ }
+ }
+};
diff --git a/src/renderer/src/scripts/guided-mode/pages/navigate.js b/src/renderer/src/scripts/guided-mode/pages/navigate.js
new file mode 100644
index 000000000..0822755c5
--- /dev/null
+++ b/src/renderer/src/scripts/guided-mode/pages/navigate.js
@@ -0,0 +1,169 @@
+import { openPage } from "./openPage";
+import { savePageChanges } from "./savePageChanges";
+import { guidedUnSkipPage, getNextPageNotSkipped, getPrevPageNotSkipped } from "./pageSkipping";
+import { guidedUnLockSideBar } from "../../../assets/nav";
+import Swal from "sweetalert2";
+
+while (!window.baseHtmlLoaded) {
+ await new Promise((resolve) => setTimeout(resolve, 100));
+}
+
+//next button click handler
+$("#guided-next-button").on("click", async function () {
+ console.log("Next button clicked");
+ //Get the ID of the current page to handle actions on page leave (next button pressed)
+ window.pageBeingLeftID = window.CURRENT_PAGE.id;
+
+ if (window.pageBeingLeftID === "guided-dataset-generation-tab") {
+ guidedUnSkipPage("guided-dataset-dissemination-tab");
+ await openPage("guided-dataset-dissemination-tab");
+ return;
+ }
+
+ try {
+ console.log("About to save");
+ await savePageChanges(window.pageBeingLeftID);
+ console.log("Past save changes");
+
+ //Mark page as completed in JSONObj so we know what pages to load when loading local saves
+ //(if it hasn't already been marked complete)
+ if (!window.sodaJSONObj["completed-tabs"].includes(window.pageBeingLeftID)) {
+ window.sodaJSONObj["completed-tabs"].push(window.pageBeingLeftID);
+ }
+
+ //NAVIGATE TO NEXT PAGE + CHANGE ACTIVE TAB/SET ACTIVE PROGRESSION TAB
+ //if more tabs in parent tab, go to next tab and update capsule
+ let targetPage = getNextPageNotSkipped(window.CURRENT_PAGE.id);
+ let targetPageID = targetPage.id;
+
+ console.log("Navigating to next page", targetPageID);
+
+ await openPage(targetPageID);
+ } catch (error) {
+ window.log.error(error);
+ if (Array.isArray(error)) {
+ error.map((error) => {
+ // get the total number of words in error.message
+ if (error.type === "notyf") {
+ window.notyf.open({
+ duration: "7000",
+ type: "error",
+ message: error.message,
+ });
+ }
+
+ if (error.type === "swal") {
+ Swal.fire({
+ icon: "error",
+ title: error.title,
+ html: error.message,
+ width: 600,
+ heightAuto: false,
+ backdrop: "rgba(0,0,0, 0.4)",
+ confirmButtonText: `OK`,
+ focusConfirm: true,
+ allowOutsideClick: false,
+ });
+ }
+ });
+ }
+ }
+});
+
+//back button click handler
+$("#guided-back-button").on("click", async () => {
+ window.pageBeingLeftID = window.CURRENT_PAGE.id;
+ const targetPage = getPrevPageNotSkipped(window.pageBeingLeftID);
+
+ // If the target page when clicking the back button does not exist, then we are on the first not skipped page.
+ // In this case, we want to save and exit guided mode.
+ if (!targetPage) {
+ await guidedSaveAndExit();
+ return;
+ }
+
+ // Get the id of the target page
+ const targetPageID = targetPage.id;
+
+ // open the target page
+ await openPage(targetPageID);
+});
+
+const guidedSaveAndExit = async () => {
+ if (!window.sodaJSONObj["digital-metadata"]["name"]) {
+ // If a progress file has not been created, then we don't need to save anything
+ guidedTransitionToHome();
+ return;
+ }
+ const { value: returnToGuidedHomeScreen } = await Swal.fire({
+ title: "Are you sure?",
+ text: `Exiting Guided Mode will discard any changes you have made on the
+ current page. You will be taken back to the homescreen, where you will be able
+ to continue the current dataset you are curating which will be located under datasets
+ in progress.`,
+ icon: "warning",
+ showCancelButton: true,
+ confirmButtonColor: "#3085d6",
+ cancelButtonColor: "#d33",
+ confirmButtonText: "Exit guided mode",
+ heightAuto: false,
+ backdrop: "rgba(0,0,0,0.4)",
+ });
+ if (returnToGuidedHomeScreen) {
+ const currentPageID = window.CURRENT_PAGE.id;
+
+ try {
+ await savePageChanges(currentPageID);
+ } catch (error) {
+ const pageWithErrorName = window.CURRENT_PAGE.dataset.pageName;
+
+ const { value: continueWithoutSavingCurrPageChanges } = await Swal.fire({
+ title: "The current page was not able to be saved before exiting",
+ html: `The following error${
+ error.length > 1 ? "s" : ""
+ } occurred when attempting to save the ${pageWithErrorName} page:
+
+
+
+ ${error.map((error) => `- ${error.message}
`).join("")}
+
+
+ Would you like to exit without saving the changes to the current page?`,
+ icon: "info",
+ showCancelButton: true,
+ confirmButtonText: "Yes, exit without saving",
+ cancelButtonText: "No, address errors before saving",
+ focusCancel: true,
+ heightAuto: false,
+ backdrop: "rgba(0,0,0, 0.4)",
+ width: 700,
+ });
+ if (continueWithoutSavingCurrPageChanges) {
+ guidedTransitionToHome();
+ } else {
+ return;
+ }
+ }
+ guidedTransitionToHome();
+ }
+};
+
+const guidedTransitionToHome = () => {
+ guidedUnLockSideBar();
+ window.guidedPrepareHomeScreen();
+
+ document.getElementById("guided-home").classList.remove("hidden");
+ // Hide all of the parent tabs
+ const guidedParentTabs = Array.from(document.querySelectorAll(".guided--parent-tab"));
+ for (const guidedParentTab of guidedParentTabs) {
+ guidedParentTab.classList.add("hidden");
+ }
+ window.CURRENT_PAGE = undefined;
+
+ document.getElementById("guided-footer-div").classList.add("hidden");
+};
+
+// Save and exit button click handlers
+document.getElementById("guided-button-save-and-exit").addEventListener("click", async () => {
+ await guidedSaveAndExit();
+});
diff --git a/src/renderer/src/scripts/guided-mode/pages/openPage.js b/src/renderer/src/scripts/guided-mode/pages/openPage.js
index 7ec995dad..d817eb8f7 100644
--- a/src/renderer/src/scripts/guided-mode/pages/openPage.js
+++ b/src/renderer/src/scripts/guided-mode/pages/openPage.js
@@ -4,10 +4,10 @@ import {
updateGuidedRadioButtonsFromJSON,
} from "../buttons/radioButtons.js";
import { externallySetSearchFilterValue } from "../../../stores/slices/datasetTreeViewSlice.js";
-import { guidedSetNavLoadingState } from "../pageNavigation/pageLoading.js";
+import { guidedSetNavLoadingState } from "./pageLoading.js";
import Swal from "sweetalert2";
import { userErrorMessage } from "../../others/http-error-handler/error-handler.js";
-import { getNonSkippedGuidedModePages } from "../pageNavigation/pageSkipping.js";
+import { getNonSkippedGuidedModePages } from "./pageSkipping.js";
import { startOrStopAnimationsInContainer } from "../lotties/lottie.js";
// Function that handles the visibility of the back button
@@ -457,22 +457,6 @@ export const openPage = async (targetPageID) => {
// }
// }
- // if (targetPageID === "guided-dataset-structure-intro-tab") {
- // // Handle whether or not the spreadsheet importation page should be skipped
- // // Note: this is done here to centralize the logic for skipping the page
- // // The page is unskipped only if the user has not added any subjects,
- // // indicated that they will be adding subjects, and the user is not starting from Pennsieve
- // if (
- // window.getExistingSubjectNames().length === 0 &&
- // window.sodaJSONObj["starting-point"]["type"] != "bf" &&
- // window.sodaJSONObj["button-config"]["dataset-contains-subjects"] === "yes"
- // ) {
- // guidedUnSkipPage("guided-subject-structure-spreadsheet-importation-tab");
- // } else {
- // guidedSkipPage("guided-subject-structure-spreadsheet-importation-tab");
- // }
- // }
-
// if (targetPageID === "guided-subject-structure-spreadsheet-importation-tab") {
// const savedSpreadSheetPath = window.sodaJSONObj["dataset-structure-spreadsheet-path"];
// setUiBasedOnSavedDatasetStructurePath(savedSpreadSheetPath);
diff --git a/src/renderer/src/scripts/guided-mode/pageNavigation/pageLoading.js b/src/renderer/src/scripts/guided-mode/pages/pageLoading.js
similarity index 100%
rename from src/renderer/src/scripts/guided-mode/pageNavigation/pageLoading.js
rename to src/renderer/src/scripts/guided-mode/pages/pageLoading.js
diff --git a/src/renderer/src/scripts/guided-mode/pageNavigation/pageSkipping.js b/src/renderer/src/scripts/guided-mode/pages/pageSkipping.js
similarity index 59%
rename from src/renderer/src/scripts/guided-mode/pageNavigation/pageSkipping.js
rename to src/renderer/src/scripts/guided-mode/pages/pageSkipping.js
index d7682381e..cee926961 100644
--- a/src/renderer/src/scripts/guided-mode/pageNavigation/pageSkipping.js
+++ b/src/renderer/src/scripts/guided-mode/pages/pageSkipping.js
@@ -64,3 +64,29 @@ export const getNonSkippedGuidedModePages = (parentElementToGetChildrenPagesFrom
return nonSkippedChildPages;
};
+
+export const getNextPageNotSkipped = (currentPageID) => {
+ const parentContainer = document.getElementById(currentPageID).closest(".guided--parent-tab");
+ const siblingPages = getNonSkippedGuidedModePages(parentContainer).map((page) => page.id);
+
+ const currentPageIndex = siblingPages.indexOf(currentPageID);
+ if (currentPageIndex != siblingPages.length - 1) {
+ return document.getElementById(siblingPages[currentPageIndex + 1]);
+ } else {
+ const nextParentContainer = parentContainer.nextElementSibling;
+ return getNonSkippedGuidedModePages(nextParentContainer)[0];
+ }
+};
+
+export const getPrevPageNotSkipped = (currentPageID) => {
+ const parentContainer = document.getElementById(currentPageID).closest(".guided--parent-tab");
+ const siblingPages = getNonSkippedGuidedModePages(parentContainer).map((page) => page.id);
+ const currentPageIndex = siblingPages.indexOf(currentPageID);
+ if (currentPageIndex != 0) {
+ return document.getElementById(siblingPages[currentPageIndex - 1]);
+ } else {
+ const prevParentContainer = parentContainer.previousElementSibling;
+ const prevParentContainerPages = getNonSkippedGuidedModePages(prevParentContainer);
+ return prevParentContainerPages[prevParentContainerPages.length - 1];
+ }
+};
diff --git a/src/renderer/src/scripts/guided-mode/pages/savePageChanges.js b/src/renderer/src/scripts/guided-mode/pages/savePageChanges.js
index eb2d98f5a..0cea7479b 100644
--- a/src/renderer/src/scripts/guided-mode/pages/savePageChanges.js
+++ b/src/renderer/src/scripts/guided-mode/pages/savePageChanges.js
@@ -1,10 +1,6 @@
-import { guidedSetNavLoadingState } from "../pageNavigation/pageLoading";
+import { guidedSetNavLoadingState } from "./pageLoading";
import { getDatasetEntityObj } from "../../../stores/slices/datasetEntitySelectorSlice";
-import {
- guidedSkipPage,
- guidedUnSkipPage,
- getNonSkippedGuidedModePages,
-} from "../pageNavigation/pageSkipping";
+import { guidedSkipPage, guidedUnSkipPage, getNonSkippedGuidedModePages } from "./pageSkipping";
import { userErrorMessage } from "../../others/http-error-handler/error-handler";
import { startOrStopAnimationsInContainer } from "../lotties/lottie";
import api from "../../others/api/api";
diff --git a/src/renderer/src/scripts/guided-mode/sidebar/sidebar.js b/src/renderer/src/scripts/guided-mode/sidebar/sidebar.js
new file mode 100644
index 000000000..e69de29bb