From f29d1d4fafd328ee1352be7159b91e30182edb7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Gl=C3=B3rias?= Date: Tue, 24 Sep 2024 20:54:54 +0000 Subject: [PATCH 1/7] Relay Tour Info: add location, websiteOfficial, standings --- modules/relay/src/main/RelayTour.scala | 8 +++++-- modules/relay/src/main/RelayTourForm.scala | 14 +++++++----- modules/relay/src/main/ui/FormUi.scala | 25 ++++++++++++++++++--- ui/analyse/src/study/relay/interfaces.ts | 3 +++ ui/analyse/src/study/relay/relayTourView.ts | 9 ++++++++ 5 files changed, 49 insertions(+), 10 deletions(-) diff --git a/modules/relay/src/main/RelayTour.scala b/modules/relay/src/main/RelayTour.scala index 794d15ac1bb4..2c9d87c96cf9 100644 --- a/modules/relay/src/main/RelayTour.scala +++ b/modules/relay/src/main/RelayTour.scala @@ -1,6 +1,7 @@ package lila.relay import reactivemongo.api.bson.Macros.Annotations.Key +import io.mola.galimatias.URL import lila.core.i18n.Language import lila.core.id.ImageId @@ -81,9 +82,12 @@ object RelayTour: format: Option[String], tc: Option[String], fideTc: Option[FideTC], - players: Option[String] + location: Option[String], + players: Option[String], + websiteOfficial: Option[URL], + standings: Option[URL] ): - val all = List(format, tc, fideTc, players).flatten + val all = List(format, tc, fideTc, location, players).flatten export all.nonEmpty override def toString = all.mkString(" | ") lazy val fideTcOrGuess: FideTC = fideTc | diff --git a/modules/relay/src/main/RelayTourForm.scala b/modules/relay/src/main/RelayTourForm.scala index 6ec90a580670..4f8b8fe08b35 100644 --- a/modules/relay/src/main/RelayTourForm.scala +++ b/modules/relay/src/main/RelayTourForm.scala @@ -3,6 +3,7 @@ package lila.relay import play.api.data.* import play.api.data.Forms.* import play.api.data.format.Formatter +import io.mola.galimatias.URL import lila.common.Form.{ cleanText, cleanNonEmptyText, formatter, into, numberIn, typeIn, url } import lila.core.perm.Granter @@ -21,10 +22,13 @@ final class RelayTourForm(langList: lila.core.i18n.LangList): private val fideTcMapping: Mapping[FideTC] = typeIn[FideTC](FideTC.values.toSet) private val infoMapping = mapping( - "format" -> optional(cleanText(maxLength = 80)), - "tc" -> optional(cleanText(maxLength = 80)), - "fideTc" -> optional(fideTcMapping), - "players" -> optional(cleanText(maxLength = 120)) + "format" -> optional(cleanText(maxLength = 80)), + "tc" -> optional(cleanText(maxLength = 80)), + "fideTc" -> optional(fideTcMapping), + "location" -> optional(cleanText(maxLength = 80)), + "players" -> optional(cleanText(maxLength = 120)), + "websiteOfficial" -> optional(url.field), + "standings" -> optional(url.field) )(RelayTour.Info.apply)(unapply) private val pinnedStreamMapping = mapping( @@ -118,7 +122,7 @@ object RelayTourForm: object Data: - val empty = Data(RelayTour.Name(""), RelayTour.Info(none, none, none, none)) + val empty = Data(RelayTour.Name(""), RelayTour.Info(none, none, none, none, none, none, none)) def make(tg: RelayTour.WithGroupTours) = import tg.* diff --git a/modules/relay/src/main/ui/FormUi.scala b/modules/relay/src/main/ui/FormUi.scala index e37c875cf8e8..723e074ce654 100644 --- a/modules/relay/src/main/ui/FormUi.scala +++ b/modules/relay/src/main/ui/FormUi.scala @@ -428,9 +428,8 @@ final class FormUi(helpers: Helpers, ui: RelayUi, tourUi: RelayTourUi): half = true )(form3.input(_)), form3.group( - form("info.players"), - "Top players", - help = frag("Mention up to 4 of the best players participating").some, + form("info.location"), + "Tournament Location", half = true )(form3.input(_)) ), @@ -453,6 +452,26 @@ final class FormUi(helpers: Helpers, ui: RelayUi, tourUi: RelayTourUi): tc.toString -> tc.toString.capitalize ) ), + form3.group( + form("info.players"), + "Top players", + help = frag("Mention up to 4 of the best players participating").some, + half = true + )(form3.input(_)), + form3.split( + form3.group( + form("info.websiteOfficial"), + "Official Website", + help = frag("Whether the tournament has an official website").some, + half = true + )(form3.input(_)), + form3.group( + form("info.standings"), + "Official Standings", + help = frag("chess-results.com, info64.org,...").some, + half = true + )(form3.input(_)) + ), form3.group( form("markdown"), trb.fullDescription(), diff --git a/ui/analyse/src/study/relay/interfaces.ts b/ui/analyse/src/study/relay/interfaces.ts index 83e09ee640b1..9917a405521f 100644 --- a/ui/analyse/src/study/relay/interfaces.ts +++ b/ui/analyse/src/study/relay/interfaces.ts @@ -37,7 +37,10 @@ export interface RelayTourInfo { format?: string; tc?: string; fideTc?: string; + location?: string; players?: string; + websiteOfficial?: string; + standings?: string; } export type RelayTourDates = [number] | [number, number]; diff --git a/ui/analyse/src/study/relay/relayTourView.ts b/ui/analyse/src/study/relay/relayTourView.ts index ad3252574e9c..28ddf54945a2 100644 --- a/ui/analyse/src/study/relay/relayTourView.ts +++ b/ui/analyse/src/study/relay/relayTourView.ts @@ -112,15 +112,24 @@ const showInfo = (i: RelayTourInfo, dates?: RelayTourDates) => { ['dates', dates && showDates(dates), 'objects.spiral-calendar'], ['format', i.format, 'objects.crown'], ['tc', i.tc, 'objects.mantelpiece-clock'], + ['location', i.location, 'travel-places.world-map'], ['players', i.players, 'activity.sparkles'], ] .map( ([key, value, icon]) => + key && value && icon && h('div.relay-tour__info__' + key, [h('img', { attrs: { src: site.asset.flairSrc(icon) } }), value]), ) .filter(defined); + + i.websiteOfficial && + contents.push(h('div.relay-tour__info__websiteOfficial', [h('img', { attrs: { src: site.asset.flairSrc('objects.link') } }), h('a', { attrs: { href: i.websiteOfficial, target: '_blank' } }, 'Official Website')])); + + i.standings && + contents.push(h('div.relay-tour__info__standings', [h('img', { attrs: { src: site.asset.flairSrc('activity.sports-medal') } }), h('a', { attrs: { href: i.standings, target: '_blank' } }, 'Standings')])); + return contents.length ? h('div.relay-tour__info', contents) : undefined; }; From 940efb78ab5afcb06447cbb28e9027c8cf7cfe47 Mon Sep 17 00:00:00 2001 From: Thibault Duplessis Date: Tue, 24 Sep 2024 23:09:17 +0200 Subject: [PATCH 2/7] rename RelayTour.Info.website --- modules/relay/src/main/RelayTour.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/relay/src/main/RelayTour.scala b/modules/relay/src/main/RelayTour.scala index 2c9d87c96cf9..5ea25b91a4f5 100644 --- a/modules/relay/src/main/RelayTour.scala +++ b/modules/relay/src/main/RelayTour.scala @@ -84,7 +84,7 @@ object RelayTour: fideTc: Option[FideTC], location: Option[String], players: Option[String], - websiteOfficial: Option[URL], + website: Option[URL], standings: Option[URL] ): val all = List(format, tc, fideTc, location, players).flatten From 110062a5d580bb4aa0e988d95bdc25cae1c721e5 Mon Sep 17 00:00:00 2001 From: Thibault Duplessis Date: Tue, 24 Sep 2024 23:11:12 +0200 Subject: [PATCH 3/7] fix RelayTour.Info.nonEmpty --- modules/relay/src/main/RelayTour.scala | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/relay/src/main/RelayTour.scala b/modules/relay/src/main/RelayTour.scala index 5ea25b91a4f5..7c216ba59117 100644 --- a/modules/relay/src/main/RelayTour.scala +++ b/modules/relay/src/main/RelayTour.scala @@ -87,9 +87,8 @@ object RelayTour: website: Option[URL], standings: Option[URL] ): - val all = List(format, tc, fideTc, location, players).flatten - export all.nonEmpty - override def toString = all.mkString(" | ") + def nonEmpty = List(format, tc, fideTc, location, players, website, standings).flatten.nonEmpty + override def toString = List(format, tc, fideTc, location, players).mkString(" | ") lazy val fideTcOrGuess: FideTC = fideTc | tc .map(_.trim.toLowerCase.replace("classical", "standard")) From 658993b5ceda526691a866f0df03da08d880a31e Mon Sep 17 00:00:00 2001 From: Thibault Duplessis Date: Tue, 24 Sep 2024 23:13:19 +0200 Subject: [PATCH 4/7] tweak broadcast info form help --- modules/relay/src/main/ui/FormUi.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/relay/src/main/ui/FormUi.scala b/modules/relay/src/main/ui/FormUi.scala index 723e074ce654..ea5b91134775 100644 --- a/modules/relay/src/main/ui/FormUi.scala +++ b/modules/relay/src/main/ui/FormUi.scala @@ -462,13 +462,13 @@ final class FormUi(helpers: Helpers, ui: RelayUi, tourUi: RelayTourUi): form3.group( form("info.websiteOfficial"), "Official Website", - help = frag("Whether the tournament has an official website").some, + help = frag("External website URL").some, half = true )(form3.input(_)), form3.group( form("info.standings"), "Official Standings", - help = frag("chess-results.com, info64.org,...").some, + help = frag("External website URL, e.g. chess-results.com, info64.org").some, half = true )(form3.input(_)) ), From 42d4ff7c53ad2ba2b820c7eabc11ede79035bfed Mon Sep 17 00:00:00 2001 From: Thibault Duplessis Date: Tue, 24 Sep 2024 23:14:53 +0200 Subject: [PATCH 5/7] complete RelayTour.Info.website rename --- modules/relay/src/main/RelayTourForm.scala | 14 +++++++------- modules/relay/src/main/ui/FormUi.scala | 2 +- ui/analyse/src/study/relay/interfaces.ts | 2 +- ui/analyse/src/study/relay/relayTourView.ts | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/modules/relay/src/main/RelayTourForm.scala b/modules/relay/src/main/RelayTourForm.scala index 4f8b8fe08b35..80afdeea8198 100644 --- a/modules/relay/src/main/RelayTourForm.scala +++ b/modules/relay/src/main/RelayTourForm.scala @@ -22,13 +22,13 @@ final class RelayTourForm(langList: lila.core.i18n.LangList): private val fideTcMapping: Mapping[FideTC] = typeIn[FideTC](FideTC.values.toSet) private val infoMapping = mapping( - "format" -> optional(cleanText(maxLength = 80)), - "tc" -> optional(cleanText(maxLength = 80)), - "fideTc" -> optional(fideTcMapping), - "location" -> optional(cleanText(maxLength = 80)), - "players" -> optional(cleanText(maxLength = 120)), - "websiteOfficial" -> optional(url.field), - "standings" -> optional(url.field) + "format" -> optional(cleanText(maxLength = 80)), + "tc" -> optional(cleanText(maxLength = 80)), + "fideTc" -> optional(fideTcMapping), + "location" -> optional(cleanText(maxLength = 80)), + "players" -> optional(cleanText(maxLength = 120)), + "website" -> optional(url.field), + "standings" -> optional(url.field) )(RelayTour.Info.apply)(unapply) private val pinnedStreamMapping = mapping( diff --git a/modules/relay/src/main/ui/FormUi.scala b/modules/relay/src/main/ui/FormUi.scala index ea5b91134775..8e5df5b4eacb 100644 --- a/modules/relay/src/main/ui/FormUi.scala +++ b/modules/relay/src/main/ui/FormUi.scala @@ -460,7 +460,7 @@ final class FormUi(helpers: Helpers, ui: RelayUi, tourUi: RelayTourUi): )(form3.input(_)), form3.split( form3.group( - form("info.websiteOfficial"), + form("info.website"), "Official Website", help = frag("External website URL").some, half = true diff --git a/ui/analyse/src/study/relay/interfaces.ts b/ui/analyse/src/study/relay/interfaces.ts index 9917a405521f..48115345649c 100644 --- a/ui/analyse/src/study/relay/interfaces.ts +++ b/ui/analyse/src/study/relay/interfaces.ts @@ -39,7 +39,7 @@ export interface RelayTourInfo { fideTc?: string; location?: string; players?: string; - websiteOfficial?: string; + website?: string; standings?: string; } diff --git a/ui/analyse/src/study/relay/relayTourView.ts b/ui/analyse/src/study/relay/relayTourView.ts index 28ddf54945a2..57299256bd6e 100644 --- a/ui/analyse/src/study/relay/relayTourView.ts +++ b/ui/analyse/src/study/relay/relayTourView.ts @@ -124,8 +124,8 @@ const showInfo = (i: RelayTourInfo, dates?: RelayTourDates) => { ) .filter(defined); - i.websiteOfficial && - contents.push(h('div.relay-tour__info__websiteOfficial', [h('img', { attrs: { src: site.asset.flairSrc('objects.link') } }), h('a', { attrs: { href: i.websiteOfficial, target: '_blank' } }, 'Official Website')])); + i.website && + contents.push(h('div.relay-tour__info__website', [h('img', { attrs: { src: site.asset.flairSrc('objects.link') } }), h('a', { attrs: { href: i.website, target: '_blank' } }, 'Official Website')])); i.standings && contents.push(h('div.relay-tour__info__standings', [h('img', { attrs: { src: site.asset.flairSrc('activity.sports-medal') } }), h('a', { attrs: { href: i.standings, target: '_blank' } }, 'Standings')])); From df1c392c85a81d9da13c57cae35f1cee696f7b9e Mon Sep 17 00:00:00 2001 From: Thibault Duplessis Date: Tue, 24 Sep 2024 23:19:08 +0200 Subject: [PATCH 6/7] remove code duplication in relay tour view --- ui/analyse/src/study/relay/relayTourView.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/ui/analyse/src/study/relay/relayTourView.ts b/ui/analyse/src/study/relay/relayTourView.ts index 57299256bd6e..584ca67ce30d 100644 --- a/ui/analyse/src/study/relay/relayTourView.ts +++ b/ui/analyse/src/study/relay/relayTourView.ts @@ -114,22 +114,20 @@ const showInfo = (i: RelayTourInfo, dates?: RelayTourDates) => { ['tc', i.tc, 'objects.mantelpiece-clock'], ['location', i.location, 'travel-places.world-map'], ['players', i.players, 'activity.sparkles'], + ['website', i.website, 'objects.link', 'Official website'], + ['standings', i.standings, 'activity.sports-medal', 'Standings'], ] .map( - ([key, value, icon]) => + ([key, value, icon, linkName]) => key && value && icon && - h('div.relay-tour__info__' + key, [h('img', { attrs: { src: site.asset.flairSrc(icon) } }), value]), + h('div.relay-tour__info__' + key, [h('img', { attrs: { src: site.asset.flairSrc(icon) } }), + linkName ? h('a', { attrs: { href: value, target: '_blank' } }, linkName) : value, + ]), ) .filter(defined); - i.website && - contents.push(h('div.relay-tour__info__website', [h('img', { attrs: { src: site.asset.flairSrc('objects.link') } }), h('a', { attrs: { href: i.website, target: '_blank' } }, 'Official Website')])); - - i.standings && - contents.push(h('div.relay-tour__info__standings', [h('img', { attrs: { src: site.asset.flairSrc('activity.sports-medal') } }), h('a', { attrs: { href: i.standings, target: '_blank' } }, 'Standings')])); - return contents.length ? h('div.relay-tour__info', contents) : undefined; }; From f5220c294f3e517403aad1a2aec5f9bc668cd10a Mon Sep 17 00:00:00 2001 From: Thibault Duplessis Date: Tue, 24 Sep 2024 23:22:58 +0200 Subject: [PATCH 7/7] no icons for tournament info links it's starting to look weird with so many icons. these links are different from the rest, because the text content is always the same. so they don't need an icon to tell the user what they are. --- ui/analyse/src/study/relay/relayTourView.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ui/analyse/src/study/relay/relayTourView.ts b/ui/analyse/src/study/relay/relayTourView.ts index 584ca67ce30d..8e46a4013751 100644 --- a/ui/analyse/src/study/relay/relayTourView.ts +++ b/ui/analyse/src/study/relay/relayTourView.ts @@ -114,15 +114,15 @@ const showInfo = (i: RelayTourInfo, dates?: RelayTourDates) => { ['tc', i.tc, 'objects.mantelpiece-clock'], ['location', i.location, 'travel-places.world-map'], ['players', i.players, 'activity.sparkles'], - ['website', i.website, 'objects.link', 'Official website'], - ['standings', i.standings, 'activity.sports-medal', 'Standings'], + ['website', i.website, null, 'Official website'], + ['standings', i.standings, null, 'Standings'], ] .map( ([key, value, icon, linkName]) => key && value && - icon && - h('div.relay-tour__info__' + key, [h('img', { attrs: { src: site.asset.flairSrc(icon) } }), + h('div.relay-tour__info__' + key, [ + icon && h('img', { attrs: { src: site.asset.flairSrc(icon) } }), linkName ? h('a', { attrs: { href: value, target: '_blank' } }, linkName) : value, ]), )