Skip to content

Commit

Permalink
fix: remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobiClark committed Jan 30, 2025
1 parent fc2ded9 commit 8e6c3c8
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 332 deletions.
22 changes: 0 additions & 22 deletions src/renderer/src/assets/css/guided.css
Original file line number Diff line number Diff line change
Expand Up @@ -627,28 +627,6 @@
background-color: var(--color-light-green);
}

.guided--capsule-container-sub-page {
display: flex;
justify-content: center;
align-items: center;
margin-top: 10px;
margin-bottom: 10px;
}
.guided--capsule-sub-page {
height: 5px;
width: 50px;
margin-left: 5px;
margin-right: 5px;
background-color: #d5eaff;
border: none;
display: inline-block;
cursor: pointer;
transform: skewx(-25deg);
}
.guided--capsule-sub-page.active {
background-color: #007bff !important;
}

.guided--form-label {
width: 100%;
margin: 0 0 0.45rem 0;
Expand Down
310 changes: 0 additions & 310 deletions src/renderer/src/scripts/guided-mode/guided-curate-dataset.js
Original file line number Diff line number Diff line change
Expand Up @@ -10273,228 +10273,6 @@ window.openCopySampleMetadataPopup = async () => {
});
};

window.specifySubject = (event, subjectNameInput) => {
if (event.which == 13) {
try {
const subjectName = `sub-${subjectNameInput.val().trim()}`;
const subjectNameElement = `
<div class="space-between w-100">
<span class="subject-id">${subjectName}</span>
<i
class="far fa-edit"
style="cursor: pointer; margin-top: .2rem;"
onclick="window.openSubjectRenameInput($(this))"
>
</i>
</div>
`;
const subjectIdCellToAddNameTo = subjectNameInput.parent();
const trashCanElement =
subjectIdCellToAddNameTo[0].parentElement.nextElementSibling.children[0];
trashCanElement.style.display = "block";

if (subjectName.length > 0) {
const subjectNameIsValid = window.evaluateStringAgainstSdsRequirements(
subjectName,
"string-adheres-to-identifier-conventions"
);
if (!subjectNameIsValid) {
generateAlertMessage(subjectNameInput);
return;
}

removeAlertMessageIfExists(subjectNameInput);
if (subjectNameInput.attr("data-prev-name")) {
const subjectToRename = subjectNameInput.attr("data-prev-name");
window.sodaJSONObj.renameSubject(subjectToRename, subjectName);
} else {
//case where subject name is valid and not being renamed:
window.sodaJSONObj.addSubject(subjectName);
}
subjectIdCellToAddNameTo.html(subjectNameElement);
addSubjectSpecificationTableRow();
}
} catch (error) {
window.notyf.open({
duration: "3000",
type: "error",
message: error,
});
}
}
};

window.specifySample = (event, sampleNameInput) => {
let buttonContainer =
sampleNameInput[0].parentElement.parentElement.parentElement.parentElement
.previousElementSibling;

let addSampleButton = buttonContainer.children[0].children[0].children[1];
if (event.which == 13) {
try {
const sampleName = `sam-${sampleNameInput.val().trim()}`;
const sampleRenameElement = `
<div class="space-between w-100">
<span class="sample-id">${sampleName}</span>
<i
class="far fa-edit jump-back"
style="cursor: pointer;"
onclick="window.openSampleRenameInput(window.$(this))"
>
</i>
</div>
`;
const sampleIdCellToAddNameTo = sampleNameInput.parent();
let sampleTrashCan = sampleIdCellToAddNameTo[0].parentElement.nextElementSibling.children[0];

//get the pool of the subject that the sample is being added to
const subjectSampleAdditionTable = sampleNameInput.closest("table");
const subjectsPoolToAddSampleTo = subjectSampleAdditionTable
.find(".samples-subjects-pool")
.text();
const subjectToAddSampleTo = subjectSampleAdditionTable.find(".samples-subject-name").text();

if (sampleName.length > 0) {
const sampleNameIsValid = window.evaluateStringAgainstSdsRequirements(
sampleName,
"string-adheres-to-identifier-conventions"
);
if (!sampleNameIsValid) {
//show alert message below pool name input if input is invalid and abort function
generateAlertMessage(sampleNameInput);
return;
}
removeAlertMessageIfExists(sampleNameInput);

if (sampleNameInput.attr("data-prev-name")) {
const sampleToRename = sampleNameInput.attr("data-prev-name");
window.sodaJSONObj.renameSample(
sampleToRename,
sampleName,
subjectsPoolToAddSampleTo,
subjectToAddSampleTo
);
} else {
//Add the new sample to window.sodaJSONObj
window.sodaJSONObj.addSampleToSubject(
sampleName,
subjectsPoolToAddSampleTo,
subjectToAddSampleTo
);
//then show trash can svg
sampleTrashCan.style.display = "block";
}
sampleIdCellToAddNameTo.html(sampleRenameElement);
if (!sampleNameInput.attr("data-prev-name")) {
window.addSampleSpecificationTableRow(addSampleButton);
}
}
} catch (error) {
window.notyf.open({
duration: "3000",
type: "error",
message: error,
});
}
}
};

