From 4bd6dcd7c07659cc226f0545b7a6fc33f4508d7d Mon Sep 17 00:00:00 2001 From: Cedric ANTHONY Date: Tue, 23 Sep 2025 18:18:00 +0200 Subject: [PATCH] :lipstick: (report): Added top report to game info panel --- assets/icons/ph/medal.svg | 1 + config/packages/twig.yaml | 1 + .../Controller/ReportsController.php | 6 +- .../Template/macro/_ordinal_macro.html.twig | 7 ++ .../macro/_reverse_ordinal_macro.html.twig | 7 ++ .../partials/_reports_game_info.html.twig | 4 + .../partials/_reports_list_footer.html.twig | 10 ++- .../partials/_reports_list_header.html.twig | 19 +++-- .../partials/_reports_top_report.html.twig | 85 +++++++++++++++++++ translations/report.en.yaml | 34 ++++++-- 10 files changed, 149 insertions(+), 25 deletions(-) create mode 100644 assets/icons/ph/medal.svg create mode 100644 src/Presentation/Template/macro/_ordinal_macro.html.twig create mode 100644 src/Presentation/Template/macro/_reverse_ordinal_macro.html.twig create mode 100644 src/Presentation/Template/reports/partials/_reports_top_report.html.twig diff --git a/assets/icons/ph/medal.svg b/assets/icons/ph/medal.svg new file mode 100644 index 0000000..51ec42d --- /dev/null +++ b/assets/icons/ph/medal.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/config/packages/twig.yaml b/config/packages/twig.yaml index 96d73d5..46d9ea4 100644 --- a/config/packages/twig.yaml +++ b/config/packages/twig.yaml @@ -6,6 +6,7 @@ twig: 'src/Presentation/Template/Admin': 'admin' 'src/Presentation/Template/reports': 'reports' 'src/Presentation/Template/turbo': 'turbo' + 'src/Presentation/Template/macro': 'macro' when@test: twig: diff --git a/src/Presentation/Controller/ReportsController.php b/src/Presentation/Controller/ReportsController.php index d847ea7..0162e60 100644 --- a/src/Presentation/Controller/ReportsController.php +++ b/src/Presentation/Controller/ReportsController.php @@ -77,7 +77,7 @@ class: Game::class, } $reports = $game->getReports()->toArray(); - $mostUpvotedReport = null; + $topReport = null; if (!empty($reports)) { /** @var array $reports */ @@ -89,7 +89,7 @@ class: Game::class, return $b->getCreatedAt() <=> $a->getCreatedAt(); }); - $mostUpvotedReport = $reports[0]; + $topReport = $reports[0]; } $createReportForm = $this->createForm(CreateReportForm::class, null, [ @@ -106,7 +106,7 @@ class: Game::class, 'game' => $game, 'reports' => $reports ?? [], 'gameSlug' => $game->getSlug(), - 'mostUpvotedReport' => $mostUpvotedReport, + 'topReport' => $topReport, 'createReportForm' => $createReportForm->createView(), 'createReportCommentForm' => $createReportCommentForm->createView(), ]); diff --git a/src/Presentation/Template/macro/_ordinal_macro.html.twig b/src/Presentation/Template/macro/_ordinal_macro.html.twig new file mode 100644 index 0000000..f3a37f7 --- /dev/null +++ b/src/Presentation/Template/macro/_ordinal_macro.html.twig @@ -0,0 +1,7 @@ +{% macro ordinal(text) %} + {% if text|length > 1 and text|slice(-1) matches '/^[1-9]$/' %} + {{ text|slice(0, -1) }}{{ text|slice(-1) }} + {% else %} + {{ text }} + {% endif %} +{% endmacro %} diff --git a/src/Presentation/Template/macro/_reverse_ordinal_macro.html.twig b/src/Presentation/Template/macro/_reverse_ordinal_macro.html.twig new file mode 100644 index 0000000..7c1ae82 --- /dev/null +++ b/src/Presentation/Template/macro/_reverse_ordinal_macro.html.twig @@ -0,0 +1,7 @@ +{% macro reverse_ordinal(text) %} + {% if text|length > 1 %} + {{ text|first }}{{ text|slice(1) }} + {% else %} + {{ text }} + {% endif %} +{% endmacro %} diff --git a/src/Presentation/Template/reports/partials/_reports_game_info.html.twig b/src/Presentation/Template/reports/partials/_reports_game_info.html.twig index 9e4034b..2d79d4b 100644 --- a/src/Presentation/Template/reports/partials/_reports_game_info.html.twig +++ b/src/Presentation/Template/reports/partials/_reports_game_info.html.twig @@ -51,7 +51,11 @@
+ {% include '@reports/partials/_reports_top_report.html.twig' %} + {% if game.description is defined %} +
{{ 'game.description'|trans }}
+

