Skip to content

Commit

Permalink
Don't show current draw at top of schedule for leagues, only for comp…
Browse files Browse the repository at this point in the history
…etitions.
  • Loading branch information
rapind committed Nov 7, 2024
1 parent 2ee448a commit d448cce
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 10 deletions.
2 changes: 1 addition & 1 deletion prod.min.js

Large diffs are not rendered by default.

52 changes: 43 additions & 9 deletions src/Results.elm
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ type alias EventConfig =

type alias Event =
{ id : Int
, eventType : EventType
, name : String
, summary : Maybe String
, description : Maybe String
Expand Down Expand Up @@ -213,6 +214,11 @@ type alias Event =
}


type EventType
= League
| Competition


type EventState
= EventStatePending
| EventStateActive
Expand Down Expand Up @@ -582,6 +588,19 @@ decodeProduct =
decodeEvent : Decoder Event
decodeEvent =
let
decodeEventType : Decoder EventType
decodeEventType =
string
|> Decode.andThen
(\str ->
case String.toLower str of
"competition" ->
Decode.succeed Competition

_ ->
Decode.succeed League
)

decodeEventState : Decoder EventState
decodeEventState =
string
Expand All @@ -606,6 +625,7 @@ decodeEvent =
in
Decode.succeed Event
|> required "id" int
|> required "event_type" decodeEventType
|> required "name" string
|> optional "summary" (nullable string) Nothing
|> optional "description" (nullable string) Nothing
Expand Down Expand Up @@ -3612,8 +3632,18 @@ viewDraws theme translations eventConfig event =
text "-"
)
}

sheetColumns =
List.indexedMap sheetColumn
(if onActive then
-- Remove sheet names that have no games
event.sheetNames

else
event.sheetNames
)
in
([ labelColumn, startsAtColumn ] ++ List.indexedMap sheetColumn event.sheetNames ++ [ attendanceColumn ])
([ labelColumn, startsAtColumn ] ++ sheetColumns ++ [ attendanceColumn ])
|> List.filterMap identity
in
el [ El.width El.fill, El.htmlAttribute (class "cio__event_draws") ]
Expand All @@ -3622,15 +3652,19 @@ viewDraws theme translations eventConfig event =

else
column [ El.width El.fill, El.spacing 20 ]
[ case activeDraw of
Just draw ->
El.table [ El.htmlAttribute (class "cio__event_draws_table") ]
{ data = [ draw ]
, columns = tableColumns True
}
[ if event.eventType == Competition then
case activeDraw of
Just draw ->
El.table [ El.htmlAttribute (class "cio__event_draws_table") ]
{ data = [ draw ]
, columns = tableColumns True
}

Nothing ->
El.none
Nothing ->
El.none

else
El.none
, El.table [ El.paddingXY 0 30, El.htmlAttribute (class "cio__event_draws_table") ]
{ data = event.draws
, columns = tableColumns False
Expand Down

0 comments on commit d448cce

Please sign in to comment.