localgovdrupal / localgov_elections

This module provides submodules, content types, views and configuration that allow the reporting of election results for the LocalGov Drupal distribution.
GNU General Public License v2.0
1 stars 0 forks source link

Results timeline table needs improving #15

Open msayoung opened 3 weeks ago

msayoung commented 3 weeks ago
<td>
<div class="ward-candidate-results">
    <div class="winner result-row">
        <div class="name">Faithful, M</div>
        <div class="key-result"></div>
  </div>
      <div class="loser result-row"><div class="name">Faithful, M</div></div>
      <div class="loser result-row"><div class="name">Zappa, Frank</div></div>
</div>
</td>

image

A few questions about the results timeline @chriswales95 @dedavidson

Issue 1. While it looks great, I'm not sure that the data is clear in the table at present, with candidates listed in one cell and their parties and votes listed adjacent.. I think each candidate needs their own table row, which probably requires a nested table. Perhaps Dave Hampton has some suggestions, I saw he gave some feedback on the table styling.

The issue is that having all the candidates in one row makes it difficult for a non-visual user to understand which party and number of votes relates to which candidate.

The current approach will likely cause alignment issues, as you'll have noticed on the Cumberland results:

image

Issue 2. I notice that the newer version of elections prints the winner twice - is this on purpose?

Issue 3. The winning candidate is first in the list, and this is also indicated visually by the use of bold and their party colours. We may want to add some visually hidden text to emphasise which is the winner to non-visual users too.

finnlewis commented 2 weeks ago

@markconroy is going to take a look at this.

markconroy commented 2 weeks ago

I'm finding it impossible to get the markup I want for this, which would be something like this image:

Screenshot 2024-06-21 at 13 28 43

I think the reason is because all the items - name, party, votes, are being returned in the same field in views, and I think the reason that is happening is because of the way it is set up in localgov_elections/src/Plugin/views/field/WardCandidates.php.

I haven't got more time to look at it now and won't be back until next Wednesday so if someone else could take it apart a little bit that would be great.

What I was trying to do was create a views template file called views-view-table--localgov-election-results-timeline.html.twig and edit it to look like this:

<table{{ attributes.addClass(classes) }}>
  {% if caption_needed %}
    <caption>
    {% if caption %}
      {{ caption }}
    {% else %}
      {{ title }}
    {% endif %}
    {% if (summary_element is not empty) %}
      {{ summary_element }}
    {% endif %}
    </caption>
  {% endif %}
  {% if header %}
    <thead>
      <tr>
        <th>Time</th>
        <th>Area</th>
        <th>Result</th>
      </tr>
    </thead>
  {% endif %}
  <tbody>
    {% for row in rows %}
    {{ dump(row) }}
      <tr{{ row.attributes }}>

        <td>{{ row.columns.changed.content }}</td>
        <td>{{ row.columns.localgov_election_area_name.content }}</td>
        <td>
          <table>
            <tr>
              <td>Name</td>
              <td>Party</td>
              <td>Votes</td>
            </tr>
            <tr>
              {#
                This is where I am stuck, because of how these the "Candidate result for a ward"
                field in the view is structured (via WardCandidate.php).
              #}
              <td>Mark Conroy</td>
              <td>Mark's Party</td>
              <td>12345</td>
            </tr>
            <tr>
              <td>Finn Lewis</td>
              <td>Finn's Party</td>
              <td>12345</td>
            </tr>
          </table>
        </td>
      </tr>
    {% endfor %}
  </tbody>
</table>
willguv commented 2 weeks ago

Does the whole thing need to be a table?

Could we do it more like this?

11.48

Manchester Central result

Will Callaghan Will's party 12345 Will Callaghan Will's party 12345

[time]

[Constituency name] result

[winning name] [winning party] [winning votes] [2nd place] [3rd place] ect

markconroy commented 2 weeks ago

That might be easier. I'll be away until next Wednesday so if someone wants to get that started I can look at it more when I am back.

msayoung commented 1 week ago

If we could avoid nested tables or merged cells I think it would be a lot cleaner.

However if we are going for tables I think it would be better to merge the row cells for the time and constituency, rather than nested tables.

some docs for reference: https://developer.mozilla.org/en-US/docs/Learn/HTML/Tables/Advanced

msayoung commented 1 week ago

Ok. Rethinking this a bit...

Do we actually need all the results on the timeline?

Surely the breakdown of the ward results should be on the ward results page itself - ie a table explaining the graph (I'm going to raise an issue to add this anyway)

Then the timeline could be much simpler with the time the results were announced , the winning candidate with a link to the ward results page.

What do you think ?

msayoung commented 1 week ago

Ok. Rethinking this a bit...

Do we actually need all the results on the timeline?

Surely the breakdown of the ward results should be on the ward results page itself - ie a table explaining the graph (I'm going to raise an issue to add this anyway)

Then the timeline could be much simpler with the time the results were announced , the winning candidate with a link to the ward results page.

What do you think ?

msayoung commented 1 week ago

Ok. Rethinking this a bit...

Do we actually need all the results on the timeline?

Surely the breakdown of the ward results should be on the ward results page itself - ie a table explaining the graph (I'm going to raise an issue to add this anyway)

Then the timeline could be much simpler with the time the results were announced , the winning candidate with a link to the ward results page.

What do you think ?

markconroy commented 1 week ago

Turning on teaser view mode instead of a table of fields, we get this Screenshot 2024-06-26 at 11 02 14

It's ugly, but I reckon we could make it into a really nice looking timeline without too much effort.

Let's get started ...

markconroy commented 1 week ago

Actually, on further thought, for phase 1 and for getting a stable release, I'm in agreement with Maria. All the content going into this timeline item is available on the ward result page.

The items in this table is just a condensation of that information. Maybe for phase 1, we actually just remove the timeline and focus on other stable blockers?

willguv commented 1 week ago

The timeline is more useful when there are multiple results called throughout the evening (eg with local council elections)

This isn't adding much for single result Westminster elections so we could safely hide it

markconroy commented 6 days ago

What's our decision on this? Are we hiding it for the Westminister elections on Thursday to work it out after that for the next elections?

Or are we going to try fix it before then?

dedavidson commented 6 days ago

I suggest we hide it if type is set to be National Parliamentary.

willguv commented 6 days ago

Agree, let's hide it. Is this something you can do a quick PR for @dedavidson @markconroy please?

markconroy commented 6 days ago

PR - https://github.com/localgovdrupal/localgov_elections/pull/77

That PR comments out the timeline stuff and disables the view for now.

willguv commented 6 days ago

I've moved this to "next version" in the Elections project view so we can keep an eye on it

So please don't close this issue when #77 is done