decide.nolog.cz/app/components/poll-evaluation-participants-table.hbs
2023-10-15 17:32:11 +02:00

88 lines
No EOL
2.7 KiB
Handlebars

<div class="participants-table">
<table class="table" data-test-table-of="participants">
<thead>
{{#if @poll.hasTimes}}
<tr>
<th>
{{! column for name }}
</th>
{{#each-in this.optionsPerDay as |jsDate count|}}
<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
jsDate
weekday="long"
day="numeric"
month="long"
year="numeric"
}}
</th>
{{/each-in}}
</tr>
{{/if}}
<tr>
<th>
{{! column for name }}
</th>
{{#each @poll.options as |option|}}
<th>
{{#if (and @poll.isFindADate @poll.hasTimes)}}
{{#if option.hasTime}}
{{!
TODO: Simplify to timeStyle="short" after upgrading to Ember Intl v6
}}
{{format-date option.jsDate hour="numeric" minute="numeric"}}
{{/if}}
{{else if @poll.isFindADate}}
{{!
TODO: Simplify to dateStyle="full" after upgrading to Ember Intl v6
}}
{{format-date
option.jsDate
weekday="long"
day="numeric"
month="long"
year="numeric"
}}
{{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>
{{#each @poll.options as |option index|}}
{{#let (object-at index user.selections) 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>