Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lua/wikis/commons/TeamParticipants/Parse/Wiki.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ local TeamParticipantsWikiParser = {}

---@alias TeamParticipant {opponent: standardOpponent, notes: {text: string, highlighted: boolean}[], aliases: string[],
---qualification: QualificationStructure?, shouldImportFromDb: boolean, date: integer,
---potentialQualifiers: standardOpponent[]?, warnings: string[]?}
---potentialQualifiers: standardOpponent[]?, warnings: string[]?, participantGroup: string}

---@alias QualificationMethod 'invite'|'qual'
---@alias QualificationType 'tournament'|'external'|'other'
Expand Down Expand Up @@ -183,6 +183,7 @@ function TeamParticipantsWikiParser.parseParticipant(input, defaultDate)
potentialQualifiers = potentialQualifiers,
warnings = warnings,
shouldImportFromDb = Logic.readBool(input.import),
participantGroup = input.group or '',
date = date,
}
end
Expand Down
40 changes: 30 additions & 10 deletions lua/wikis/commons/Widget/Participants/Team/CardsGroup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ local Lua = require('Module:Lua')

local Array = Lua.import('Module:Array')
local Class = Lua.import('Module:Class')
local Logic = Lua.import('Module:Logic')
local Operator = Lua.import('Module:Operator')
local Tabs = Lua.import('Module:Tabs')

local Widget = Lua.import('Module:Widget')
local AnalyticsWidget = Lua.import('Module:Widget/Analytics')
Expand All @@ -19,6 +22,7 @@ local Switch = Lua.import('Module:Widget/Switch')

---@class ParticipantsTeamCardsGroup: Widget
---@operator call(table): ParticipantsTeamCardsGroup
---@field props {participants: TeamParticipant[]}
local ParticipantsTeamCardsGroup = Class.new(Widget)

---@return Widget?
Expand All @@ -28,6 +32,16 @@ function ParticipantsTeamCardsGroup:render()
return
end

local participantGroups = Array.groupBy(participants, Operator.property('participantGroup'))

local tabArgs = {}

Array.forEach(participantGroups, function (group, groupIndex)
tabArgs['name' .. groupIndex] = Logic.emptyOr(group[1].participantGroup, 'Unnamed')
Copy link
Collaborator

@hjpalpha hjpalpha Jan 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a fan of 'Unnamed' (Maybe 'Placeholder' or 'Missing |group='?)
maybe just throw if it is empty and we have >1 participantGroups?

tabArgs['content' .. groupIndex] = ParticipantsTeamCardsGroup._createParticipantGroup(group)
end)
tabArgs.suppressHeader = true

return Div{
classes = { 'team-participant' },
children = {
Expand Down Expand Up @@ -59,17 +73,23 @@ function ParticipantsTeamCardsGroup:render()
}
}
},
AnalyticsWidget{
analyticsName = 'Team participants card',
children = Div{
classes = { 'team-participant__grid' },
children = Array.map(participants, function(participant)
return ParticipantsTeamCard{
participant = participant,
}
end),
Tabs.dynamic(tabArgs)
}
}
end

---@private
---@param participantGroup TeamParticipant[]
function ParticipantsTeamCardsGroup._createParticipantGroup(participantGroup)
return AnalyticsWidget{
analyticsName = 'Team participants card',
children = Div{
classes = { 'team-participant__grid' },
children = Array.map(participantGroup, function(participant)
return ParticipantsTeamCard{
participant = participant,
}
}
end),
}
}
end
Expand Down
Loading