From c9cfc0141416c5386e19f93377bc9f77413917a8 Mon Sep 17 00:00:00 2001 From: Eetu Rantanen Date: Thu, 19 Feb 2026 15:43:50 +0200 Subject: [PATCH 01/11] use Table2 for squad --- lua/wikis/commons/Squad/Row.lua | 54 +++---- lua/wikis/commons/Widget/Squad/Core.lua | 48 ++++--- stylesheets/Main.scss | 1 - stylesheets/commons/RosterCard.scss | 180 ------------------------ 4 files changed, 42 insertions(+), 241 deletions(-) delete mode 100644 stylesheets/commons/RosterCard.scss diff --git a/lua/wikis/commons/Squad/Row.lua b/lua/wikis/commons/Squad/Row.lua index ac7798f9758..0e32e9ae4b0 100644 --- a/lua/wikis/commons/Squad/Row.lua +++ b/lua/wikis/commons/Squad/Row.lua @@ -14,7 +14,8 @@ local OpponentDisplay = Lua.import('Module:OpponentDisplay/Custom') local String = Lua.import('Module:StringUtils') local Template = Lua.import('Module:Template') -local Widget = Lua.import('Module:Widget/All') +local Table2Widgets = Lua.import('Module:Widget/Table2/All') +local Row, Cell = Table2Widgets.Row, Table2Widgets.Cell local RoleIcons = { captain = Icon.makeIcon{iconName = 'captain', hover = 'Captain'}, @@ -52,16 +53,14 @@ function SquadRow:id() table.insert(content, ' ' .. roleIcon) end - local cell = Widget.Td{ - classes = {'ID'}, + local cell = Cell{ children = content, } local date = self.model.leavedate or self.model.inactivedate local hasTeam = self.model.extradata.loanedto and mw.ext.TeamTemplate.teamexists(self.model.extradata.loanedto) local hasTeamRole = hasTeam and self.model.extradata.loanedtorole - local teamNode = Widget.Td{ - css = hasTeamRole and {'text-align', 'center'} or nil, + local teamNode = Cell{ children = { hasTeam and mw.ext.TeamTemplate.teamicon(self.model.extradata.loanedto, date) or nil, hasTeamRole and mw.html.create('small'):tag('i'):wikitext(self.model.extradata.loanedtorole) or nil, @@ -76,12 +75,8 @@ end ---@return self function SquadRow:name() - table.insert(self.children, Widget.Td{ - classes = {'Name'}, - children = String.isNotEmpty(self.model.name) and { - mw.html.create('div'):addClass('MobileStuff'):wikitext('(', self.model.name, ')'), - mw.html.create('div'):addClass('LargeStuff'):wikitext(self.model.name), - } or nil + table.insert(self.children, Cell{ + children = String.isNotEmpty(self.model.name) and {self.model.name} or nil, }) return self @@ -91,12 +86,8 @@ end function SquadRow:role() local display = String.isNotEmpty(self.model.role) and not RoleIcons[self.model.role:lower()] - table.insert(self.children, Widget.Td{ - classes = {'Position'}, - children = display and { - mw.html.create('div'):addClass('MobileStuff'):wikitext('Role: '), - mw.html.create('i'):wikitext('(' .. self.model.role .. ')'), - } or nil, + table.insert(self.children, Cell{ + children = display and {self.model.role} or nil, }) return self @@ -110,20 +101,17 @@ function SquadRow:position() local content = {} if String.isNotEmpty(self.model.position) or String.isNotEmpty(self.model.role) then - table.insert(content, mw.html.create('div'):addClass('MobileStuff'):wikitext('Position: ')) - if String.isNotEmpty(self.model.position) then table.insert(content, self.model.position) if displayRole then - table.insert(content, ' (' .. self.model.role .. ')') + table.insert(content, ' (' .. self.model.role .. ')') end elseif displayRole then table.insert(content, self.model.role) end end - table.insert(self.children, Widget.Td{ - classes = {'Position'}, + table.insert(self.children, Cell{ children = content, }) @@ -134,13 +122,10 @@ end ---@param cellTitle string? ---@return self function SquadRow:date(field, cellTitle) - table.insert(self.children, Widget.Td{ - classes = {'Date'}, + table.insert(self.children, Cell{ children = self.model[field] and { - mw.html.create('div'):addClass('MobileStuffDate'):wikitext(cellTitle), - mw.html.create('div'):addClass('Date') - :tag('i'):wikitext(self.model.extradata[field .. 'display'] or self.model[field]) - } or nil + mw.html.create('i'):wikitext(self.model.extradata[field .. 'display'] or self.model[field]), + } or nil, }) return self @@ -158,16 +143,13 @@ function SquadRow:newteam() return content end - table.insert(content, mw.html.create('div'):addClass('MobileStuff') - :tag('i'):addClass('fa fa-long-arrow-right'):attr('aria-hidden', 'true'):done():wikitext(' ')) - if hasNewTeamSpecial then table.insert(content, Template.safeExpand(mw.getCurrentFrame(), newTeamSpecial)) return content end if not hasNewTeam then - table.insert(content, mw.html.create('div'):addClass('NewTeamRole'):wikitext(newTeamRole)) + table.insert(content, newTeamRole) return content end @@ -175,14 +157,12 @@ function SquadRow:newteam() table.insert(content, mw.ext.TeamTemplate.team(newTeam, date)) if hasNewTeamRole then - table.insert(content, ' ') - table.insert(content, mw.html.create('i'):tag('small'):wikitext('(' .. newTeamRole .. ')')) + table.insert(content, ' (' .. newTeamRole .. ')') end return content end - table.insert(self.children, Widget.Td{ - classes = {'NewTeam'}, + table.insert(self.children, Cell{ children = createContent(), }) @@ -202,7 +182,7 @@ function SquadRow:create() table.insert(backgrounds, 'roster-coach') end - return Widget.Tr{ + return Row{ classes = backgrounds, children = self.children, } diff --git a/lua/wikis/commons/Widget/Squad/Core.lua b/lua/wikis/commons/Widget/Squad/Core.lua index 1cf6a7a840d..7ded8f91a7f 100644 --- a/lua/wikis/commons/Widget/Squad/Core.lua +++ b/lua/wikis/commons/Widget/Squad/Core.lua @@ -12,12 +12,13 @@ local Logic = Lua.import('Module:Logic') local String = Lua.import('Module:StringUtils') local SquadUtils = Lua.import('Module:Squad/Utils') -local Widgets = Lua.import('Module:Widget/All') +local Table2Widgets = Lua.import('Module:Widget/Table2/All') local Widget = Lua.import('Module:Widget') local WidgetUtil = Lua.import('Module:Widget/Util') local SquadContexts = Lua.import('Module:Widget/Contexts/Squad') -local DataTable, Tr, Th = Widgets.DataTable, Widgets.Tr, Widgets.Th +local Table2, TableHeader, TableBody, Row, CellHeader = + Table2Widgets.Table, Table2Widgets.TableHeader, Table2Widgets.TableBody, Table2Widgets.Row, Table2Widgets.CellHeader ---@class SquadWidget: Widget ---@operator call(table): SquadWidget @@ -39,24 +40,28 @@ local SquadTypeToDisplay = { [SquadUtils.SquadType.STAFF] = 'Organization', } ----@return WidgetDataTable +---@return Table2 function Squad:render() local title = self:_title(self.props.status, self.props.title, self.props.type) local header = self:_header(self.props.status) - local allChildren = WidgetUtil.collect(title, header, unpack(self.props.children)) - - return DataTable{ - classes = {'wikitable-striped', 'roster-card'}, - wrapperClasses = {'roster-card-wrapper'}, - children = allChildren, + return Table2{ + title = title, + children = { + TableHeader{ + children = {header}, + }, + TableBody{ + children = self.props.children, + }, + }, } end ---@param squadStatus SquadStatus ---@param title string? ---@param squadType SquadType ----@return Widget? +---@return string? function Squad:_title(squadStatus, title, squadType) local defaultTitle -- TODO: Work away this special case @@ -75,9 +80,7 @@ function Squad:_title(squadStatus, title, squadType) return end - return Tr{ - children = {Th{children = {titleText}, attributes={colspan = 10}}} - } + return titleText end ---@param status SquadStatus @@ -86,24 +89,23 @@ function Squad:_header(status) local isInactive = status == SquadUtils.SquadStatus.INACTIVE or status == SquadUtils.SquadStatus.FORMER_INACTIVE local isFormer = status == SquadUtils.SquadStatus.FORMER or status == SquadUtils.SquadStatus.FORMER_INACTIVE - local name = self:useContext(SquadContexts.NameSection, {Th{children = {'Name'}}}) + local name = self:useContext(SquadContexts.NameSection, {CellHeader{children = {'Name'}}}) local inactive = isInactive and self:useContext(SquadContexts.InactiveSection, { - Th{children = {'Inactive Date'}} + CellHeader{children = {'Inactive Date'}} }) or nil local former = isFormer and self:useContext(SquadContexts.FormerSection, { - Th{children = {'Leave Date'}}, - Th{children = {'New Team'}}, + CellHeader{children = {'Leave Date'}}, + CellHeader{children = {'New Team'}}, }) or nil - local role = {Th{children = {self:useContext(SquadContexts.RoleTitle)}}} + local role = {CellHeader{children = {self:useContext(SquadContexts.RoleTitle)}}} - return Tr{ - classes = {'HeaderRow'}, + return Row{ children = WidgetUtil.collect( - Th{children = {'ID'}}, - Th{}, -- "Team Icon" (most commmonly used for loans) + CellHeader{children = {'ID'}}, + CellHeader{}, -- "Team Icon" (most commmonly used for loans) name, role, - Th{children = {'Join Date'}}, + CellHeader{children = {'Join Date'}}, inactive, former ) diff --git a/stylesheets/Main.scss b/stylesheets/Main.scss index 9ffe2c8f366..b5f39d63f02 100644 --- a/stylesheets/Main.scss +++ b/stylesheets/Main.scss @@ -34,7 +34,6 @@ @use "commons/Faction"; @use "commons/HexagonPortraits"; @use "commons/ResponsiveTable"; -@use "commons/RosterCard"; @use "commons/TeamPortal"; @use "commons/TournamentCard"; @use "commons/NavFrame"; diff --git a/stylesheets/commons/RosterCard.scss b/stylesheets/commons/RosterCard.scss deleted file mode 100644 index 646de0774a6..00000000000 --- a/stylesheets/commons/RosterCard.scss +++ /dev/null @@ -1,180 +0,0 @@ -/******************************************************************************* -Template(s): Roster Cards ( SquadPlayer_start; SquadPlayer ) -Author(s): Rapture -*******************************************************************************/ -.roster-card-wrapper { - margin: 0 0 10px 0; -} - -.roster-card { - display: table; - white-space: nowrap; -} - -.roster-card > tbody > tr > th { - background-color: var( --clr-surface-4, #f5f5f5 ); - font-weight: bold; - padding: 5px; -} - -.roster-card > tbody > tr.HeaderRow > th { - background-color: var( --table-subheader-background-color, var( --clr-surface-4, #f5f5f5 ) ); -} - -.roster-card > tbody > tr:not( .HeaderRow ) > th { - background-color: var( --table-header-background-color, var( --clr-surface-4, #f5f5f5 ) ); -} - -.roster-card > tbody > tr.Player { - display: table-row; - border-top: 1px solid var( --clr-border, #bbbbbb ); -} - -.roster-card > tbody > tr.Player > td { - display: table-cell; - line-height: 1.42857143; - padding: 5px; -} - -.roster-card > tbody > tr.Player > td.Team2 { - padding: 2px 0 0 0; -} - -.roster-card > tbody > tr.Player > td.Position { - text-align: center; -} - -.roster-card > tbody > tr.Player > td.PositionWoTeam2 { - text-align: center; -} - -.roster-card > tbody > tr.Player > td.NewTeam { - padding: 2px 5px 2px 5px; -} - -.roster-card > tbody > tr.Player > td > .MobileStuff { - display: none; -} - -.roster-card > tbody > tr.Player > td > div.MobileStuffDate { - display: none; -} - -.roster-card > tbody > tr.Player > td > div.Date { - font-style: italic; - text-align: center; -} - -.roster-card > tbody > tr.Player > td.NewTeam > div.NewTeamRole { - text-align: center; - font-style: italic; -} - -.roster-none, -.roster-coach { - background-color: var( --table-variant-background-color, var( --clr-surface-variant, #e5e5e5 ) ) !important; -} - -.roster-title-row2-border { - border-bottom: 1px solid var( --table-border-color, var( --clr-border, #bbbbbb ) ); -} - -@media screen and ( max-width: 750px ) { - .roster-card { - width: 100% !important; - max-width: 425px; - border: 1px solid var( --table-border-color, var( --clr-border, #bbbbbb ) ); - } - - .roster-card > tbody > tr.HeaderRow { - display: none; - } - - .roster-card > tbody > tr.Player { - display: block; - padding: 5px; - } - - .roster-card > tbody > tr.Player > td { - display: inline-block; - line-height: 1.42857143; - border: 0 !important; - padding: 0; - } - - .roster-card > tbody > tr.Player > td.ID { - float: left; - padding: 0 5px 0 0; - } - - .roster-card > tbody > tr.Player > td.Name { - font-style: italic; - font-size: small; - float: left; - margin-top: 1px; - } - - .roster-card > tbody > tr.Player > td.Team2 { - float: right; - } - - .roster-card > tbody > tr.Player > td.Position { - font-style: italic; - text-align: left; - font-size: small; - clear: left; - float: left; - } - - .roster-card > tbody > tr.Player > td.PositionWoTeam2 { - font-style: italic; - text-align: right; - font-size: small; - float: right; - } - - .roster-card > tbody > tr.Player > td.NewTeam { - display: block; - width: 100%; - text-align: center; - clear: both; - border-right: 0; - } - - .roster-card > tbody > tr.Player > td > .LargeStuff { - display: none; - } - - .roster-card > tbody > tr.Player > td > .MobileStuff { - display: inline-block; - } - - .roster-card > tbody > tr.Player > td.Date { - display: block; - width: 100%; - clear: both; - border-right: 0; - } - - .roster-card > tbody > tr.Player > td > div.MobileStuffDate { - display: inline-block; - width: 50%; - text-align: right; - font-style: italic; - float: left; - } - - .roster-card > tbody > tr.Player > td > div.Date { - display: inline-block; - width: 50%; - text-align: left; - font-style: italic; - } - - .roster-card > tbody > tr.Player > td.NewTeam > div.NewTeamRole { - display: inline-block; - text-align: left; - font-style: italic; - border-right: 0; - } -} From e611a026d411984cd7a797e990f384dd2ac389f1 Mon Sep 17 00:00:00 2001 From: Eetu Rantanen Date: Thu, 19 Feb 2026 16:12:41 +0200 Subject: [PATCH 02/11] convert to widget system --- lua/wikis/commons/Squad/Row.lua | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lua/wikis/commons/Squad/Row.lua b/lua/wikis/commons/Squad/Row.lua index 0e32e9ae4b0..cf1e326f647 100644 --- a/lua/wikis/commons/Squad/Row.lua +++ b/lua/wikis/commons/Squad/Row.lua @@ -15,6 +15,7 @@ local String = Lua.import('Module:StringUtils') local Template = Lua.import('Module:Template') local Table2Widgets = Lua.import('Module:Widget/Table2/All') +local HtmlWidgets = Lua.import('Module:Widget/Html/All') local Row, Cell = Table2Widgets.Row, Table2Widgets.Cell local RoleIcons = { @@ -35,7 +36,6 @@ local SquadRow = Class.new( ---@return self function SquadRow:id() - local content = {} local opponent = Opponent.resolve( Opponent.readOpponentArgs{ self.model.id, @@ -46,15 +46,17 @@ function SquadRow:id() }, nil, {syncPlayer = true} ) - table.insert(content, mw.html.create('b'):node(OpponentDisplay.InlineOpponent{opponent = opponent})) + local idContent = { + HtmlWidgets.B{children = {OpponentDisplay.InlineOpponent{opponent = opponent}}}, + } local roleIcon = RoleIcons[(self.model.role or ''):lower()] if roleIcon then - table.insert(content, ' ' .. roleIcon) + table.insert(idContent, ' ' .. roleIcon) end local cell = Cell{ - children = content, + children = idContent, } local date = self.model.leavedate or self.model.inactivedate @@ -63,7 +65,7 @@ function SquadRow:id() local teamNode = Cell{ children = { hasTeam and mw.ext.TeamTemplate.teamicon(self.model.extradata.loanedto, date) or nil, - hasTeamRole and mw.html.create('small'):tag('i'):wikitext(self.model.extradata.loanedtorole) or nil, + hasTeamRole and HtmlWidgets.Small{children = {HtmlWidgets.I{children = {self.model.extradata.loanedtorole}}}} or nil, } } @@ -124,7 +126,7 @@ end function SquadRow:date(field, cellTitle) table.insert(self.children, Cell{ children = self.model[field] and { - mw.html.create('i'):wikitext(self.model.extradata[field .. 'display'] or self.model[field]), + HtmlWidgets.I{children = {self.model.extradata[field .. 'display'] or self.model[field]}}, } or nil, }) From d2d895417a54d82f88ef2dd58a1dc4c7e499d9ea Mon Sep 17 00:00:00 2001 From: Eetu Rantanen Date: Fri, 20 Feb 2026 10:05:22 +0200 Subject: [PATCH 03/11] clean up --- lua/wikis/commons/Squad/Row.lua | 15 +-------------- lua/wikis/commons/Squad/Utils.lua | 6 +++--- lua/wikis/dota2/Squad/Custom.lua | 6 +++--- lua/wikis/overwatch/Squad/Custom.lua | 6 +++--- lua/wikis/smash/Squad/Custom.lua | 6 +++--- lua/wikis/starcraft/Squad/Custom.lua | 6 +++--- lua/wikis/starcraft2/Squad/Custom.lua | 6 +++--- lua/wikis/stormgate/Squad/Custom.lua | 6 +++--- 8 files changed, 22 insertions(+), 35 deletions(-) diff --git a/lua/wikis/commons/Squad/Row.lua b/lua/wikis/commons/Squad/Row.lua index cf1e326f647..113f8294397 100644 --- a/lua/wikis/commons/Squad/Row.lua +++ b/lua/wikis/commons/Squad/Row.lua @@ -121,9 +121,8 @@ function SquadRow:position() end ---@param field string ----@param cellTitle string? ---@return self -function SquadRow:date(field, cellTitle) +function SquadRow:date(field) table.insert(self.children, Cell{ children = self.model[field] and { HtmlWidgets.I{children = {self.model.extradata[field .. 'display'] or self.model[field]}}, @@ -173,19 +172,7 @@ end ---@return Widget function SquadRow:create() - -- Set row background for certain roles - local backgrounds = {'Player'} - local role = string.lower(self.model.role or '') - - if role == 'sub' then - table.insert(backgrounds, 'sub') - elseif role:find('coach') then - table.insert(backgrounds, role) - table.insert(backgrounds, 'roster-coach') - end - return Row{ - classes = backgrounds, children = self.children, } end diff --git a/lua/wikis/commons/Squad/Utils.lua b/lua/wikis/commons/Squad/Utils.lua index 5dbf246563c..90807c00e2a 100644 --- a/lua/wikis/commons/Squad/Utils.lua +++ b/lua/wikis/commons/Squad/Utils.lua @@ -257,14 +257,14 @@ function SquadUtils.defaultRow(squadRowClass) else row:role() end - row:date('joindate', 'Join Date: ') + row:date('joindate') if squadStatus == SquadUtils.SquadStatus.INACTIVE or squadStatus == SquadUtils.SquadStatus.FORMER_INACTIVE then - row:date('inactivedate', 'Inactive Date: ') + row:date('inactivedate') end if squadStatus == SquadUtils.SquadStatus.FORMER or squadStatus == SquadUtils.SquadStatus.FORMER_INACTIVE then - row:date('leavedate', 'Leave Date: ') + row:date('leavedate') row:newteam() end diff --git a/lua/wikis/dota2/Squad/Custom.lua b/lua/wikis/dota2/Squad/Custom.lua index c802226844b..b5b762d41a8 100644 --- a/lua/wikis/dota2/Squad/Custom.lua +++ b/lua/wikis/dota2/Squad/Custom.lua @@ -85,14 +85,14 @@ function CustomSquad._playerRow(person, squadStatus, squadType) row:id() row:name() row:position() - row:date('joindate', 'Join Date: ') + row:date('joindate') if squadStatus == SquadUtils.SquadStatus.INACTIVE or squadStatus == SquadUtils.SquadStatus.FORMER_INACTIVE then - row:date('inactivedate', 'Inactive Date: ') + row:date('inactivedate') row:activeteam() end if squadStatus == SquadUtils.SquadStatus.FORMER or squadStatus == SquadUtils.SquadStatus.FORMER_INACTIVE then - row:date('leavedate', 'Leave Date: ') + row:date('leavedate') row:newteam() end diff --git a/lua/wikis/overwatch/Squad/Custom.lua b/lua/wikis/overwatch/Squad/Custom.lua index 626f94263ff..115d4dd354b 100644 --- a/lua/wikis/overwatch/Squad/Custom.lua +++ b/lua/wikis/overwatch/Squad/Custom.lua @@ -94,14 +94,14 @@ function CustomSquad._playerRow(person, squadStatus, squadType, showNumber) if showNumber then row:number() end - row:name():position():date('joindate', 'Join Date: ') + row:name():position():date('joindate') if squadStatus == SquadUtils.SquadStatus.INACTIVE or squadStatus == SquadUtils.SquadStatus.FORMER_INACTIVE then - row:date('inactivedate', 'Inactive Date: ') + row:date('inactivedate') end if squadStatus == SquadUtils.SquadStatus.FORMER or squadStatus == SquadUtils.SquadStatus.FORMER_INACTIVE then - row:date('leavedate', 'Leave Date: ') + row:date('leavedate') row:newteam() end diff --git a/lua/wikis/smash/Squad/Custom.lua b/lua/wikis/smash/Squad/Custom.lua index 45d203db345..89a1fa4eb8f 100644 --- a/lua/wikis/smash/Squad/Custom.lua +++ b/lua/wikis/smash/Squad/Custom.lua @@ -69,14 +69,14 @@ function CustomSquad.run(frame) local row = ExtendedSquadRow(squadPerson) ---@type SmashSquadRow row:id():name() - row:mains():date('joindate', 'Join Date: ') + row:mains():date('joindate') if props.status == SquadUtils.SquadStatus.INACTIVE or props.status == SquadUtils.SquadStatus.FORMER_INACTIVE then - row:date('inactivedate', 'Inactive Date: ') + row:date('inactivedate') end if props.status == SquadUtils.SquadStatus.FORMER or props.status == SquadUtils.SquadStatus.FORMER_INACTIVE then - row:date('leavedate', 'Leave Date: ') + row:date('leavedate') row:newteam() end diff --git a/lua/wikis/starcraft/Squad/Custom.lua b/lua/wikis/starcraft/Squad/Custom.lua index 7fa681fad38..0150dffbdde 100644 --- a/lua/wikis/starcraft/Squad/Custom.lua +++ b/lua/wikis/starcraft/Squad/Custom.lua @@ -66,13 +66,13 @@ function CustomSquad.run(frame) row:elo() else row:role() - row:date('joindate', 'Join Date: ') + row:date('joindate') if squadStatus == SquadUtils.SquadStatus.FORMER then - row:date('leavedate', 'Leave Date: ') + row:date('leavedate') row:newteam() elseif squadStatus == SquadUtils.SquadStatus.INACTIVE then - row:date('inactivedate', 'Inactive Date: ') + row:date('inactivedate') end end diff --git a/lua/wikis/starcraft2/Squad/Custom.lua b/lua/wikis/starcraft2/Squad/Custom.lua index 948faf66b6b..5c3e0197844 100644 --- a/lua/wikis/starcraft2/Squad/Custom.lua +++ b/lua/wikis/starcraft2/Squad/Custom.lua @@ -68,13 +68,13 @@ function CustomSquad._playerRow(person, squadStatus, squadType) local row = SquadRow(squadPerson) - row:id():name():role():date('joindate', 'Join Date: ') + row:id():name():role():date('joindate') if squadStatus == SquadUtils.SquadStatus.INACTIVE or squadStatus == SquadUtils.SquadStatus.FORMER_INACTIVE then - row:date('inactivedate', 'Inactive Date: ') + row:date('inactivedate') end if squadStatus == SquadUtils.SquadStatus.FORMER or squadStatus == SquadUtils.SquadStatus.FORMER_INACTIVE then - row:date('leavedate', 'Leave Date: ') + row:date('leavedate') row:newteam() end diff --git a/lua/wikis/stormgate/Squad/Custom.lua b/lua/wikis/stormgate/Squad/Custom.lua index 8ac6d877788..0c44f3a2e80 100644 --- a/lua/wikis/stormgate/Squad/Custom.lua +++ b/lua/wikis/stormgate/Squad/Custom.lua @@ -66,13 +66,13 @@ function CustomSquad._playerRow(person, squadStatus, squadType) row:id() row:name() row:role() - row:date('joindate', 'Join Date: ') + row:date('joindate') if squadStatus == SquadUtils.SquadStatus.FORMER then - row:date('leavedate', 'Leave Date: ') + row:date('leavedate') row:newteam() elseif squadStatus == SquadUtils.SquadStatus.INACTIVE then - row:date('inactivedate', 'Inactive Date: ') + row:date('inactivedate') end return row:create() From a06f9556e96d13993fa0de51620f6b79e87e43b3 Mon Sep 17 00:00:00 2001 From: Eetu Rantanen Date: Fri, 20 Feb 2026 10:31:05 +0200 Subject: [PATCH 04/11] clean up --- lua/wikis/commons/Widget/Squad/Core.lua | 28 +++++++++++-------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/lua/wikis/commons/Widget/Squad/Core.lua b/lua/wikis/commons/Widget/Squad/Core.lua index 7ded8f91a7f..6372ad4a886 100644 --- a/lua/wikis/commons/Widget/Squad/Core.lua +++ b/lua/wikis/commons/Widget/Squad/Core.lua @@ -17,9 +17,6 @@ local Widget = Lua.import('Module:Widget') local WidgetUtil = Lua.import('Module:Widget/Util') local SquadContexts = Lua.import('Module:Widget/Contexts/Squad') -local Table2, TableHeader, TableBody, Row, CellHeader = - Table2Widgets.Table, Table2Widgets.TableHeader, Table2Widgets.TableBody, Table2Widgets.Row, Table2Widgets.CellHeader - ---@class SquadWidget: Widget ---@operator call(table): SquadWidget local Squad = Class.new(Widget) @@ -45,13 +42,13 @@ function Squad:render() local title = self:_title(self.props.status, self.props.title, self.props.type) local header = self:_header(self.props.status) - return Table2{ + return Table2Widgets.Table{ title = title, children = { - TableHeader{ + Table2Widgets.TableHeader{ children = {header}, }, - TableBody{ + Table2Widgets.TableBody{ children = self.props.children, }, }, @@ -69,7 +66,6 @@ function Squad:_title(squadStatus, title, squadType) (squadStatus == SquadUtils.SquadStatus.FORMER or squadStatus == SquadUtils.SquadStatus.FORMER_INACTIVE) then defaultTitle = 'Former Squad' - -- No default title for Active tables elseif squadStatus ~= SquadUtils.SquadStatus.ACTIVE then defaultTitle = SquadStatusToDisplay[squadStatus] .. ' ' .. SquadTypeToDisplay[squadType] end @@ -89,23 +85,23 @@ function Squad:_header(status) local isInactive = status == SquadUtils.SquadStatus.INACTIVE or status == SquadUtils.SquadStatus.FORMER_INACTIVE local isFormer = status == SquadUtils.SquadStatus.FORMER or status == SquadUtils.SquadStatus.FORMER_INACTIVE - local name = self:useContext(SquadContexts.NameSection, {CellHeader{children = {'Name'}}}) + local name = self:useContext(SquadContexts.NameSection, {Table2Widgets.CellHeader{children = {'Name'}}}) local inactive = isInactive and self:useContext(SquadContexts.InactiveSection, { - CellHeader{children = {'Inactive Date'}} + Table2Widgets.CellHeader{children = {'Inactive Date'}} }) or nil local former = isFormer and self:useContext(SquadContexts.FormerSection, { - CellHeader{children = {'Leave Date'}}, - CellHeader{children = {'New Team'}}, + Table2Widgets.CellHeader{children = {'Leave Date'}}, + Table2Widgets.CellHeader{children = {'New Team'}}, }) or nil - local role = {CellHeader{children = {self:useContext(SquadContexts.RoleTitle)}}} + local role = {Table2Widgets.CellHeader{children = {self:useContext(SquadContexts.RoleTitle)}}} - return Row{ + return Table2Widgets.Row{ children = WidgetUtil.collect( - CellHeader{children = {'ID'}}, - CellHeader{}, -- "Team Icon" (most commmonly used for loans) + Table2Widgets.CellHeader{children = {'ID'}}, + Table2Widgets.CellHeader{}, -- "Team Icon" (most commmonly used for loans) name, role, - CellHeader{children = {'Join Date'}}, + Table2Widgets.CellHeader{children = {'Join Date'}}, inactive, former ) From 66a4cf612599af92df3983aaf78ed6666123ae85 Mon Sep 17 00:00:00 2001 From: Eetu Rantanen Date: Fri, 20 Feb 2026 10:32:31 +0200 Subject: [PATCH 05/11] rename to TableWidgets --- lua/wikis/commons/Widget/Squad/Core.lua | 26 ++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/lua/wikis/commons/Widget/Squad/Core.lua b/lua/wikis/commons/Widget/Squad/Core.lua index 6372ad4a886..ee4d41b1a10 100644 --- a/lua/wikis/commons/Widget/Squad/Core.lua +++ b/lua/wikis/commons/Widget/Squad/Core.lua @@ -12,7 +12,7 @@ local Logic = Lua.import('Module:Logic') local String = Lua.import('Module:StringUtils') local SquadUtils = Lua.import('Module:Squad/Utils') -local Table2Widgets = Lua.import('Module:Widget/Table2/All') +local TableWidgets = Lua.import('Module:Widget/Table2/All') local Widget = Lua.import('Module:Widget') local WidgetUtil = Lua.import('Module:Widget/Util') local SquadContexts = Lua.import('Module:Widget/Contexts/Squad') @@ -42,13 +42,13 @@ function Squad:render() local title = self:_title(self.props.status, self.props.title, self.props.type) local header = self:_header(self.props.status) - return Table2Widgets.Table{ + return TableWidgets.Table{ title = title, children = { - Table2Widgets.TableHeader{ + TableWidgets.TableHeader{ children = {header}, }, - Table2Widgets.TableBody{ + TableWidgets.TableBody{ children = self.props.children, }, }, @@ -85,23 +85,23 @@ function Squad:_header(status) local isInactive = status == SquadUtils.SquadStatus.INACTIVE or status == SquadUtils.SquadStatus.FORMER_INACTIVE local isFormer = status == SquadUtils.SquadStatus.FORMER or status == SquadUtils.SquadStatus.FORMER_INACTIVE - local name = self:useContext(SquadContexts.NameSection, {Table2Widgets.CellHeader{children = {'Name'}}}) + local name = self:useContext(SquadContexts.NameSection, {TableWidgets.CellHeader{children = {'Name'}}}) local inactive = isInactive and self:useContext(SquadContexts.InactiveSection, { - Table2Widgets.CellHeader{children = {'Inactive Date'}} + TableWidgets.CellHeader{children = {'Inactive Date'}} }) or nil local former = isFormer and self:useContext(SquadContexts.FormerSection, { - Table2Widgets.CellHeader{children = {'Leave Date'}}, - Table2Widgets.CellHeader{children = {'New Team'}}, + TableWidgets.CellHeader{children = {'Leave Date'}}, + TableWidgets.CellHeader{children = {'New Team'}}, }) or nil - local role = {Table2Widgets.CellHeader{children = {self:useContext(SquadContexts.RoleTitle)}}} + local role = {TableWidgets.CellHeader{children = {self:useContext(SquadContexts.RoleTitle)}}} - return Table2Widgets.Row{ + return TableWidgets.Row{ children = WidgetUtil.collect( - Table2Widgets.CellHeader{children = {'ID'}}, - Table2Widgets.CellHeader{}, -- "Team Icon" (most commmonly used for loans) + TableWidgets.CellHeader{children = {'ID'}}, + TableWidgets.CellHeader{}, -- "Team Icon" (most commmonly used for loans) name, role, - Table2Widgets.CellHeader{children = {'Join Date'}}, + TableWidgets.CellHeader{children = {'Join Date'}}, inactive, former ) From 3d6939d57ba11463d2e92d2f1a11f03bd27bbe99 Mon Sep 17 00:00:00 2001 From: Eetu Rantanen Date: Fri, 20 Feb 2026 12:02:14 +0200 Subject: [PATCH 06/11] make nowrap default --- lua/wikis/commons/Widget/Table2/Cell.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lua/wikis/commons/Widget/Table2/Cell.lua b/lua/wikis/commons/Widget/Table2/Cell.lua index e51fd1e1bbf..be9680b91d3 100644 --- a/lua/wikis/commons/Widget/Table2/Cell.lua +++ b/lua/wikis/commons/Widget/Table2/Cell.lua @@ -34,6 +34,10 @@ local ColumnUtil = Lua.import('Module:Widget/Table2/ColumnUtil') ---@field props Table2CellProps local Table2Cell = Class.new(Widget) +Table2Cell.defaultProps = { + nowrap = true, +} + ---@return Widget function Table2Cell:render() local props = self.props From 3097bfed02e9151ae559893e9864f9b6ba979e44 Mon Sep 17 00:00:00 2001 From: Eetu Rantanen Date: Fri, 20 Feb 2026 12:26:14 +0200 Subject: [PATCH 07/11] fix cells no getting nowrap if columns are not defined --- lua/wikis/commons/Widget/Table2/Cell.lua | 7 ++++++- lua/wikis/commons/Widget/Table2/CellHeader.lua | 7 +++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lua/wikis/commons/Widget/Table2/Cell.lua b/lua/wikis/commons/Widget/Table2/Cell.lua index be9680b91d3..0eada517845 100644 --- a/lua/wikis/commons/Widget/Table2/Cell.lua +++ b/lua/wikis/commons/Widget/Table2/Cell.lua @@ -47,7 +47,12 @@ function Table2Cell:render() -- Skip context lookups and property merging if there are no column definitions if not columns then return HtmlWidgets.Td{ - attributes = props.attributes, + attributes = ColumnUtil.buildCellAttributes( + props.align, + props.nowrap, + props.shrink, + props.attributes + ), children = props.children, } end diff --git a/lua/wikis/commons/Widget/Table2/CellHeader.lua b/lua/wikis/commons/Widget/Table2/CellHeader.lua index cd6cce70707..9ec4127d69b 100644 --- a/lua/wikis/commons/Widget/Table2/CellHeader.lua +++ b/lua/wikis/commons/Widget/Table2/CellHeader.lua @@ -50,6 +50,13 @@ function Table2CellHeader:render() attributes.class = 'unsortable' end + attributes = ColumnUtil.buildCellAttributes( + props.align, + props.nowrap, + props.shrink, + attributes + ) + return HtmlWidgets.Th{ attributes = attributes, children = props.children, From 87708724be92adb4d8ee57d20626a31d7607b2af Mon Sep 17 00:00:00 2001 From: Eetu Rantanen Date: Fri, 20 Feb 2026 13:44:32 +0200 Subject: [PATCH 08/11] add column visibility context --- lua/wikis/commons/Squad/Row.lua | 60 ++++++++++++------ lua/wikis/commons/Squad/Utils.lua | 68 +++++++++++++++++---- lua/wikis/commons/Widget/Contexts/Squad.lua | 1 + lua/wikis/commons/Widget/Squad/Core.lua | 27 +++++--- lua/wikis/dota2/Squad/Custom.lua | 4 +- lua/wikis/overwatch/Squad/Custom.lua | 9 ++- lua/wikis/smash/Squad/Custom.lua | 12 ++-- lua/wikis/starcraft/Squad/Custom.lua | 4 +- lua/wikis/starcraft2/Squad/Custom.lua | 5 +- lua/wikis/stormgate/Squad/Custom.lua | 5 +- 10 files changed, 141 insertions(+), 54 deletions(-) diff --git a/lua/wikis/commons/Squad/Row.lua b/lua/wikis/commons/Squad/Row.lua index 113f8294397..b3f21e3a1df 100644 --- a/lua/wikis/commons/Squad/Row.lua +++ b/lua/wikis/commons/Squad/Row.lua @@ -23,14 +23,20 @@ local RoleIcons = { sub = Icon.makeIcon{iconName = 'substitute', hover = 'Substitute'}, } +local function shouldShowColumn(visibility, columnId) + return visibility == nil or visibility[columnId] == nil or visibility[columnId] == true +end + ---@class SquadRow: BaseClass ----@operator call(ModelRow): SquadRow +---@operator call(ModelRow, table?): SquadRow ---@field children Widget[] ---@field model ModelRow +---@field columnVisibility table? local SquadRow = Class.new( - function(self, squadPerson) + function(self, squadPerson, columnVisibility) self.children = {} self.model = assert(squadPerson, 'No Squad Person supplied to the Row') + self.columnVisibility = columnVisibility end ) @@ -55,28 +61,33 @@ function SquadRow:id() table.insert(idContent, ' ' .. roleIcon) end - local cell = Cell{ + table.insert(self.children, Cell{ children = idContent, - } - - local date = self.model.leavedate or self.model.inactivedate - local hasTeam = self.model.extradata.loanedto and mw.ext.TeamTemplate.teamexists(self.model.extradata.loanedto) - local hasTeamRole = hasTeam and self.model.extradata.loanedtorole - local teamNode = Cell{ - children = { - hasTeam and mw.ext.TeamTemplate.teamicon(self.model.extradata.loanedto, date) or nil, - hasTeamRole and HtmlWidgets.Small{children = {HtmlWidgets.I{children = {self.model.extradata.loanedtorole}}}} or nil, - } - } + }) - table.insert(self.children, cell) - table.insert(self.children, teamNode) + if shouldShowColumn(self.columnVisibility, 'teamIcon') then + local date = self.model.leavedate or self.model.inactivedate + local hasTeam = self.model.extradata.loanedto and mw.ext.TeamTemplate.teamexists(self.model.extradata.loanedto) + local hasTeamRole = hasTeam and self.model.extradata.loanedtorole + table.insert(self.children, Cell{ + children = { + hasTeam and mw.ext.TeamTemplate.teamicon(self.model.extradata.loanedto, date) or nil, + hasTeamRole and HtmlWidgets.Small{ + children = {HtmlWidgets.I{children = {self.model.extradata.loanedtorole}}} + } or nil, + } + }) + end return self end ---@return self function SquadRow:name() + if not shouldShowColumn(self.columnVisibility, 'name') then + return self + end + table.insert(self.children, Cell{ children = String.isNotEmpty(self.model.name) and {self.model.name} or nil, }) @@ -86,6 +97,10 @@ end ---@return self function SquadRow:role() + if not shouldShowColumn(self.columnVisibility, 'role') then + return self + end + local display = String.isNotEmpty(self.model.role) and not RoleIcons[self.model.role:lower()] table.insert(self.children, Cell{ @@ -95,9 +110,12 @@ function SquadRow:role() return self end ----Display Position and Role in a single cell ---@return self function SquadRow:position() + if not shouldShowColumn(self.columnVisibility, 'role') then + return self + end + local displayRole = String.isNotEmpty(self.model.role) and not RoleIcons[self.model.role:lower()] local content = {} @@ -123,6 +141,10 @@ end ---@param field string ---@return self function SquadRow:date(field) + if not shouldShowColumn(self.columnVisibility, field) then + return self + end + table.insert(self.children, Cell{ children = self.model[field] and { HtmlWidgets.I{children = {self.model.extradata[field .. 'display'] or self.model[field]}}, @@ -134,6 +156,10 @@ end ---@return self function SquadRow:newteam() + if not shouldShowColumn(self.columnVisibility, 'newteam') then + return self + end + local function createContent() local content = {} local newTeam, newTeamRole, newTeamSpecial = self.model.newteam, self.model.newteamrole, self.model.newteamspecial diff --git a/lua/wikis/commons/Squad/Utils.lua b/lua/wikis/commons/Squad/Utils.lua index 90807c00e2a..a4918ccde7c 100644 --- a/lua/wikis/commons/Squad/Utils.lua +++ b/lua/wikis/commons/Squad/Utils.lua @@ -185,11 +185,48 @@ function SquadUtils.readSquadPersonArgs(args) return person end ----@param squadPerson ModelRow +---@param person ModelRow function SquadUtils.storeSquadPerson(squadPerson) squadPerson:save() end +---@param players table[] +---@param squadStatus SquadStatus +---@return table +function SquadUtils.analyzeColumnVisibility(players, squadStatus) + local isInactive = squadStatus == SquadUtils.SquadStatus.INACTIVE + or squadStatus == SquadUtils.SquadStatus.FORMER_INACTIVE + local isFormer = squadStatus == SquadUtils.SquadStatus.FORMER + or squadStatus == SquadUtils.SquadStatus.FORMER_INACTIVE + + return { + teamIcon = Array.any(players, function(p) + local loanedTo = p.extradata and p.extradata.loanedto or p.loanedto + return loanedTo and mw.ext.TeamTemplate.teamexists(loanedTo) + end), + name = Array.any(players, function(p) + return String.isNotEmpty(p.name) + end), + role = Array.any(players, function(p) + return String.isNotEmpty(p.role) or String.isNotEmpty(p.position) + end), + joindate = Array.any(players, function(p) + return String.isNotEmpty(p.joindate) + end), + inactivedate = isInactive and Array.any(players, function(p) + return String.isNotEmpty(p.inactivedate) + end) or false, + leavedate = isFormer and Array.any(players, function(p) + return String.isNotEmpty(p.leavedate) + end) or false, + newteam = isFormer and Array.any(players, function(p) + return String.isNotEmpty(p.newteam) + or String.isNotEmpty(p.newteamrole) + or String.isNotEmpty(p.newteamspecial) + end) or false, + } +end + ---@param frame table ---@param squadWidget SquadWidget ---@param rowCreator fun(player: table, squadStatus: SquadStatus, squadType: SquadType):Widget @@ -207,49 +244,54 @@ function SquadUtils.defaultRunManual(frame, squadWidget, rowCreator) props.status = SquadUtils.SquadStatus.FORMER_INACTIVE end + local columnVisibility = SquadUtils.analyzeColumnVisibility(players, props.status) props.children = Array.map(players, function(player) - return rowCreator(player, props.status, props.type) + return rowCreator(player, props.status, props.type, columnVisibility) end) + local output = squadWidget(props) + output = SquadContexts.ColumnVisibility{value = columnVisibility, children = {output}} if Info.config.squads.hasPosition then - return SquadContexts.RoleTitle{value = SquadUtils.positionTitle(), children = {squadWidget(props)}} + output = SquadContexts.RoleTitle{value = SquadUtils.positionTitle(), children = {output}} end - return squadWidget(props) + return output end ---@param players table[] ---@param squadStatus SquadStatus ---@param squadType SquadType ---@param squadWidget SquadWidget ----@param rowCreator fun(person: table, squadStatus: SquadStatus, squadType: SquadType):Widget +---@param rowCreator fun(person: table, squadStatus: SquadStatus, squadType: SquadType, columnVisibility: table):Widget ---@param customTitle string? ---@param personMapper? fun(person: table): table ---@return Widget function SquadUtils.defaultRunAuto(players, squadStatus, squadType, squadWidget, rowCreator, customTitle, personMapper) + local mappedPlayers = Array.map(players, personMapper or SquadUtils.convertAutoParameters) + local columnVisibility = SquadUtils.analyzeColumnVisibility(mappedPlayers, squadStatus) local props = { status = squadStatus, title = customTitle, type = squadType, } - - local mappedPlayers = Array.map(players, personMapper or SquadUtils.convertAutoParameters) props.children = Array.map(mappedPlayers, function(player) - return rowCreator(player, props.status, props.type) + return rowCreator(player, props.status, props.type, columnVisibility) end) + local output = squadWidget(props) + output = SquadContexts.ColumnVisibility{value = columnVisibility, children = {output}} if Info.config.squads.hasPosition then - return SquadContexts.RoleTitle{value = SquadUtils.positionTitle(), children = {squadWidget(props)}} + output = SquadContexts.RoleTitle{value = SquadUtils.positionTitle(), children = {output}} end - return squadWidget(props) + return output end ---@param squadRowClass SquadRow ----@return fun(person: table, squadStatus: SquadStatus, squadType: SquadType):Widget +---@return fun(person: table, squadStatus: SquadStatus, squadType: SquadType, columnVisibility: table?):Widget function SquadUtils.defaultRow(squadRowClass) - return function(person, squadStatus, squadType) + return function(person, squadStatus, squadType, columnVisibility) local squadPerson = SquadUtils.readSquadPersonArgs(Table.merge(person, {status = squadStatus, type = squadType})) SquadUtils.storeSquadPerson(squadPerson) - local row = squadRowClass(squadPerson) + local row = squadRowClass(squadPerson, columnVisibility) row:id():name() if Info.config.squads.hasPosition then diff --git a/lua/wikis/commons/Widget/Contexts/Squad.lua b/lua/wikis/commons/Widget/Contexts/Squad.lua index d58dd19d150..50827a26a53 100644 --- a/lua/wikis/commons/Widget/Contexts/Squad.lua +++ b/lua/wikis/commons/Widget/Contexts/Squad.lua @@ -15,4 +15,5 @@ return { RoleTitle = Class.new(Context), InactiveSection = Class.new(Context), FormerSection = Class.new(Context), + ColumnVisibility = Class.new(Context), } diff --git a/lua/wikis/commons/Widget/Squad/Core.lua b/lua/wikis/commons/Widget/Squad/Core.lua index ee4d41b1a10..cb31b9313a9 100644 --- a/lua/wikis/commons/Widget/Squad/Core.lua +++ b/lua/wikis/commons/Widget/Squad/Core.lua @@ -82,26 +82,35 @@ end ---@param status SquadStatus ---@return Widget function Squad:_header(status) + local visibility = self:useContext(SquadContexts.ColumnVisibility) + + local function show(col) + return visibility == nil or visibility[col] == nil or visibility[col] == true + end + local isInactive = status == SquadUtils.SquadStatus.INACTIVE or status == SquadUtils.SquadStatus.FORMER_INACTIVE local isFormer = status == SquadUtils.SquadStatus.FORMER or status == SquadUtils.SquadStatus.FORMER_INACTIVE - local name = self:useContext(SquadContexts.NameSection, {TableWidgets.CellHeader{children = {'Name'}}}) - local inactive = isInactive and self:useContext(SquadContexts.InactiveSection, { + local name = show('name') and self:useContext( + SquadContexts.NameSection, + {TableWidgets.CellHeader{children = {'Name'}}} + ) or nil + local inactive = isInactive and show('inactivedate') and self:useContext(SquadContexts.InactiveSection, { TableWidgets.CellHeader{children = {'Inactive Date'}} }) or nil - local former = isFormer and self:useContext(SquadContexts.FormerSection, { - TableWidgets.CellHeader{children = {'Leave Date'}}, - TableWidgets.CellHeader{children = {'New Team'}}, - }) or nil - local role = {TableWidgets.CellHeader{children = {self:useContext(SquadContexts.RoleTitle)}}} + local former = isFormer and WidgetUtil.collect( + show('leavedate') and TableWidgets.CellHeader{children = {'Leave Date'}} or nil, + show('newteam') and TableWidgets.CellHeader{children = {'New Team'}} or nil + ) or nil + local role = show('role') and {TableWidgets.CellHeader{children = {self:useContext(SquadContexts.RoleTitle)}}} or nil return TableWidgets.Row{ children = WidgetUtil.collect( TableWidgets.CellHeader{children = {'ID'}}, - TableWidgets.CellHeader{}, -- "Team Icon" (most commmonly used for loans) + show('teamIcon') and TableWidgets.CellHeader{} or nil, name, role, - TableWidgets.CellHeader{children = {'Join Date'}}, + show('joindate') and TableWidgets.CellHeader{children = {'Join Date'}} or nil, inactive, former ) diff --git a/lua/wikis/dota2/Squad/Custom.lua b/lua/wikis/dota2/Squad/Custom.lua index b5b762d41a8..6f45b636b38 100644 --- a/lua/wikis/dota2/Squad/Custom.lua +++ b/lua/wikis/dota2/Squad/Custom.lua @@ -75,13 +75,13 @@ function CustomSquad.runAuto(playerList, squadStatus, squadType, customTitle) ) end -function CustomSquad._playerRow(person, squadStatus, squadType) +function CustomSquad._playerRow(person, squadStatus, squadType, columnVisibility) local squadPerson = SquadUtils.readSquadPersonArgs(Table.merge(person, {status = squadStatus, type = squadType})) squadPerson.extradata.activeteam = person.activeteam squadPerson.extradata.activeteamrole = person.activeteamrole SquadUtils.storeSquadPerson(squadPerson) - local row = ExtendedSquadRow(squadPerson) + local row = ExtendedSquadRow(squadPerson, columnVisibility) row:id() row:name() row:position() diff --git a/lua/wikis/overwatch/Squad/Custom.lua b/lua/wikis/overwatch/Squad/Custom.lua index 115d4dd354b..5ce0f35ef3d 100644 --- a/lua/wikis/overwatch/Squad/Custom.lua +++ b/lua/wikis/overwatch/Squad/Custom.lua @@ -50,12 +50,14 @@ function CustomSquad.run(frame) local players = SquadUtils.parsePlayers(args) local showNumber = Array.any(players, Operator.property('number')) + local columnVisibility = SquadUtils.analyzeColumnVisibility(players, props.status) props.children = Array.map(players, function(player) - return CustomSquad._playerRow(player, props.status, props.type, showNumber) + return CustomSquad._playerRow(player, props.status, props.type, showNumber, columnVisibility) end) local root = SquadContexts.RoleTitle{value = SquadUtils.positionTitle(), children = {Squad(props)}} + root = SquadContexts.ColumnVisibility{value = columnVisibility, children = {root}} if not showNumber then return root end @@ -82,13 +84,14 @@ end ---@param squadStatus SquadStatus ---@param squadType SquadType ---@param showNumber boolean +---@param columnVisibility table? ---@return Widget -function CustomSquad._playerRow(person, squadStatus, squadType, showNumber) +function CustomSquad._playerRow(person, squadStatus, squadType, showNumber, columnVisibility) local squadPerson = SquadUtils.readSquadPersonArgs(Table.merge(person, {status = squadStatus, type = squadType})) squadPerson.extradata.number = person.number SquadUtils.storeSquadPerson(squadPerson) - local row = ExtendedSquadRow(squadPerson) + local row = ExtendedSquadRow(squadPerson, columnVisibility) row:id() if showNumber then diff --git a/lua/wikis/smash/Squad/Custom.lua b/lua/wikis/smash/Squad/Custom.lua index 89a1fa4eb8f..38fea14f357 100644 --- a/lua/wikis/smash/Squad/Custom.lua +++ b/lua/wikis/smash/Squad/Custom.lua @@ -54,6 +54,7 @@ function CustomSquad.run(frame) local tableGame = args.game local players = SquadUtils.parsePlayers(args) + local columnVisibility = SquadUtils.analyzeColumnVisibility(players, props.status) props.children = Array.map(players, function(person) local game = person.game and mw.text.split(person.game:lower(), ',')[1] or tableGame @@ -66,7 +67,7 @@ function CustomSquad.run(frame) squadPerson.extradata.mains = mains SquadUtils.storeSquadPerson(squadPerson) - local row = ExtendedSquadRow(squadPerson) ---@type SmashSquadRow + local row = ExtendedSquadRow(squadPerson, columnVisibility) ---@type SmashSquadRow row:id():name() row:mains():date('joindate') @@ -87,9 +88,12 @@ function CustomSquad.run(frame) end) - return SquadContexts.RoleTitle{ - value = 'Main', - children = {Squad(props)} + return SquadContexts.ColumnVisibility{ + value = columnVisibility, + children = {SquadContexts.RoleTitle{ + value = 'Main', + children = {Squad(props)} + }} } end diff --git a/lua/wikis/starcraft/Squad/Custom.lua b/lua/wikis/starcraft/Squad/Custom.lua index 0150dffbdde..a3cae4521fd 100644 --- a/lua/wikis/starcraft/Squad/Custom.lua +++ b/lua/wikis/starcraft/Squad/Custom.lua @@ -44,7 +44,7 @@ function CustomSquad.run(frame) local tlpd = Logic.readBool(args.tlpd) local SquadClass = tlpd and SquadTldb or Squad - return SquadUtils.defaultRunManual(frame, SquadClass, function(person, squadStatus, squadType) + return SquadUtils.defaultRunManual(frame, SquadClass, function(person, squadStatus, squadType, columnVisibility) local inputId = person.id --[[@as number]] person.race = CustomSquad._queryTLPD(inputId, 'race') or person.race person.id = CustomSquad._queryTLPD(inputId, 'name') or person.id @@ -58,7 +58,7 @@ function CustomSquad.run(frame) squadPerson.extradata.eloPeak = CustomSquad._queryTLPD(inputId, 'peak_elo') SquadUtils.storeSquadPerson(squadPerson) - local row = ExtendedSquadRow(squadPerson) + local row = ExtendedSquadRow(squadPerson, columnVisibility) row:id():name() diff --git a/lua/wikis/starcraft2/Squad/Custom.lua b/lua/wikis/starcraft2/Squad/Custom.lua index 5c3e0197844..3ed6974222d 100644 --- a/lua/wikis/starcraft2/Squad/Custom.lua +++ b/lua/wikis/starcraft2/Squad/Custom.lua @@ -51,8 +51,9 @@ end ---@param person table ---@param squadStatus SquadStatus ---@param squadType SquadType +---@param columnVisibility table? ---@return Widget -function CustomSquad._playerRow(person, squadStatus, squadType) +function CustomSquad._playerRow(person, squadStatus, squadType, columnVisibility) local squadPerson = SquadUtils.readSquadPersonArgs(Table.merge(person, {status = squadStatus, type = squadType})) local squadArgs = Arguments.getArgs(mw.getCurrentFrame()) @@ -66,7 +67,7 @@ function CustomSquad._playerRow(person, squadStatus, squadType) SquadUtils.storeSquadPerson(squadPerson) - local row = SquadRow(squadPerson) + local row = SquadRow(squadPerson, columnVisibility) row:id():name():role():date('joindate') diff --git a/lua/wikis/stormgate/Squad/Custom.lua b/lua/wikis/stormgate/Squad/Custom.lua index 0c44f3a2e80..7c9bba77094 100644 --- a/lua/wikis/stormgate/Squad/Custom.lua +++ b/lua/wikis/stormgate/Squad/Custom.lua @@ -50,8 +50,9 @@ end ---@param person table ---@param squadStatus SquadStatus ---@param squadType SquadType +---@param columnVisibility table? ---@return Widget -function CustomSquad._playerRow(person, squadStatus, squadType) +function CustomSquad._playerRow(person, squadStatus, squadType, columnVisibility) local squadPerson = SquadUtils.readSquadPersonArgs(Table.merge(person, {status = squadStatus, type = squadType})) if Logic.isEmpty(squadPerson.newteam) then if Logic.readBool(person.retired) then @@ -62,7 +63,7 @@ function CustomSquad._playerRow(person, squadStatus, squadType) end SquadUtils.storeSquadPerson(squadPerson) - local row = SquadRow(squadPerson) + local row = SquadRow(squadPerson, columnVisibility) row:id() row:name() row:role() From d038153f480561d117fcd25b07af66f59df671e8 Mon Sep 17 00:00:00 2001 From: Eetu Rantanen Date: Mon, 23 Feb 2026 10:08:31 +0200 Subject: [PATCH 09/11] cleanup --- lua/wikis/commons/Squad/Row.lua | 7 ++++--- lua/wikis/commons/Squad/Utils.lua | 13 +++++++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/lua/wikis/commons/Squad/Row.lua b/lua/wikis/commons/Squad/Row.lua index b3f21e3a1df..cb3818d0ffa 100644 --- a/lua/wikis/commons/Squad/Row.lua +++ b/lua/wikis/commons/Squad/Row.lua @@ -12,6 +12,7 @@ local Icon = Lua.import('Module:Icon') local Opponent = Lua.import('Module:Opponent/Custom') local OpponentDisplay = Lua.import('Module:OpponentDisplay/Custom') local String = Lua.import('Module:StringUtils') +local TeamTemplate = Lua.import('Module:TeamTemplate') local Template = Lua.import('Module:Template') local Table2Widgets = Lua.import('Module:Widget/Table2/All') @@ -67,11 +68,11 @@ function SquadRow:id() if shouldShowColumn(self.columnVisibility, 'teamIcon') then local date = self.model.leavedate or self.model.inactivedate - local hasTeam = self.model.extradata.loanedto and mw.ext.TeamTemplate.teamexists(self.model.extradata.loanedto) + local hasTeam = self.model.extradata.loanedto and TeamTemplate.exists(self.model.extradata.loanedto) local hasTeamRole = hasTeam and self.model.extradata.loanedtorole table.insert(self.children, Cell{ children = { - hasTeam and mw.ext.TeamTemplate.teamicon(self.model.extradata.loanedto, date) or nil, + hasTeam and OpponentDisplay.InlineTeamContainer{template = self.model.extradata.loanedto, date = date, style = 'icon'} or nil, hasTeamRole and HtmlWidgets.Small{ children = {HtmlWidgets.I{children = {self.model.extradata.loanedtorole}}} } or nil, @@ -181,7 +182,7 @@ function SquadRow:newteam() end local date = self.model.extradata.newteamdate or self.model.leavedate - table.insert(content, mw.ext.TeamTemplate.team(newTeam, date)) + table.insert(content, OpponentDisplay.InlineTeamContainer{template = newTeam, date = date}) if hasNewTeamRole then table.insert(content, ' (' .. newTeamRole .. ')') diff --git a/lua/wikis/commons/Squad/Utils.lua b/lua/wikis/commons/Squad/Utils.lua index a4918ccde7c..645ea47a044 100644 --- a/lua/wikis/commons/Squad/Utils.lua +++ b/lua/wikis/commons/Squad/Utils.lua @@ -16,6 +16,7 @@ local Logic = Lua.import('Module:Logic') local ReferenceCleaner = Lua.import('Module:ReferenceCleaner') local String = Lua.import('Module:StringUtils') local Table = Lua.import('Module:Table') +local TeamTemplate = Lua.import('Module:TeamTemplate') local Lpdb = Lua.import('Module:Lpdb') local Faction = Lua.import('Module:Faction') @@ -125,10 +126,10 @@ end ---@return ModelRow function SquadUtils.readSquadPersonArgs(args) local function getTeamInfo(page, property) - if not page or not mw.ext.TeamTemplate.teamexists(page) then + if not page or not TeamTemplate.exists(page) then return end - return mw.ext.TeamTemplate.raw(page)[property] + return TeamTemplate.getRawOrNil(page)[property] end local name = String.nilIfEmpty(args.name) @@ -202,7 +203,7 @@ function SquadUtils.analyzeColumnVisibility(players, squadStatus) return { teamIcon = Array.any(players, function(p) local loanedTo = p.extradata and p.extradata.loanedto or p.loanedto - return loanedTo and mw.ext.TeamTemplate.teamexists(loanedTo) + return loanedTo and TeamTemplate.exists(loanedTo) end), name = Array.any(players, function(p) return String.isNotEmpty(p.name) @@ -215,15 +216,15 @@ function SquadUtils.analyzeColumnVisibility(players, squadStatus) end), inactivedate = isInactive and Array.any(players, function(p) return String.isNotEmpty(p.inactivedate) - end) or false, + end), leavedate = isFormer and Array.any(players, function(p) return String.isNotEmpty(p.leavedate) - end) or false, + end), newteam = isFormer and Array.any(players, function(p) return String.isNotEmpty(p.newteam) or String.isNotEmpty(p.newteamrole) or String.isNotEmpty(p.newteamspecial) - end) or false, + end), } end From 2e2f549b4f0172b222385de688917aa5a8f30bb9 Mon Sep 17 00:00:00 2001 From: Eetu Rantanen Date: Mon, 23 Feb 2026 10:34:00 +0200 Subject: [PATCH 10/11] lint --- lua/wikis/commons/Squad/Row.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lua/wikis/commons/Squad/Row.lua b/lua/wikis/commons/Squad/Row.lua index cb3818d0ffa..df248b2e556 100644 --- a/lua/wikis/commons/Squad/Row.lua +++ b/lua/wikis/commons/Squad/Row.lua @@ -72,7 +72,11 @@ function SquadRow:id() local hasTeamRole = hasTeam and self.model.extradata.loanedtorole table.insert(self.children, Cell{ children = { - hasTeam and OpponentDisplay.InlineTeamContainer{template = self.model.extradata.loanedto, date = date, style = 'icon'} or nil, + hasTeam and OpponentDisplay.InlineTeamContainer{ + template = self.model.extradata.loanedto, + date = date, + style = 'icon', + } or nil, hasTeamRole and HtmlWidgets.Small{ children = {HtmlWidgets.I{children = {self.model.extradata.loanedtorole}}} } or nil, From 8571149610fba7287e3acf660c82b0d457668ccf Mon Sep 17 00:00:00 2001 From: Eetu Rantanen Date: Mon, 23 Feb 2026 14:23:01 +0200 Subject: [PATCH 11/11] anno fixes --- lua/wikis/commons/Squad/Utils.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/wikis/commons/Squad/Utils.lua b/lua/wikis/commons/Squad/Utils.lua index 645ea47a044..0848cb2ddbe 100644 --- a/lua/wikis/commons/Squad/Utils.lua +++ b/lua/wikis/commons/Squad/Utils.lua @@ -186,7 +186,7 @@ function SquadUtils.readSquadPersonArgs(args) return person end ----@param person ModelRow +---@param squadPerson ModelRow function SquadUtils.storeSquadPerson(squadPerson) squadPerson:save() end @@ -230,7 +230,7 @@ end ---@param frame table ---@param squadWidget SquadWidget ----@param rowCreator fun(player: table, squadStatus: SquadStatus, squadType: SquadType):Widget +---@param rowCreator fun(player: table, squadStatus: SquadStatus, squadType: SquadType, columnVisibility: table):Widget ---@return Widget function SquadUtils.defaultRunManual(frame, squadWidget, rowCreator) local args = Arguments.getArgs(frame)