Open msayoung opened 3 weeks ago
@markconroy is going to take a look at this.
I'm finding it impossible to get the markup I want for this, which would be something like this image:
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>
Does the whole thing need to be a table?
Could we do it more like this?
11.48
Will Callaghan Will's party 12345 Will Callaghan Will's party 12345
[time]
[winning name] [winning party] [winning votes] [2nd place] [3rd place] ect
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.
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
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 ?
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 ?
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 ?
Turning on teaser view mode instead of a table of fields, we get this
It's ugly, but I reckon we could make it into a really nice looking timeline without too much effort.
Let's get started ...
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?
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
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?
I suggest we hide it if type is set to be National Parliamentary.
Agree, let's hide it. Is this something you can do a quick PR for @dedavidson @markconroy please?
PR - https://github.com/localgovdrupal/localgov_elections/pull/77
That PR comments out the timeline stuff and disables the view for now.
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
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:
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.