diff --git a/lua/wikis/commons/MatchGroup/Display/Helper.lua b/lua/wikis/commons/MatchGroup/Display/Helper.lua index 3a4fe21d362..606d3e22137 100644 --- a/lua/wikis/commons/MatchGroup/Display/Helper.lua +++ b/lua/wikis/commons/MatchGroup/Display/Helper.lua @@ -278,14 +278,12 @@ function DisplayHelper.DefaultGameSummaryContainer(props) return GameSummaryModule.getGameByMatchId(props) end ----@param props table ----@return Html +---@param props {match: MatchGroupUtilMatch} +---@return Widget function DisplayHelper.DefaultMatchPageContainer(props) local MatchPageModule = Lua.import('Module:MatchPage') - assert(MatchPageModule.getByMatchId, 'Expected MatchPage.getByMatchId to be a function') - - return MatchPageModule.getByMatchId(props) + return MatchPageModule(props.match):render() end ---Retrieves the wiki specific global bracket config. diff --git a/lua/wikis/commons/MatchGroup/Display/MatchPage.lua b/lua/wikis/commons/MatchGroup/Display/MatchPage.lua index 6bd88645871..1f6ba1b2d57 100644 --- a/lua/wikis/commons/MatchGroup/Display/MatchPage.lua +++ b/lua/wikis/commons/MatchGroup/Display/MatchPage.lua @@ -16,12 +16,12 @@ local WikiSpecific = Lua.import('Module:Brkts/WikiSpecific') local MatchPageDisplay = {} ---@class MatchPageConfigOptions ----@field MatchPageContainer function? +---@field MatchPageContainer? fun(props: {match: MatchGroupUtilMatch}): Widget ---Display component for a MatchPage. The MatchPage is specified by matchID. ---The component fetches the match data from LPDB or page variables. ---@param props {matchId: string, config: MatchPageConfigOptions} ----@return Html +---@return Widget|Html function MatchPageDisplay.MatchPageContainer(props) local bracketId, _ = MatchGroupUtil.splitMatchId(props.matchId) @@ -38,7 +38,7 @@ end ---Display component for a singleMatch. Match data is specified in the input. ---@param props {config: MatchPageConfigOptions, match: MatchGroupUtilMatch} ----@return Html +---@return Widget|Html function MatchPageDisplay.SingleMatch(props) local propsConfig = props.config or {} local config = { @@ -52,8 +52,8 @@ function MatchPageDisplay.SingleMatch(props) end ---Display component for a matcch. Consists of the match page. ----@param props {MatchPageContainer: function, match: MatchGroupUtilMatch} ----@return Html +---@param props {MatchPageContainer: (fun(props: {match: MatchGroupUtilMatch}): Widget), match: MatchGroupUtilMatch} +---@return Widget|Html function MatchPageDisplay.Match(props) local bracketId = MatchGroupUtil.splitMatchId(props.match.matchId) diff --git a/lua/wikis/commons/MatchGroup/Input.lua b/lua/wikis/commons/MatchGroup/Input.lua index b7bec27cf09..63d4ba0f2f7 100644 --- a/lua/wikis/commons/MatchGroup/Input.lua +++ b/lua/wikis/commons/MatchGroup/Input.lua @@ -124,10 +124,7 @@ end ---@param matchInput table ---@return table[] function MatchGroupInput.readMatchpage(bracketId, matchId, matchInput) - local matchArgs = {} - for key, value in pairs(matchInput) do - matchArgs[key] = Json.parseIfTable(value) or value - end + local matchArgs = Json.parseStringifiedArgs(matchInput) local function setMatchPageContext() local tournamentPage = (mw.ext.LiquipediaDB.lpdb('match2', { diff --git a/lua/wikis/commons/MatchPage/Base.lua b/lua/wikis/commons/MatchPage/Base.lua index 4ef9901f7ff..e1e52b4cbda 100644 --- a/lua/wikis/commons/MatchPage/Base.lua +++ b/lua/wikis/commons/MatchPage/Base.lua @@ -61,8 +61,8 @@ local WidgetUtil = Lua.import('Module:Widget/Util') ---@field teamTemplateData teamTemplateData ---@field seriesDots string[] ----@class BaseMatchPage ----@operator call(MatchPageMatch): BaseMatchPage +---@class BaseMatchPage: BaseClass +---@operator call(MatchGroupUtilMatch): BaseMatchPage ---@field matchData MatchPageMatch ---@field games MatchPageGame[] ---@field opponents MatchPageOpponent[] @@ -89,13 +89,6 @@ local BaseMatchPage = Class.new( BaseMatchPage.NOT_PLAYED = 'notplayed' BaseMatchPage.NO_CHARACTER = 'default' ----@param props {match: MatchGroupUtilMatch} ----@return Widget -function BaseMatchPage.getByMatchId(props) - local matchPage = BaseMatchPage(props.match) - return matchPage:render() -end - function BaseMatchPage:addCategories() local matchPhase = MatchGroupUtil.computeMatchPhase(self.matchData) diff --git a/lua/wikis/dota2/MatchPage.lua b/lua/wikis/dota2/MatchPage.lua index 98b8b551713..d1ee6102fa3 100644 --- a/lua/wikis/dota2/MatchPage.lua +++ b/lua/wikis/dota2/MatchPage.lua @@ -30,6 +30,7 @@ local VetoRow = Lua.import('Module:Widget/Match/Page/VetoRow') local WidgetUtil = Lua.import('Module:Widget/Util') ---@class Dota2MatchPage: BaseMatchPage +---@operator call(MatchGroupUtilMatch): Dota2MatchPage local MatchPage = Class.new(BaseMatchPage) local GOLD_ICON = IconFa{iconName = 'gold', hover = 'Gold'} @@ -37,14 +38,6 @@ local ITEM_IMAGE_SIZE = '64px' local KDA_ICON = IconFa{iconName = 'kda', hover = 'KDA'} local SPAN_SLASH = HtmlWidgets.Span{classes = {'slash'}, children = '/'} ----@param props {match: MatchGroupUtilMatch} ----@return Widget -function MatchPage.getByMatchId(props) - local matchPage = MatchPage(props.match) - - return matchPage:render() -end - function MatchPage:populateGames() Array.forEach(self.games, function(game) game.finished = game.winner ~= nil and game.winner ~= -1 diff --git a/lua/wikis/leagueoflegends/MatchPage.lua b/lua/wikis/leagueoflegends/MatchPage.lua index 34a77453682..ca079a8eaba 100644 --- a/lua/wikis/leagueoflegends/MatchPage.lua +++ b/lua/wikis/leagueoflegends/MatchPage.lua @@ -40,7 +40,7 @@ local WidgetUtil = Lua.import('Module:Widget/Util') ---@class LoLMatchPage: BaseMatchPage ---@field games LoLMatchPageGame[] ----@operator call(MatchGroupUtilMatch): BaseMatchPage +---@operator call(MatchGroupUtilMatch): LoLMatchPage local MatchPage = Class.new(BaseMatchPage) local KEYSTONES = Table.map({ @@ -83,14 +83,6 @@ local KP_ICON = IconFa{iconName = 'leagueoflegends_killparticipation', hover = ' local GOLD_ICON = IconFa{iconName = 'gold', hover = 'Gold'} local SPAN_SLASH = HtmlWidgets.Span{classes = {'slash'}, children = '/'} ----@param props {match: MatchGroupUtilMatch} ----@return Widget -function MatchPage.getByMatchId(props) - local matchPage = MatchPage(props.match) - - return matchPage:render() -end - function MatchPage:populateGames() Array.forEach(self.games, function(game) local vetoPhase = game.extradata.vetophase or {} diff --git a/lua/wikis/valorant/MatchPage.lua b/lua/wikis/valorant/MatchPage.lua index 54f4f96e4e2..49d2819e710 100644 --- a/lua/wikis/valorant/MatchPage.lua +++ b/lua/wikis/valorant/MatchPage.lua @@ -36,7 +36,7 @@ local DisplayHelper = Lua.import('Module:MatchGroup/Display/Helper') local MatchSummaryWidgets = Lua.import('Module:Widget/Match/Summary/All') ---@class ValorantMatchPage: BaseMatchPage ----@operator call(MatchPageMatch): ValorantMatchPage +---@operator call(MatchGroupUtilMatch): ValorantMatchPage local MatchPage = Class.new(BaseMatchPage) local SPAN_SLASH = HtmlWidgets.Span{classes = {'slash'}, children = '/'} @@ -65,14 +65,6 @@ local WIN_TYPES = { } } ----@param props {match: MatchGroupUtilMatch} ----@return Widget -function MatchPage.getByMatchId(props) - local matchPage = MatchPage(props.match) - - return matchPage:render() -end - function MatchPage:populateGames() Array.forEach(self.games, function(game) game.finished = game.winner ~= nil and game.winner ~= -1