Skip to content

Commit

Permalink
fix: 🐛 updated spreadsheet skipping logic
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobiClark committed Dec 4, 2023
1 parent 4ec7fe3 commit 36f995f
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions scripts/guided-mode/guided-curate-dataset.js
Original file line number Diff line number Diff line change
Expand Up @@ -870,8 +870,7 @@ const savePageChanges = async (pageBeingLeftID) => {
// Skip the page where they confirm their log in and workspace because we should already have it
sodaJSONObj["digital-metadata"]["dataset-workspace"] = guidedGetCurrentUserWorkSpace();
guidedSkipPage("guided-pennsieve-intro-tab");
// Skip the subject structure import page since the user is starting from Pennsieve
guidedSkipPage("guided-subject-structure-spreadsheet-importation-tab");

}

//Skip this page becausae we should not come back to it
Expand Down Expand Up @@ -1133,7 +1132,6 @@ const savePageChanges = async (pageBeingLeftID) => {
const datasetHasCode = sodaJSONObj["dataset-contains-code"];

if (datasetHasSubjects) {
guidedUnSkipPage("guided-subject-structure-spreadsheet-importation-tab");
guidedUnSkipPage("guided-subjects-addition-tab");
guidedUnSkipPage("guided-subjects-pooling-tab");
guidedUnSkipPage("guided-samples-addition-tab");
Expand All @@ -1144,7 +1142,6 @@ const savePageChanges = async (pageBeingLeftID) => {
guidedUnSkipPage("guided-create-subjects-metadata-tab");
guidedUnSkipPage("guided-create-samples-metadata-tab");
} else {
guidedSkipPage("guided-subject-structure-spreadsheet-importation-tab");
guidedSkipPage("guided-subjects-addition-tab");
guidedSkipPage("guided-subjects-pooling-tab");
guidedSkipPage("guided-samples-addition-tab");
Expand Down Expand Up @@ -1370,10 +1367,7 @@ const savePageChanges = async (pageBeingLeftID) => {
}
}

if (userChoseToEnterSubsSamsPoolsManually) {
// Skip the page so the user can add subjects manually
guidedSkipPage("guided-subject-structure-spreadsheet-importation-tab");
}

}

if (pageBeingLeftID === "guided-primary-data-organization-tab") {
Expand Down Expand Up @@ -5108,6 +5102,16 @@ const openPage = async (targetPageID) => {
importProgressCircle.classList.add("hidden");
}

if (targetPageID === "guided-dataset-structure-intro-capsule") {
if (getExistingSubjectNames().length === 0 &&
sodaJSONObj["starting-point"]["type"] != "bf" &&
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 = sodaJSONObj["dataset-structure-spreadsheet-path"];
setUiBasedOnSavedDatasetStructurePath(savedSpreadSheetPath);
Expand Down Expand Up @@ -5286,6 +5290,7 @@ const openPage = async (targetPageID) => {
}

if (targetPageID === "guided-subjects-addition-tab") {
guidedSkipPage("guided-subject-structure-spreadsheet-importation-tab")
renderSubjectsTable();
}

Expand Down Expand Up @@ -7828,11 +7833,6 @@ const patchPreviousGuidedModeVersions = async () => {
sodaJSONObj["cuartion-mode"] = "guided";
}

// Skip the subject spreadsheet importatin page if subjects have already been imported
if (getExistingSubjectNames().length > 0) {
guidedSkipPage("guided-subject-structure-spreadsheet-importation-tab");
}

// If no other conditions are met, return the page the user was last on
return sodaJSONObj["page-before-exit"];
};
Expand Down Expand Up @@ -11592,8 +11592,6 @@ document
<b>Note:</b> You will not be able to return to this step once you proceed.
`
);
// Skip the spreadsheet importation page so the user can't go back to it
guidedSkipPage("guided-subject-structure-spreadsheet-importation-tab");
$("#guided-next-button").click();
});

Expand Down Expand Up @@ -15790,11 +15788,14 @@ $("#guided-save-banner-image").click(async (event) => {
const getNextPageNotSkipped = (currentPageID) => {
const parentContainer = document.getElementById(currentPageID).closest(".guided--parent-tab");
const siblingPages = getNonSkippedGuidedModePages(parentContainer).map((page) => page.id);
console.log("siblingPages", siblingPages)

const currentPageIndex = siblingPages.indexOf(currentPageID);
if (currentPageIndex != siblingPages.length - 1) {
console.log("here")
return document.getElementById(siblingPages[currentPageIndex + 1]);
} else {
console.log("there")
const nextParentContainer = parentContainer.nextElementSibling;
return getNonSkippedGuidedModePages(nextParentContainer)[0];
}
Expand Down Expand Up @@ -15825,6 +15826,7 @@ $("#guided-next-button").on("click", async function () {
//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(CURRENT_PAGE.id);
console.log("targetPage**************************", targetPage);
let targetPageID = targetPage.id;

await openPage(targetPageID);
Expand Down

0 comments on commit 36f995f

Please sign in to comment.