window.specifyPool = (event, poolNameInput) => {
if (event.which == 13) {
try {
const poolName = `pool-${poolNameInput.val().trim()}`;
const poolNameElement = `
<div class="space-between" style="width: 250px;">
<span class="pool-id">${poolName}</span>
<i
class="far fa-edit"
style="cursor: pointer;"
onclick="openPoolRenameInput($(this))"
>
</i>
</div>
`;
const poolSubjectSelectElement = `
<select
class="js-example-basic-multiple"
style="width: 100%"
name="${poolName}-subjects-selection-dropdown"
multiple="multiple"
></select>
`;
const poolSubjectsDropdownCell = poolNameInput.parent().parent().next();
const poolTrashcan = poolSubjectsDropdownCell[0].nextElementSibling.children[0];
const poolIdCellToAddNameTo = poolNameInput.parent();
let poolsTable = $("#pools-table");
if (poolName !== "pool-") {
const poolNameIsValid = window.evaluateStringAgainstSdsRequirements(
poolName,
"string-adheres-to-identifier-conventions"
);
if (!poolNameIsValid) {
window.notyf.open({
duration: "3000",
type: "error",
message: "Pool IDs may not contain spaces or special characters",
});
return;
}
removeAlertMessageIfExists(poolsTable);
if (poolNameInput.attr("data-prev-name")) {
const poolFolderToRename = poolNameInput.attr("data-prev-name");

window.sodaJSONObj.renamePool(poolFolderToRename, poolName);

//refresh the UI to update the dropdowns to avoid having to update select2 dropdowns
setActiveSubPage("guided-organize-subjects-into-pools-page");
return;
} else {
//Add left border back to subject dropdown cell to separate pool name and subject dropdown
poolSubjectsDropdownCell.removeClass("remove-left-border");

//Add the new pool to window.sodaJSONObj
window.sodaJSONObj.addPool(poolName);
poolTrashcan.style.display = "block";

//Add the select2 base element
poolSubjectsDropdownCell.html(poolSubjectSelectElement);

//Get the newly created select2 element
const newPoolSubjectsSelectElement = $(
`select[name="${poolName}-subjects-selection-dropdown"]`
);

//create a select2 dropdown for the pool subjects
$(newPoolSubjectsSelectElement).select2({
placeholder: "Select subjects",
tags: true,
width: "100%",
closeOnSelect: false,
});
$(newPoolSubjectsSelectElement).on("select2:open", (e) => {
updatePoolDropdown($(e.currentTarget), poolName);
});
$(newPoolSubjectsSelectElement).on("select2:unselect", (e) => {
const subjectToRemove = e.params.data.id;
window.sodaJSONObj.moveSubjectOutOfPool(subjectToRemove, poolName);
});
$(newPoolSubjectsSelectElement).on("select2:select", function (e) {
const selectedSubject = e.params.data.id;
window.sodaJSONObj.moveSubjectIntoPool(selectedSubject, poolName);
});
}
poolIdCellToAddNameTo.html(poolNameElement);
}
} catch (error) {
window.notyf.open({
duration: "3000",
type: "error",
message: error,
});
}
}
};

