Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
9b3c418
clean up condition building syntax
ElectricalBoy Feb 24, 2026
896e214
type anno
ElectricalBoy Feb 24, 2026
5601621
simplify opponent conditions
ElectricalBoy Feb 24, 2026
6cc81de
Array.forEach
ElectricalBoy Feb 24, 2026
d548bc5
access modifiers
ElectricalBoy Feb 24, 2026
47497aa
add column definition function
ElectricalBoy Feb 24, 2026
92fd440
simplify error message
ElectricalBoy Feb 24, 2026
d20713e
use widgets
ElectricalBoy Feb 24, 2026
88c90d9
type annotation
ElectricalBoy Feb 24, 2026
3e2bd36
update awards table
ElectricalBoy Feb 24, 2026
c7a3d93
syntax
ElectricalBoy Feb 24, 2026
5e236a2
fixes
ElectricalBoy Feb 24, 2026
d561ba4
update results table
ElectricalBoy Feb 24, 2026
1ee5e55
reorganize imports
ElectricalBoy Feb 24, 2026
ef2ca47
refactor common cell types
ElectricalBoy Feb 24, 2026
6dabced
type annotation
ElectricalBoy Feb 24, 2026
f0f0651
use Opponent.isType
ElectricalBoy Feb 24, 2026
ade1eef
replace html code with html entity
ElectricalBoy Feb 24, 2026
aeabe8f
reorder imports
ElectricalBoy Feb 24, 2026
0054576
type annotations
ElectricalBoy Feb 24, 2026
97caacd
tune column defs
ElectricalBoy Feb 24, 2026
a9fb0d6
type anno
ElectricalBoy Feb 24, 2026
b78fad9
reduce include size a bit
ElectricalBoy Feb 24, 2026
80713ae
adjust column definitions
ElectricalBoy Feb 24, 2026
0936f72
this actually should be centered
ElectricalBoy Feb 24, 2026
33cd6d4
override header alignment
ElectricalBoy Feb 24, 2026
0b32def
adjust footer styling
ElectricalBoy Feb 24, 2026
9546d6b
use subheader
ElectricalBoy Feb 25, 2026
47617be
use new placement badges
ElectricalBoy Feb 25, 2026
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
226 changes: 129 additions & 97 deletions lua/wikis/commons/ResultsTable.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,122 +7,154 @@

local Lua = require('Module:Lua')

local Abbreviation = Lua.import('Module:Abbreviation')
local BaseResultsTable = Lua.import('Module:ResultsTable/Base')
local Class = Lua.import('Module:Class')
local Currency = Lua.import('Module:Currency')
local DateExt = Lua.import('Module:Date/Ext')
local FnUtil = Lua.import('Module:FnUtil')
local Game = Lua.import('Module:Game')
local LeagueIcon = Lua.import('Module:LeagueIcon')
local Page = Lua.import('Module:Page')
local Opponent = Lua.import('Module:Opponent/Custom')
local Placement = Lua.import('Module:Placement')
local Table = Lua.import('Module:Table')

local BaseResultsTable = Lua.import('Module:ResultsTable/Base')

local Opponent = Lua.import('Module:Opponent/Custom')
local HtmlWidgets = Lua.import('Module:Widget/Html/All')
local TableWidgets = Lua.import('Module:Widget/Table2/All')
local WidgetUtil = Lua.import('Module:Widget/Util')

---@class ResultsTable: BaseResultsTable
---@operator call(table): ResultsTable
local ResultsTable = Class.new(BaseResultsTable)

---@protected
---@return table[]
function ResultsTable:buildColumnDefinitions()
return WidgetUtil.collect(
{
align = 'left',
sortType = 'isoDate',
},
{align = 'center'},
{align = 'left'},
self.config.showType and {align = 'center'} or nil,
self.config.displayGameIcons and {align = 'center'} or nil,
{align = 'left'},
{align = 'left'},
(self.config.queryType ~= Opponent.team or Table.isNotEmpty(self.config.aliases)) and {
align = 'center',
} or self.config.playerResultsOfTeam and {
align = 'center',
} or nil,
not self.config.hideResult and {
{
align = 'center',
unsortable = true,
},
{
align = 'center',
unsortable = true,
},
} or nil,
{
align = 'right',
sortType = 'currency',
}
)
end

---Builds the Header of the results/achievements table
---@return Html
---@return Widget
function ResultsTable:buildHeader()
local header = mw.html.create('tr')
:tag('th'):css('width', '100px'):wikitext('Date'):done()
:tag('th'):css('min-width', '80px'):wikitext('Place'):done()
:tag('th'):css('min-width', '75px'):wikitext('Tier'):done()

if self.config.showType then
header:tag('th'):css('min-width', '50px'):wikitext('Type')
end

if self.config.displayGameIcons then
header:tag('th'):node(Abbreviation.make{text = 'G.', title = 'Game'})
end

header:tag('th'):css('width', '420px'):attr('colspan', 2):wikitext('Tournament')

if self.config.queryType ~= Opponent.team or Table.isNotEmpty(self.config.aliases) then
header:tag('th'):css('min-width', '70px'):wikitext('Team')
elseif self.config.playerResultsOfTeam then
header:tag('th'):css('min-width', '105px'):wikitext('Player')
end

if not self.config.hideResult then
header:tag('th'):css('min-width', '105px'):attr('colspan', 2):addClass('unsortable'):wikitext('Result')
end

