Skip to content

Commit

Permalink
Temporary fix to #716 and #717 by adding and removing "is-loading" cl…
Browse files Browse the repository at this point in the history
…ass to search buttons
  • Loading branch information
adkinsrs committed Jul 4, 2024
1 parent 32220aa commit f9e198a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
8 changes: 8 additions & 0 deletions www/js/expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,13 @@ document.addEventListener('DOMContentLoaded', () => {

// add event listener for when the submit-expression-search button is clicked
document.getElementById('submit-expression-search').addEventListener('click', async (event) => {
const currentTarget = event.currentTarget;
currentTarget.classList.add('is-loading');
const status = validateExpressionSearchForm();

if (! status) {
console.info("Aborting search");
event.currentTarget.classList.remove('is-loading');
return;
}

Expand Down Expand Up @@ -108,6 +111,8 @@ document.addEventListener('DOMContentLoaded', () => {
} catch (error) {
logErrorInConsole(error);
return;
} finally {
currentTarget.classList.remove('is-loading');
}

const url = buildStateURL();
Expand Down Expand Up @@ -310,6 +315,7 @@ const handlePageSpecificLoginUIUpdates = async (event) => {
layoutShareId = getUrlParameter('layout_id');

// Wait until all pending API calls have completed before checking if we need to search
document.getElementById("submit-expression-search").classList.add("is-loading");
try {
// SAdkins note - Promise.all fails fast,
// but Promise.allSettled waits until all resolve/reject and lets you know which ones failed
Expand All @@ -320,6 +326,8 @@ const handlePageSpecificLoginUIUpdates = async (event) => {
]);
} catch (error) {
logErrorInConsole(error);
} finally {
document.getElementById("submit-expression-search").classList.remove("is-loading");
}

// Trigger the default dataset collection to be selected in the
Expand Down
2 changes: 2 additions & 0 deletions www/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,12 @@ const handlePageSpecificLoginUIUpdates = async (event) => {
populateUserHistoryTable();
}

document.getElementById("submit-expression-search").classList.add("is-loading");
await Promise.all([
fetchGeneCartData(),
fetchDatasetCollections()
]);
document.getElementById("submit-expression-search").classList.remove("is-loading");

// Trigger the default dataset collection to be selected in the
if (CURRENT_USER.default_profile_share_id) {
Expand Down
10 changes: 9 additions & 1 deletion www/js/projection.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,14 @@ const handlePageSpecificLoginUIUpdates = async (event) => {
// add event listener for when the submit-projection-search button is clicked
document.querySelector('#submit-projection-search').addEventListener('click', async (event) => {

const currentTarget = event.currentTarget;
currentTarget.classList.add("is-loading");

const status = validateProjectionSearchForm();

if (! status) {
console.info("Aborting search");
event.currentTarget.classList.remove("is-loading");
return;
}

Expand Down Expand Up @@ -104,12 +108,13 @@ const handlePageSpecificLoginUIUpdates = async (event) => {
} catch (error) {
logErrorInConsole(error);
return;
} finally {
currentTarget.classList.remove("is-loading");
}

const url = buildStateUrl();
// add to state history
history.pushState(null, '', url);

});

// Change the svg scoring method when select element is changed
Expand All @@ -128,6 +133,7 @@ const handlePageSpecificLoginUIUpdates = async (event) => {
});

// Wait until all pending API calls have completed before checking if we need to search
document.getElementById("submit-projection-search").classList.add("is-loading");
try {
// SAdkins note - Promise.all fails fast,
// but Promise.allSettled waits until all resolve/reject and lets you know which ones failed
Expand All @@ -141,6 +147,8 @@ const handlePageSpecificLoginUIUpdates = async (event) => {

} catch (error) {
logErrorInConsole(error);
} finally {
document.getElementById("submit-projection-search").classList.remove("is-loading");
}

// Trigger the default dataset collection to be selected in the
Expand Down

0 comments on commit f9e198a

Please sign in to comment.