Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set url parameters with selected queries #361

Open
wants to merge 2 commits into
base: development
Choose a base branch
from

Conversation

kaczmarj
Copy link
Contributor

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.

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.
@kaczmarj
Copy link
Contributor Author

kaczmarj commented Nov 15, 2021

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")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant