decide.nolog.cz/app/components/poll-evaluation-participants-table.hbs

96 lines
3.3 KiB
Handlebars
Raw Normal View History

<div class="participants-table">
<table class="table" data-test-table-of="participants">
<thead>
2023-10-15 17:32:11 +02:00
{{#if @poll.hasTimes}}
<tr>
<th>
{{! column for name }}
</th>
2023-10-15 17:32:11 +02:00
{{#each-in this.optionsPerDay as |jsDate count|}}
{{!
@glint-ignore
We can be sure that count is a number because it is destructed from a
Map, which values are only numbers. But somehow Glint / TypeScript
is not sure about it.
}}
2023-10-15 17:32:11 +02:00
<th colspan={{count}}>
{{!
TODO: Simplify to dateStyle="full" after upgrading to Ember Intl v6
Cannot use optionGroup.value because that's a ISO8601 day string
(e.g. "2023-10-01"), which is parsed by browsers in UTC and not
locale time zone. Therefore we need parse a JS Date representation
of that string, which has been parsed by Luxon in correct timezone.
}}
{{format-date
2023-10-15 17:32:11 +02:00
jsDate
weekday="long"
day="numeric"
month="long"
year="numeric"
}}
</th>
2023-10-15 17:32:11 +02:00
{{/each-in}}
</tr>
{{/if}}
<tr>
<th>
{{! column for name }}
</th>
2023-10-15 17:32:11 +02:00
{{#each @poll.options as |option|}}
<th>
2023-10-15 17:32:11 +02:00
{{#if (and @poll.isFindADate @poll.hasTimes)}}
{{#if option.hasTime}}
{{!
@glint-ignore
Narrowring is not working here correctly. Due to the only executing if
`option.hasTime` is `true`, we know that `option.jsDate` cannot be `null`.
But TypeScript does not support narrowing through a chain of getters
currently.
}}
{{format-date option.jsDate timeStyle="short"}}
{{/if}}
2023-10-15 17:32:11 +02:00
{{else if @poll.isFindADate}}
{{!
@glint-ignore
Narrowring is not working here correctly. Due to the only executing if
`option.hasTime` is `true`, we know that `option.jsDate` cannot be `null`.
But TypeScript does not support narrowing through a chain of getters
currently.
}}
{{format-date option.jsDate dateStyle="full"}}
{{else}}
{{option.title}}
{{/if}}
</th>
{{/each}}
</tr>
</thead>
<tbody>
{{#each this.usersSorted as |user|}}
<tr data-test-participant={{user.id}}>
<td data-test-value-for="name">
{{user.name}}
</td>
2023-10-15 17:32:11 +02:00
{{#each @poll.options as |option index|}}
{{#let (get user.selections index) as |selection|}}
<td
class={{selection.type}}
data-test-is-selection-cell
data-test-value-for={{option.title}}
>
{{#if selection.labelTranslation}}
{{t selection.labelTranslation}}
{{else}}
{{selection.label}}
{{/if}}
</td>
{{/let}}
{{/each}}
</tr>
{{/each}}
</tbody>
</table>
</div>