const updatePoolDropdown = (poolDropDown, poolName) => {
poolDropDown.empty().trigger("change");
//add subjects in pool to dropdown and set as selected
Expand Down Expand Up @@ -10536,39 +10314,6 @@ window.openSubjectRenameInput = (subjectNameEditButton) => {
`;
subjectIdCellToRename.html(subjectRenameElement);
};
const openPoolRenameInput = (poolNameEditButton) => {
const poolIdCellToRename = poolNameEditButton.closest("td");
const prevPoolName = poolIdCellToRename.find(".pool-id").text();
const prevPoolInput = prevPoolName.substr(prevPoolName.search("-") + 1);
const poolRenameElement = `
<div class="space-between" style="align-items: center; width: 250px;">
<span style="margin-right: 5px;">pool-</span>
<input
class="guided--input"
type="text"
name="guided-pool-id"
value=${prevPoolInput}
placeholder="Enter new pool ID"
onkeyup="window.specifyPool(event, window.$(this))"
data-alert-message="Pool IDs may not contain spaces or special characters"
data-alert-type="danger"
data-prev-name="${prevPoolName}"
style="width: 180px;"
/>
<i class="far fa-check-circle fa-solid" style="cursor: pointer; margin-left: 15px; color: var(--color-light-green); font-size: 1.24rem;" onclick="window.confirmEnter(this)"></i>
</div>
`;
poolIdCellToRename.html(poolRenameElement);
};

//updates the indices for guided tables using class given to spans in index cells
const updateGuidedTableIndices = (tableIndexClass) => {
const indiciesToUpdate = $(`.${tableIndexClass}`);
indiciesToUpdate.each((index, indexElement) => {
let newIndex = index + 1;
indexElement.innerHTML = newIndex;
});
};

const generateSubjectRowElement = (subjectName) => {
return `
Expand Down Expand Up @@ -11568,61 +11313,6 @@ const addSampleTableRow = () => {
}
};

const generatePoolSpecificationRowElement = () => {
return `
<td class="middle aligned pool-cell collapsing">
<div class="space-between" style="align-items: center; width: 250px;">
<span style="margin-right: 5px;">pool-</span>
<input
class="guided--input"
type="text"
name="guided-pool-id"
placeholder="Enter pool ID"
onkeyup="window.specifyPool(event, window.$(this))"
data-alert-message="Pool IDs may not contain spaces or special characters"
data-alert-type="danger"
style="width: 100%;"
/>
<i class="far fa-check-circle fa-solid" style="cursor: pointer; margin-left: 15px; color: var(--color-light-green); font-size: 1.24rem;" onclick="window.confirmEnter(this)"></i>
</div>
</td>
<td class="middle aligned pool-subjects remove-left-border">
</td>
<td class="middle aligned collapsing text-center remove-left-border">
<i
class="far fa-trash-alt"
style="color: red; cursor: pointer; display: none;"
onclick="window.deletePool(window.$(this))"
></i>
</td>
`;
};

window.addPoolTableRow = () => {
const poolsTableBody = document.getElementById("pools-specification-table-body");
const poolSpecificationTableInput = poolsTableBody.querySelector("input[name='guided-pool-id']");

const re = new RegExp("/^(d|w)+$/g");

if (poolSpecificationTableInput) {
//focus on the input that already exists
//check if pool has input
if (poolSpecificationTableInput.val != "") {
window.confirmEnter(poolSpecificationTableInput);
// addPoolTableRow();
// let newPoolTableRow = poolsTableBody.insertRow(-1);
// newPoolTableRow.innerHTML = generatePoolSpecificationRowElement();
} else {
poolSpecificationTableInput.focus();
}
} else {
//insert a new table row container with js as select2 breaks when adding a new row
//via template literals
const newPoolTableRow = poolsTableBody.insertRow(-1);
newPoolTableRow.innerHTML = generatePoolSpecificationRowElement();
}
};

//deletes subject from jsonObj and UI
window.deleteSubject = async (subjectDeleteButton) => {
const subjectIdCellToDelete = subjectDeleteButton.closest("tr");
Expand Down

0 comments on commit 8e6c3c8

Please sign in to comment.