Skip to content

Commit

Permalink
handle unknown school
Browse files Browse the repository at this point in the history
  • Loading branch information
Headary committed Nov 23, 2024
1 parent da2a9f3 commit 1ec8596
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/Components/ResultsPanel/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ const CategoryColumn: React.FC<{
<td>
<div className="team-name">{mappedTeams[p.team.teamId]?.name ?? p.team.name}</div>
<div className="flags">
{[...new Set(mappedTeams[p.team.teamId]?.participants.map(p => p.countryIso))].filter(iso => iso !== 'ZZ').map(iso =>
{[...new Set(mappedTeams[p.team.teamId]?.participants.map(p => p.countryIso))].filter(iso => iso !== '').map(iso =>
<span className={`flag-icon flag-icon-${iso?.toLowerCase()}`} />,
)}
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/Components/TeamList/teamList.latte
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
{$member->name}
{do $inSchool++}
{if $iterator->isLast() || (!is_null($members[$key + 1]) && isset($member->school) && isset($members[$key + 1]->school) && $member->school['schoolId'] != $members[$key + 1]->school['schoolId'])}
<span class="text-muted"> ({if $inSchool > 1}{$inSchool}&nbsp;&times;&nbsp;{/if}{$member->school['nameAbbrev']??''}{if isset($member->school) && $member->school['countryISO'] !== 'ZZ'} <span
<span class="text-muted"> ({if $inSchool > 1}{$inSchool}&nbsp;&times;&nbsp;{/if}{$member->school['nameAbbrev']??''}{if isset($member->school) && $member->school['countryISO'] !== ''} <span
class="flag-icon flag-icon-{$member->school['countryISO']??'zz'|lower}"></span>{/if})</span>
{do $inSchool = 0}
{/if}
Expand Down
9 changes: 5 additions & 4 deletions app/Components/TeamResults/TeamResultsComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ protected function passesCountryFilter(TeamModel $team): bool
$ISOsForTeam = [];

foreach ($team->members as $member) {
$iso = $member->school['countryISO'] ?? 'zz';
$iso = $member->school['countryISO'] ?? 'Uknown';
if (!in_array($iso, $ISOsForTeam)) {
$ISOsForTeam[] = $iso;
}
Expand Down Expand Up @@ -161,11 +161,12 @@ protected function createComponentFilterForm(): Form
// ->setOption('count', $count);
// }
foreach ($countryISOs as $countryISO => $count) {
$countryISO = $countryISO !== '' ? $countryISO : 'Uknown'; // set default value to unknown countries
$countryISOContainer->addCheckbox(
$countryISO,
sprintf(
$this->translator->lang === Language::cs ? '%s:%s účastníků' : '%s:%s participants',
$countryISO,
$this->translator->lang === Language::cs ? ' %s: %s účastníků' : ' %s: %s participants',
$countryISO !== 'Uknown' ? $countryISO : $this->presenter->csen('Nestudent', 'Not a student'),
$count
)
);
Expand All @@ -176,7 +177,7 @@ protected function createComponentFilterForm(): Form

$form->addSubmit('applyFilters', 'Apply')->setHtmlAttribute('class', 'btn btn-primary');

$form->onSuccess[] = fn (Form $form) => $this->filterData = $form->getValues('array');
$form->onSuccess[] = fn(Form $form) => $this->filterData = $form->getValues('array');
// $form->onSuccess[] = function(Form $form) {
// $this->filterData = $form->getValues('array');
// $this->redirect('this', ['filterData' => $this->filterData]);
Expand Down
9 changes: 6 additions & 3 deletions app/Components/TeamResults/teamResults.latte
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
</div>
<div class="results-second-row">
<div class="result-column text-muted" style="flex-grow: 1; margin-left: 5rem; margin-right: 10rem">
{switch $lang->value}{case cs}{var $notAStudentText = 'Nestudent'}{default}{var $notAStudentText = 'Not a student'}{/switch}
{var $inSchool = 0}
{if $team->members && count($team->members)}
{do
Expand All @@ -64,12 +65,14 @@
}
{foreach $members as $key => $member}
{varType App\Models\Downloader\TeamMemberModel $member}
{$member->name|trim}{if !$iterator->isLast()},{/if}
{do $inSchool++}
{if $iterator->isLast() || (!is_null($members[$key + 1]) && isset($member->school) && isset($members[$key + 1]->school) && $member->school['schoolId'] != $members[$key + 1]->school['schoolId'])}
<span class="text-muted"> ({if $inSchool > 1}{$inSchool}&nbsp;&times;&nbsp;{/if}{$member->school['nameAbbrev']??''}{if isset($member->school) && $member->school['countryISO'] !== 'ZZ'} <span
class="flag-icon flag-icon-{$member->school['countryISO']??'zz'|lower}"></span>{/if}) </span>
{$member->name|trim}
<span class="text-muted"> ({if $inSchool > 1}{$inSchool}&nbsp;&times;&nbsp;{/if}{$member->school['nameAbbrev']??$notAStudentText}{if isset($member->school) && $member->school['countryISO'] !== null}
<span class="flag-icon flag-icon-{$member->school['countryISO']??'zz'|lower}"></span>{/if})</span>{if !$iterator->isLast()},{/if}
{do $inSchool = 0}
{else}
{$member->name|trim}{if !$iterator->isLast()},{/if}
{/if}
{/foreach}
{else}
Expand Down
2 changes: 1 addition & 1 deletion app/Modules/Core/BasePresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function formatTemplateFiles(): array
/**
* Helper function to return correct translation based on the current language
*/
protected function csen(string $cs, string $en): string
public function csen(string $cs, string $en): string
{
if ($this->translator->lang === Language::cs) {
return $cs;
Expand Down
2 changes: 1 addition & 1 deletion app/Renderers/templates/formRender.latte
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<div class="country-container">
{$item['html']}
<div class="text-country-container">
{if $item['control']->getCaption() === 'ZZ'}
{if $item['control']->getCaption() === 'Unknown'}
{switch $lang}
{case cs}Neznámá
{default}Unknown
Expand Down

0 comments on commit 1ec8596

Please sign in to comment.