From fccd9b5f3025670e9ef621d8557d2289c96ecb21 Mon Sep 17 00:00:00 2001 From: Thibault Duplessis Date: Tue, 2 Mar 2021 18:21:12 +0100 Subject: [PATCH] only show inputs of analysable games closes lichess-org/tavern#40 --- app/views/mod/games.scala | 12 +++++++++--- ui/site/css/mod/_games.scss | 2 +- ui/site/src/modGames.ts | 8 +++++--- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/app/views/mod/games.scala b/app/views/mod/games.scala index bf7e5d8e60af2..0cb7c16769478 100644 --- a/app/views/mod/games.scala +++ b/app/views/mod/games.scala @@ -70,7 +70,13 @@ object games { table(cls := "mod-games game-list slist")( thead( tr( - sortNoneTh(input(tpe := "checkbox", name := s"game[]", st.value := "all")), + sortNoneTh( + input( + tpe := "checkbox", + name := s"game[]", + st.value := "all" + ) + ), sortNumberTh("Opponent"), sortNumberTh("Speed"), th(iconTag('g')), @@ -85,8 +91,8 @@ object games { tbody( games.map { case (pov, assessment) => tr( - td( - input( + td(cls := pov.game.analysable.option("input"))( + pov.game.analysable option input( tpe := "checkbox", name := s"game[]", st.value := pov.gameId diff --git a/ui/site/css/mod/_games.scss b/ui/site/css/mod/_games.scss index 3096495a39eaf..3a4a3d1106f66 100644 --- a/ui/site/css/mod/_games.scss +++ b/ui/site/css/mod/_games.scss @@ -14,7 +14,7 @@ background: mix($c-bad, $c-bg-box, 50%); } - td:first-child { + td.input { cursor: pointer; &:hover { background: $c-bg-zebra2; diff --git a/ui/site/src/modGames.ts b/ui/site/src/modGames.ts index 3ceb782dcd584..cfe4608c6107e 100644 --- a/ui/site/src/modGames.ts +++ b/ui/site/src/modGames.ts @@ -72,9 +72,11 @@ const expandCheckboxZone = (table: HTMLTableElement, onSelect: OnSelect) => $(table).on('click', 'td:first-child', (e: MouseEvent) => { if ((e.target as HTMLElement).tagName == 'INPUT') onSelect(e.target as HTMLInputElement, e.shiftKey); else { - const input = (e.target as HTMLTableDataCellElement).querySelector('input') as HTMLInputElement; - input.checked = !input.checked; - onSelect(input, e.shiftKey); + const input = (e.target as HTMLTableDataCellElement).querySelector('input') as HTMLInputElement | undefined; + if (input) { + input.checked = !input.checked; + onSelect(input, e.shiftKey); + } } });