Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
 into staging
  • Loading branch information
aaronm-2112 committed Jan 19, 2024
2 parents ecfb79a + 08746d6 commit dce2c3e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
24 changes: 14 additions & 10 deletions src/renderer/src/scripts/guided-mode/guided-curate-dataset.js
Original file line number Diff line number Diff line change
Expand Up @@ -9216,8 +9216,12 @@ window.openGuidedEditContributorSwal = async (contibuttorOrcidToEdit) => {
);
}

// If a contributor has already been marked as Principal Investigator, make sure that the
// current contributor is the one marked as Principal Investigator
// otherwise, show an error message
if (contributorRoles.includes("PrincipalInvestigator")) {
if (getContributorMarkedAsPrincipalInvestigator()) {
const currentPIsOrcid = getContributorMarkedAsPrincipalInvestigator();
if (currentPIsOrcid && currentPIsOrcid !== contributorOrcid) {
return Swal.showValidationMessage(
"Only one contributor can be marked as Principal Investigator"
);
Expand Down Expand Up @@ -9278,7 +9282,7 @@ const handleAddContributorHeaderUI = () => {
return !existingContributorORCiDs.includes(contributor.ORCiD);
});

// If no stored contribturs are found, use the default header
// If no stored contributors are found, use the default header
if (locallyStoredContributorArray.length === 0) {
return `
<label class="guided--form-label centered mb-md" style="font-size: 1em !important;">
Expand All @@ -9288,9 +9292,9 @@ const handleAddContributorHeaderUI = () => {
}

const contributorOptions = locallyStoredContributorArray
.filter((contribturo) => {
.filter((contributor) => {
// Filter out any contributors that have already been added by ORCID
return !existingContributorORCiDs.includes(contribturo.ORCiD);
return !existingContributorORCiDs.includes(contributor.ORCiD);
})
.map((contributor) => {
return `
Expand Down Expand Up @@ -9626,15 +9630,15 @@ const switchOrderOfContributors = (draggedOrcid, targetOrcid) => {
// Constants used for drag and drop functionality for contributors
let draggedRow;
let targetRow;
const handleContributorDragStart = (event) => {
window.handleContributorDragStart = (event) => {
draggedRow = event.target.closest("tr");
};
const handleContributorDragOver = (event) => {
window.handleContributorDragOver = (event) => {
event.preventDefault();
targetRow = event.target.closest("tr");
};

const handleContributorDrop = (event) => {
window.handleContributorDrop = (event) => {
event.preventDefault();
if (targetRow === draggedRow) {
return;
Expand All @@ -9658,9 +9662,9 @@ const generateContributorTableRow = (contributorObj, contributorIndex) => {
<tr
data-contributor-orcid=${contributorOrcid}
draggable="true"
ondragstart="handleContributorDragStart(event)"
ondragover="handleContributorDragOver(event)"
ondragend="handleContributorDrop(event)"
ondragstart="window.handleContributorDragStart(event)"
ondragover="window.handleContributorDragOver(event)"
ondragend="window.handleContributorDrop(event)"
style="cursor: move;"
>
<td class="middle aligned collapsing text-center">
Expand Down
8 changes: 4 additions & 4 deletions src/renderer/src/scripts/others/contributor-storage.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
while (!window.htmlPagesAdded) {
await new Promise((resolve) => setTimeout(resolve, 100))
await new Promise((resolve) => setTimeout(resolve, 100));
}


// Save the contributors array to the JSON file
const saveStoredContributors = (contributors) => {
try {
Expand All @@ -16,9 +15,11 @@ const saveStoredContributors = (contributors) => {
// If the file doesn't exist, return an empty array
window.loadStoredContributors = () => {
try {
const contributorFileData = window.fs.readFileSync(window.storedContributorsPath);
const contributorFileData = window.fs.readFileSync(window.storedContributorsPath, "utf8");
return JSON.parse(contributorFileData);
} catch (err) {
window.log.info("Error loading stored contributors file: " + err);
window.log.info("Returning empty array instead");
return [];
}
};
Expand Down Expand Up @@ -87,4 +88,3 @@ window.addOrUpdateStoredContributor = (
// Write the updated array to the JSON file
saveStoredContributors(storedContributorsArray);
};

0 comments on commit dce2c3e

Please sign in to comment.