diff --git a/assets/controllers/game_config_controller.js b/assets/controllers/game_config_controller.js index ada75ff..90b3c65 100644 --- a/assets/controllers/game_config_controller.js +++ b/assets/controllers/game_config_controller.js @@ -3,6 +3,14 @@ import { Controller } from '@hotwired/stimulus'; export default class extends Controller { static targets = ['hintType', 'awardSection', 'allAwards', 'awardType']; + enforceMinOneChecked(event) { + const checked = this.hintTypeTargets.filter((e) => e.checked); + if (checked.length === 0) { + event.target.checked = true; + } + this.toggleAwardSection(); + } + toggleAwardSection() { const awardChecked = this.hintTypeTargets.find( (el) => el.name === 'hint_award' @@ -22,20 +30,4 @@ export default class extends Controller { const allChecked = this.awardTypeTargets.every((el) => el.checked); this.allAwardsTarget.checked = allChecked; } - - hintTypeTargetConnected() { - this.#bindMinOneChecked(); - } - - #bindMinOneChecked() { - this.hintTypeTargets.forEach((el) => { - el.addEventListener('change', () => { - const checked = this.hintTypeTargets.filter((e) => e.checked); - if (checked.length === 0) { - el.checked = true; - } - this.toggleAwardSection(); - }); - }); - } } diff --git a/src/Repository/AwardRepository.php b/src/Repository/AwardRepository.php index 252f8a1..ef37e40 100644 --- a/src/Repository/AwardRepository.php +++ b/src/Repository/AwardRepository.php @@ -36,6 +36,10 @@ class AwardRepository extends ServiceEntityRepository ->andWhere('a.actor = :actorId') ->setParameter('actorId', $actorId); + if ($awardTypeIds !== null && empty($awardTypeIds)) { + return null; + } + if ($awardTypeIds !== null) { $qb->andWhere('a.awardType IN (:typeIds)') ->setParameter('typeIds', $awardTypeIds); diff --git a/templates/homepage/index.html.twig b/templates/homepage/index.html.twig index 13c8ace..e992d58 100644 --- a/templates/homepage/index.html.twig +++ b/templates/homepage/index.html.twig @@ -75,18 +75,20 @@