Comments (13)
@jbotwins suggested we add a field to the office elections that can be used to group the related districts together.
from odca-jekyll.
@ckingbailey is working on this
from odca-jekyll.
Hey @adborden I was working on this last night with @jbotwins, @mford008, and Linda (whose handle I can't find on here) and we had some issues and proposed resolutions.
As you know one of the difficulties is that there's no office_name attribute or anything like that on an office_elections item that we could use to sort by. Instead we tried to use Jekyll to iterate over office_elections and append a property office_name on a string contains match, like:
(Sorry, semi-pseudo-code follows coz I'm at work and don't remember the exact syntax)
{% for ballot_item in office_elections %}
{% if ballot_item.title | contains "School Board' %}
{% assign ballot_item.office_name = "School Board" %}
{% else if ballot_item.title | contains "City Council" %}
{% assign ballot_item.office_name = "City Council" %}
{% endif %}
{% endfor %}
But on printing the results we found that we could not mutate the ballot_items of office_elections that way in a for loop. Perhaps there is a way to mutate the array prop currently being iterated over in a for loop. Do you know?
Another way we thought of is to use | where_exp "ballot_item.title contains \"School Board\""
and the same for "City Council" to separate the School Brd and City Council items into their own separate school_board_elections and city_council_elections arrays. Then we would loop over and display each of those arrays down at the bottom of the template where we loop over the office_elections array. The annoying thing about that technique is that then we have to either remove those values from the main office_elections array or, when we iterate over office_elections for display, skip those ballot_items that are also contained in either the school_board_elections or city_council_elections arrays.
So then that brings me to the easiest technique, but also maybe the cheesiest. I could put a script tag at the bottom of the page with some JS that, once the ballot_nav content is loaded, grabs the rendered DOM content and inserts the "School Board" and "City Council" headings we want there.
Do you think one of these is the best solution, or is there a better way you see?
from odca-jekyll.
The drawback of any of those techniques outlined above is that they only work for this election right now because the names of offices in any future election would likely be slightly different
from odca-jekyll.
Right, the best thing to do is to add an office_name
attribute to the office elections. These recently moved out of the source code and are now generated from the spreadsheet.
@tdooner do you have any ideas for how this should be added? I started a new sheet for office_elections and getting them into the back end but not sure how we want to handle the hard-coded sorting logic. That should move to the spreadsheet, but I'm debating how it should be represented. Before we moved things to the spreadsheet, I was thinking we would have a nested list on the ballot e.g.
office_elections:
- items:
- mayor
- label: City Council
items:
- city-council-district-2
- city-council-district-4
- city-council-district-6
from odca-jekyll.
Sure, let's update the ballot YAML to be exactly what the frontend needs. I think your structure is great.
As for the implementation, I'd like to keep the spreadsheet as simple as possible -- I wonder if we could do without adding a new tab for this. (Esp. because then it's one more thing that needs to be in-sync across sheets). Perhaps we can just make it (yet) another column on the candidates tab, say "Office Category"? As for ordering, perhaps we can just do it alphabetically?
from odca-jekyll.
I was half way through ^ before I saw this.
If we went the yaml direction, I'm not sure where we'd put it. In the spreadsheet? That would mean embedding a string with newlines and indendtation in a single cell where the formatting is probably hard to tweak.
from odca-jekyll.
But couldn't the ballot YAML just get output by the backend, the way it already does, but instead of having a structure like:
office_elections:
- city-council-1
- city-council-3
- city-council-5
referendums:
- referendum-1
- referendum-3
we update it to the structure you proposed? Or would that require too many changes in the frontend? Either way, if your PR caciviclab/disclosure-backend-static#128 will work for the frontend, let's just go with that.
from odca-jekyll.
Oh, I see. 👍 let's go with that. I'll add that to caciviclab/disclosure-backend-static#128, because it still lets us control the order from the spreadsheet, which I like.
from odca-jekyll.
@ckingbailey how does the above work for you?
from odca-jekyll.
Looks good to me ✔️
from odca-jekyll.
I merged caciviclab/disclosure-backend-static#128 and thought it would fail the tests, but it didn't and ended up deploying with a broken nav, so I fixed it in ^ There's still some clean up to do.
from odca-jekyll.
Actually, I'm going to call this done. The styling work is covered in #92
from odca-jekyll.
Related Issues (20)
- Ensure alerts link is at the bottom of the candidates page
- Make 'Search' button more prominent in header HOT 2
- Add call to action (CTA) for Search to landing page HOT 1
- `make docker` command does not track _sass or html files in the project root
- Add permalink to most recent election
- Update FAQ page to include contribution limits towards ballot measures and IEC
- Display candidate social links as icons only HOT 1
- Enable warning message on ballot measure committees that we have on contributor pages HOT 2
- Add link to new mapping tool to candidate and referendum pages HOT 2
- Add behested donation data in search.
- Handle contributions for committees that span elections HOT 1
- Feedback: a question on data correctness HOT 3
- URL for '?' tooltip on voluntary spending limits is broken HOT 2
- "Other committees controlled by this candidate" not showing for all candidates with other committees HOT 5
- The by origin bar chart should include an unitimized bar
- Link to GitHub repos from website
- Display "current" elections HOT 2
- Update homepage design to allow clicking into either the 2023 or 2024 elections
- Upgrade to Jekyll 4
- Bar chart is not scaling properly
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from odca-jekyll.