{{ game.description|raw }}

diff --git a/src/Presentation/Template/reports/partials/_reports_list_footer.html.twig b/src/Presentation/Template/reports/partials/_reports_list_footer.html.twig index d5e3d6f..1be6a8e 100644 --- a/src/Presentation/Template/reports/partials/_reports_list_footer.html.twig +++ b/src/Presentation/Template/reports/partials/_reports_list_footer.html.twig @@ -1,4 +1,5 @@ {% trans_default_domain 'report' %} +{% import '@macro/_reverse_ordinal_macro.html.twig' as reverse_ordinal %} {% if reports|length > 0 %} @@ -15,9 +16,10 @@
-

{{ 'list.table.notice.60fps'|trans }}

-

{{ 'list.table.notice.stable_FPS'|trans }}

-

{{ 'list.table.notice.better_resolution'|trans }}

-

{{ 'list.table.notice.native_resolution'|trans }}

+

{{ reverse_ordinal.reverse_ordinal('list.table.notice.60fps'|trans) }}

+

{{ reverse_ordinal.reverse_ordinal('list.table.notice.stable_FPS'|trans) }}

+

{{ reverse_ordinal.reverse_ordinal('list.table.notice.better_resolution'|trans) }}

+

{{ reverse_ordinal.reverse_ordinal('list.table.notice.native_resolution'|trans) }}

+

{{ reverse_ordinal.reverse_ordinal('list.table.notice.switch_2_edition'|trans) }}

