datamade / bga-payroll

💰 How much do your public officials make?
4 stars 4 forks source link

Changing the data year doesn't update the data download link #563

Closed hancush closed 2 years ago

hancush commented 2 years ago
Screen Shot 2021-11-16 at 8 15 12 AM

(See selected year vs. location of the data download link at bottom left.)

fgregg commented 2 years ago

Great catch! @smcalilly and I will get on this today.

fgregg commented 2 years ago

The current code attempts to get the year from the url request.

https://github.com/datamade/bga-payroll/blob/78aea94ef7c71db923d41a66684c323ee022682d/templates/jinja2/partials/employee_card.html#L4

but the data selector does not update the url, instead we use javascript to update the values of the date in a bunch of places.

https://github.com/datamade/bga-payroll/blob/78aea94ef7c71db923d41a66684c323ee022682d/bga_database/static/js/employer.js

to me, it seems a bit more correct for the date selector to update the url, otherwise the you have urls that don't take you to the page you are looking at now. (if you select a previous year, the url does not change and will show the year you first navigated to).

modifying the URL could a number of other things simpler, but we lose the AJAX stuff. that's a pretty big change.

So, while i think it would be good to have cool urls, that's a bigger change than we should make right now.

@smcalilly please add a little javascript to https://github.com/datamade/bga-payroll/blob/78aea94ef7c71db923d41a66684c323ee022682d/bga_database/static/js/employer.js

to update the date year in the download url instead of trying to get the year from the url.