Skip to content

Commit

Permalink
Dataset selector now properly pre-loads from URL params
Browse files Browse the repository at this point in the history
  • Loading branch information
jorvis committed Jan 15, 2024
1 parent 8c932a6 commit 016d659
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,7 @@ document.addEventListener('DOMContentLoaded', () => {
selected_dc_share_id = row_div.dataset.shareId;
selected_dc_label = dataset_collection_label_index[selected_dc_share_id];

if (selected_dc_label.length > DATASET_COLLECTION_SELECTOR_PROFILE_LABEL_LENGTH_LIMIT) {
let truncated_label = selected_dc_label.substring(0, DATASET_COLLECTION_SELECTOR_PROFILE_LABEL_LENGTH_LIMIT) + '...';
document.querySelector('#dropdown-dc-selector-label').innerHTML = truncated_label;
} else {
document.querySelector('#dropdown-dc-selector-label').innerHTML = selected_dc_label;
}
updateDatasetCollectionSelectorLabel();

document.querySelector('#dropdown-dc').classList.remove('is-active');
}
Expand Down Expand Up @@ -128,6 +123,15 @@ const fetchDatasetCollections = async (callback) => {
}
}

const selectDatasetCollection = (share_id) => {
// reads the DC share_id passed and handles any UI and data updates to make
// it preselected
selected_dc_share_id = share_id;
selected_dc_label = dataset_collection_label_index[selected_dc_share_id];

updateDatasetCollectionSelectorLabel();
}

const setActiveDCCategory = (category) => {
// clear the gene list
document.querySelector('#dropdown-content-dc').innerHTML = '';
Expand Down Expand Up @@ -179,4 +183,13 @@ const setActiveDCCategory = (category) => {

document.querySelector('#dropdown-content-dc').appendChild(row);
}
}

const updateDatasetCollectionSelectorLabel = () => {
if (selected_dc_label.length > DATASET_COLLECTION_SELECTOR_PROFILE_LABEL_LENGTH_LIMIT) {
let truncated_label = selected_dc_label.substring(0, DATASET_COLLECTION_SELECTOR_PROFILE_LABEL_LENGTH_LIMIT) + '...';
document.querySelector('#dropdown-dc-selector-label').innerHTML = truncated_label;
} else {
document.querySelector('#dropdown-dc-selector-label').innerHTML = selected_dc_label;
}
}
8 changes: 6 additions & 2 deletions www/js/expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ const parseGeneCartURLParams = () => {
}

const parseDatasetCollectionURLParams = () => {
// handle passed dataset collections
//const layout_id = getUrlParameter('layout_id');
// handle passed dataset collection
const layout_id = getUrlParameter('layout_id');

if (layout_id) {
selectDatasetCollection(layout_id);
}
}

0 comments on commit 016d659

Please sign in to comment.