header:tag('th'):attr('data-sort-type', 'currency'):wikitext('Prize')

return header
return TableWidgets.Row{children = WidgetUtil.collect(
TableWidgets.CellHeader{children = 'Date'},
TableWidgets.CellHeader{children = 'Place'},
TableWidgets.CellHeader{children = 'Tier'},
self.config.showType and TableWidgets.CellHeader{children = 'Type'} or nil,
self.config.displayGameIcons and TableWidgets.CellHeader{
children = HtmlWidgets.Abbreviation{children = 'G.', title = 'Game'}
} or nil,
TableWidgets.CellHeader{
colspan = 2,
children = 'Tournament'
},
(self.config.queryType ~= Opponent.team or Table.isNotEmpty(self.config.aliases)) and TableWidgets.CellHeader{
children = 'Team'
} or self.config.playerResultsOfTeam and TableWidgets.CellHeader{
children = 'Player'
} or nil,
not self.config.hideResult and TableWidgets.CellHeader{
align = 'left',
colspan = 2,
children = 'Result'
} or nil,
TableWidgets.CellHeader{children = 'Prize'}
)}
end

---Builds a placement row of the results/achievements table
---@param placement table
---@param placement placement
---@return Html
function ResultsTable:buildRow(placement)
local placementCell = mw.html.create('td')
Placement._placement{parent = placementCell, placement = placement.placement}

local row = mw.html.create('tr')
:addClass(self:rowHighlight(placement))
:tag('td'):wikitext(DateExt.toYmdInUtc(placement.date)):done()
:node(placementCell)

local tierDisplay, tierSortValue = self:tierDisplay(placement)

row:tag('td'):attr('data-sort-value', tierSortValue):wikitext(tierDisplay)

if self.config.showType then
row:tag('td'):wikitext(placement.type)
end

if self.config.displayGameIcons then
row:tag('td'):node(Game.icon{game = placement.game})
end

local tournamentDisplayName = BaseResultsTable.tournamentDisplayName(placement)

row
:tag('td'):css('width', '30px'):attr('data-sort-value', tournamentDisplayName):wikitext(LeagueIcon.display{
icon = placement.icon,
iconDark = placement.icondark,
link = placement.parent,
name = tournamentDisplayName,
options = {noTemplate = true},
}):done()
:tag('td'):attr('data-sort-value', tournamentDisplayName):css('text-align', 'left'):wikitext(Page.makeInternalLink(
{},
tournamentDisplayName,
placement.pagename
))

if self.config.playerResultsOfTeam or
self.config.queryType ~= Opponent.team or
Table.isNotEmpty(self.config.aliases) then

row:tag('td'):css('text-align', self.config.hideResult and 'left' or 'right')
:attr('data-sort-value', placement.opponentname)
:node(self:opponentDisplay(placement,
{teamForSolo = not self.config.playerResultsOfTeam, flip = not self.config.hideResult}
))
end
return TableWidgets.Row{
highlighted = self:rowHighlight(placement),
children = WidgetUtil.collect(
self:createDateCell(placement),
ResultsTable._placementToTableCell(placement.placement),
self:createTierCell(placement),
self:createTypeCell(placement),
self.config.displayGameIcons and TableWidgets.Cell{
children = Game.icon{game = placement.game}
} or nil,
self:createTournamentCells(placement),
(
self.config.playerResultsOfTeam or
self.config.queryType ~= Opponent.team or
Table.isNotEmpty(self.config.aliases)
) and TableWidgets.Cell{
align = self.config.hideResult and 'left' or 'right',
attributes = {
['data-sort-value'] = placement.opponentname
},
children = self:opponentDisplay(
placement,
{teamForSolo = not self.config.playerResultsOfTeam, flip = not self.config.hideResult}
)
} or nil,
self:_buildResultCells(placement),
self:createPrizeCell{
useIndivPrize = self.config.useIndivPrize and self.config.queryType ~= Opponent.team,
placement = placement
}
)
}
end

if not self.config.hideResult then
local score, vsDisplay, groupAbbr = self:processVsData(placement)
row
:tag('td'):wikitext(score):done()
:tag('td'):css('text-align', 'left'):cssText(groupAbbr and 'padding-left:14px' or nil):node(vsDisplay or groupAbbr)
---@private
---@param placement string
---@return Widget
ResultsTable._placementToTableCell = FnUtil.memoize(function (placement)
local rawPlacement = Placement.raw(placement or '')
return TableWidgets.Cell{
attributes = {
['data-sort-value'] = rawPlacement.sort
},
children = Placement.renderInWidget{placement = placement}
}
end)

---@private
---@param placement placement
---@return Widget[]?
function ResultsTable:_buildResultCells(placement)
if self.config.hideResult then
return
end

local useIndivPrize = self.config.useIndivPrize and self.config.queryType ~= Opponent.team
row:tag('td'):wikitext(Currency.display('USD',
useIndivPrize and placement.individualprizemoney or placement.prizemoney,
{dashIfZero = true, displayCurrencyCode = false, formatValue = true}
))

return row
local score, vsDisplay, groupAbbr = self:processVsData(placement)
return {
TableWidgets.Cell{children = score},
TableWidgets.Cell{
align = 'left',
css = {padding = groupAbbr and '14px' or nil},
children = vsDisplay or groupAbbr
}
}
end

return ResultsTable
Loading
Loading