Giter VIP home page Giter VIP logo

Comments (13)

adborden avatar adborden commented on June 12, 2024

@jbotwins suggested we add a field to the office elections that can be used to group the related districts together.

from odca-jekyll.

adborden avatar adborden commented on June 12, 2024

@ckingbailey is working on this

from odca-jekyll.

ckingbailey avatar ckingbailey commented on June 12, 2024

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.

ckingbailey avatar ckingbailey commented on June 12, 2024

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.

adborden avatar adborden commented on June 12, 2024

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.

tdooner avatar tdooner commented on June 12, 2024

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.

adborden avatar adborden commented on June 12, 2024

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.

tdooner avatar tdooner commented on June 12, 2024

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.

adborden avatar adborden commented on June 12, 2024

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.

adborden avatar adborden commented on June 12, 2024

@ckingbailey how does the above work for you?

from odca-jekyll.

ckingbailey avatar ckingbailey commented on June 12, 2024

Looks good to me ✔️

from odca-jekyll.

adborden avatar adborden commented on June 12, 2024

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.

adborden avatar adborden commented on June 12, 2024

Actually, I'm going to call this done. The styling work is covered in #92

from odca-jekyll.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.