set url parameters with selected queries#361
Open
kaczmarj wants to merge 2 commits intoweb4bio:developmentfrom
Open
set url parameters with selected queries#361kaczmarj wants to merge 2 commits intoweb4bio:developmentfrom
kaczmarj wants to merge 2 commits intoweb4bio:developmentfrom
Conversation
When a user selects an option, the option will be set as a parameter in the url. The next step is to set the initial values for the select2 boxes using the url parameters, if they are given. Once this is implemented, a user can copy-paste a url to select the same things. Imagine that a user wants to send the results to a friend. That friend can enter the url and will have the same selection as the original user.
Contributor
Author
|
form values can be auto-populated using the code below. one thing i haven't figured out yet is how to integrate this with local storage... because i realized we save cohorts in local storage. but would it make more sense to persist it in the url instead of localstorage? const autoSelectFromURLParam = function(select2Object, key) {
const url = new URL(window.location.href);
const value = url.searchParams.get(key);
if (value === undefined || value === null || value === "") {
return
}
select2Object.select2("val", value.split(",")).trigger("change");
}
autoSelectFromURLParam($("#cancerTypeMultipleSelection"), "cohorts");
autoSelectFromURLParam($("#geneOneMultipleSelection"), "genesMutation");
autoSelectFromURLParam($("#clinicalMultipleSelection"), "clinical")
autoSelectFromURLParam($("#geneTwoMultipleSelection"), "genesExpression")
autoSelectFromURLParam($("#pathwayMultipleSelection"), "pathways") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a user selects an option, the option will be set as a parameter in
the url. The next step is to set the initial values for the select2
boxes using the url parameters, if they are given. Once this is
implemented, a user can copy-paste a url to select the same things.
Imagine that a user wants to send the results to a friend. That friend
can enter the url and will have the same selection as the original user.