Gilead-BioStats / gsm

Good Statistical Monitoring R Package
https://gilead-biostats.github.io/gsm/
Apache License 2.0
36 stars 8 forks source link

Feature: Update the "Highlighted Site" dropdown if `?site={SiteID}` is found in report URL #1562

Open jwildfire opened 3 months ago

jwildfire commented 3 months ago

Feature Details

Need to write some custom js to grab and parse document.URLand then set the selected value in the dropdown

Will allow us to easily link to specific site/KRI combos in the report

Example Code

// Add an onload callback to document.
document.addEventListener('DOMContentLoaded', function() {
    // parse URL parameters
    const urlParams = new URLSearchParams(window.location.search);
    // Get the site id from the URL parameters.
    const siteId = urlParams.get('site_id');
    console.log(siteId);
    // Update the dropdown to the selected site. TODO: this select's the `div`, not the `select`.
    document.getElementById('overall-site-select').value = siteId;
})

Possible Implementation

Additional Comments

jwildfire commented 3 months ago

Copilot implementation via @samussiah

// Add an onload callback to document.
document.addEventListener('DOMContentLoaded', function() {
    // parse URL parameters
    const urlParams = new URLSearchParams(window.location.search);
    // Get the site id from the URL parameters.
    const siteId = urlParams.get('site_id');
    console.log(siteId);
    // Update the dropdown to the selected site.
    document.getElementById('overall-site-select').value = siteId;
})
jwildfire commented 2 months ago

Consider bumping to v2.1