{% endif %} diff --git a/src/Presentation/Template/reports/partials/_reports_list_header.html.twig b/src/Presentation/Template/reports/partials/_reports_list_header.html.twig index ddcd162..fea1ca4 100644 --- a/src/Presentation/Template/reports/partials/_reports_list_header.html.twig +++ b/src/Presentation/Template/reports/partials/_reports_list_header.html.twig @@ -1,4 +1,5 @@ {% trans_default_domain 'report' %} +{% import '@macro/_ordinal_macro.html.twig' as ordinal %} {% if reports|length > 0 %}
@@ -6,16 +7,16 @@ {{ 'list.table.header.status'|trans }} - {{ 'list.table.header.60fps'|trans }} - {{ 'list.table.header.stable_FPS'|trans }} - {{ 'list.table.header.better_resolution'|trans }} - {{ 'list.table.header.native_resolution'|trans }} - {{ 'list.table.header.60fps'|trans }} - {{ 'list.table.header.stable_FPS'|trans }} - {{ 'list.table.header.better_resolution'|trans }} - {{ 'list.table.header.native_resolution'|trans }} + {{ ordinal.ordinal('list.table.header.60fps'|trans) }} + {{ ordinal.ordinal('list.table.header.stable_FPS'|trans) }} + {{ ordinal.ordinal('list.table.header.better_resolution'|trans) }} + {{ ordinal.ordinal('list.table.header.native_resolution'|trans) }} + {{ ordinal.ordinal('list.table.header.60fps'|trans) }} + {{ ordinal.ordinal('list.table.header.stable_FPS'|trans) }} + {{ ordinal.ordinal('list.table.header.better_resolution'|trans) }} + {{ ordinal.ordinal('list.table.header.native_resolution'|trans) }} {{ 'list.table.header.better_loading_times'|trans }} - {{ 'list.table.header.switch_2_edition'|trans }} + {{ ordinal.ordinal('list.table.header.switch_2_edition'|trans) }} {{ 'list.table.header.upvoted'|trans }} {{ 'list.table.header.issue'|trans }} diff --git a/src/Presentation/Template/reports/partials/_reports_top_report.html.twig b/src/Presentation/Template/reports/partials/_reports_top_report.html.twig new file mode 100644 index 0000000..02c57cf --- /dev/null +++ b/src/Presentation/Template/reports/partials/_reports_top_report.html.twig @@ -0,0 +1,85 @@ +{% trans_default_domain 'report' %} + +{% if topReport is defined and topReport is not null %} + + {% set status = topReport.gameStatus %} + {% set statusBg = '' %} + {% set statusIcon = '' %} + + {% if status == enum('App\\Infrastructure\\Enum\\ReportGameStatusEnum').OK %} + {% set statusIcon = 'ph:smiley' %} + {% set statusBg = 'bg-info/50' %} + {% elseif status == enum('App\\Infrastructure\\Enum\\ReportGameStatusEnum').BUGGED %} + {% set statusIcon = 'ph:smiley-x-eyes' %} + {% set statusBg = 'bg-primary/50' %} + {% elseif status == enum('App\\Infrastructure\\Enum\\ReportGameStatusEnum').BAD %} + {% set statusIcon = 'ph:smiley-nervous' %} + {% set statusBg = 'bg-warning/50' %} + {% else %} + {% set statusIcon = 'ph:sparkle' %} + + {% set statusBg = 'bg-success/50' %} + {% endif %} + +
+
+
{{ ux_icon('ph:medal') }}
{{ 'most_upvoted.title'|trans }} +
+
+ +
+
+ Status: +
+ {{ ux_icon(statusIcon) }} +
+
+ +
+ {{ 'most_upvoted.badge.switch_2_edition'|trans }} +
+ +
+ {{ 'most_upvoted.badge.better_loading_times'|trans }} +
+
+ +
+
+ {{ 'most_upvoted.badge.60fps_portable'|trans }} +
+ +
+ {{ 'most_upvoted.badge.stable_fps_portable'|trans }} +
+ +
+ {{ 'most_upvoted.badge.resolution_improved_portable'|trans }} +
+ +
+ {{ 'most_upvoted.badge.native_resolution_portable'|trans }} +
+
+ +
+
+ {{ 'most_upvoted.badge.60fps_tv'|trans }} +
+ +
+ {{ 'most_upvoted.badge.stable_fps_tv'|trans }} +
+ +
+ {{ 'most_upvoted.badge.resolution_improved_tv'|trans }} +
+ +
+ {{ 'most_upvoted.badge.native_resolution_tv'|trans }} +
+
+ +
+ +{% endif %} diff --git a/translations/report.en.yaml b/translations/report.en.yaml index ea1039e..e8b4379 100644 --- a/translations/report.en.yaml +++ b/translations/report.en.yaml @@ -2,6 +2,7 @@ game: release_date: 'Release Date' developer: 'Developer' publisher: 'Publisher' + description: 'Description' add_report: label: 'Add a Report' @@ -40,19 +41,34 @@ list: table: header: status: 'Status' - 60fps: '60 FPS*' - stable_FPS: 'Stable FPS**' - better_resolution: 'Better Res***' - native_resolution: 'Native Res****' + 60fps: '60 FPS1' + stable_FPS: 'Stable FPS2' + better_resolution: 'Better Res3' + native_resolution: 'Native Res4' better_loading_times: 'Better loading' - switch_2_edition: 'Switch 2 Edition' + switch_2_edition: 'S2E5' issue: 'Issue?' upvoted: 'Upvoted' portable_label: 'Portable' tv_label: 'TV' misc_label: 'Misc' notice: - 60fps: '*Target above 30 FPS' - stable_FPS: '**Framerate is consistently at 30 or 60 FPS related to the reported framerate' - better_resolution: '***Has a better resolution than on Nintendo Switch 1 system in related mode' - native_resolution: '****Can hit 1080p in portable mode and/or 4K in TV mode on Nintendo Switch 2 system' + 60fps: '1: Target above 30 FPS' + stable_FPS: '2: Framerate is consistently at 30 or 60 FPS related to the reported framerate' + better_resolution: '3: Has a better resolution than on Nintendo Switch 1 system in related mode' + native_resolution: '4: Can hit 1080p in portable mode and/or 4K in TV mode on Nintendo Switch 2 system' + switch_2_edition: '5: Is a "Switch 2 Edition" or not' + +most_upvoted: + title: 'Top report' + badge: + 60fps_portable: '60 FPS on portable' + stable_fps_portable: 'Stable FPS on portable' + resolution_improved_portable: 'Better Resolution on portable' + native_resolution_portable: 'Native Resolution on portable' + 60fps_tv: '60 FPS on TV' + stable_fps_tv: 'Stable FPS on TV' + resolution_improved_tv: 'Better Resolution on TV' + native_resolution_tv: 'Native Resolution on TV' + better_loading_times: 'Better loading times' + switch_2_edition: 'Switch 2 Edition'