Skip to content

set url parameters with selected queries#361

Open
kaczmarj wants to merge 2 commits intoweb4bio:developmentfrom
kaczmarj:add/urlparams
Open

set url parameters with selected queries#361
kaczmarj wants to merge 2 commits intoweb4bio:developmentfrom
kaczmarj:add/urlparams

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

@adit-anand adit-anand requested a review from amaraim22 February 4, 2022 17:00
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