From d8726e19488d4f764001be164aedebf71c990d12 Mon Sep 17 00:00:00 2001 From: Rikard Blixt Date: Tue, 24 Sep 2024 11:49:15 +0200 Subject: [PATCH] bla --- components/squad/commons/squad_utils.lua | 10 +++++----- components/squad/wikis/dota2/squad_custom.lua | 2 +- components/squad/wikis/overwatch/squad_custom.lua | 4 ++-- components/squad/wikis/smash/squad_custom.lua | 4 ++-- components/widget/contexts/widget_contexts_squad.lua | 8 ++++---- components/widget/squad/widget_squad_core.lua | 8 ++++---- components/widget/widget.lua | 7 ++++--- 7 files changed, 22 insertions(+), 21 deletions(-) diff --git a/components/squad/commons/squad_utils.lua b/components/squad/commons/squad_utils.lua index 7adb761825a..75b2cb482d8 100644 --- a/components/squad/commons/squad_utils.lua +++ b/components/squad/commons/squad_utils.lua @@ -197,7 +197,7 @@ function SquadUtils.defaultRunManual(frame, squadWidget, rowCreator) end) if Info.config.squads.hasPosition then - return SquadContexts.Role{value = SquadUtils.positionHeader(), children = {squadWidget(props)}} + return SquadContexts.RoleTitle{value = SquadUtils.positionTitle(), children = {squadWidget(props)}} end return squadWidget(props) end @@ -221,7 +221,7 @@ function SquadUtils.defaultRunAuto(players, squadType, squadWidget, rowCreator, end) if Info.config.squads.hasPosition then - return SquadContexts.Role{value = SquadUtils.positionHeader(), children = {squadWidget(props)}} + return SquadContexts.RoleTitle{value = SquadUtils.positionTitle(), children = {squadWidget(props)}} end return squadWidget(props) end @@ -255,9 +255,9 @@ function SquadUtils.defaultRow(squadRowClass) end end ----@return WidgetTh -function SquadUtils.positionHeader() - return {Widget.Th{content = {'Position'}}} +---@return string +function SquadUtils.positionTitle() + return 'Position' end return SquadUtils diff --git a/components/squad/wikis/dota2/squad_custom.lua b/components/squad/wikis/dota2/squad_custom.lua index 5b09560b793..4ff883703b8 100644 --- a/components/squad/wikis/dota2/squad_custom.lua +++ b/components/squad/wikis/dota2/squad_custom.lua @@ -50,7 +50,7 @@ end ---@param frame Frame ---@return Widget function CustomSquad.run(frame) - return SquadContexts.Inactive{ + return SquadContexts.InactiveSection{ value = function(widgets) table.insert(widgets, Widget.Th{content = {'Inactive Date'}}) return widgets diff --git a/components/squad/wikis/overwatch/squad_custom.lua b/components/squad/wikis/overwatch/squad_custom.lua index 54f1de55bc4..23e23b229b5 100644 --- a/components/squad/wikis/overwatch/squad_custom.lua +++ b/components/squad/wikis/overwatch/squad_custom.lua @@ -54,12 +54,12 @@ function CustomSquad.run(frame) return CustomSquad._playerRow(player, props.type, showNumber) end) - local root = SquadContexts.Role{value = SquadUtils.positionHeader(), children = {Squad(props)}} + local root = SquadContexts.RoleTitle{value = SquadUtils.positionTitle(), children = {Squad(props)}} if not showNumber then return root end - return SquadContexts.HeaderName{ + return SquadContexts.NameSection{ value = function(widgets) table.insert(widgets, 1, Widget.Th{content = {'Number'}}) return widgets diff --git a/components/squad/wikis/smash/squad_custom.lua b/components/squad/wikis/smash/squad_custom.lua index 33790953ce1..15f7b43b8c0 100644 --- a/components/squad/wikis/smash/squad_custom.lua +++ b/components/squad/wikis/smash/squad_custom.lua @@ -86,8 +86,8 @@ function CustomSquad.run(frame) end) - return SquadContexts.Role{ - value = {Widget.Th{content = {'Main'}}}, + return SquadContexts.RoleTitle{ + value = 'Main', children = {Squad(props)} } end diff --git a/components/widget/contexts/widget_contexts_squad.lua b/components/widget/contexts/widget_contexts_squad.lua index 91527cc6482..3cc06cb4a04 100644 --- a/components/widget/contexts/widget_contexts_squad.lua +++ b/components/widget/contexts/widget_contexts_squad.lua @@ -11,8 +11,8 @@ local Lua = require('Module:Lua') local Context = Lua.import('Module:Widget/Context') return { - HeaderName = Class.new(Context), - Role = Class.new(Context), - Inactive = Class.new(Context), - Former = Class.new(Context), + NameSection = Class.new(Context), + RoleTitle = Class.new(Context), + InactiveSection = Class.new(Context), + FormerSection = Class.new(Context), } \ No newline at end of file diff --git a/components/widget/squad/widget_squad_core.lua b/components/widget/squad/widget_squad_core.lua index 80930cb9f60..e80cbba64f3 100644 --- a/components/widget/squad/widget_squad_core.lua +++ b/components/widget/squad/widget_squad_core.lua @@ -65,15 +65,15 @@ function Squad:_header(type) local isInactive = type == SquadUtils.SquadType.INACTIVE or type == SquadUtils.SquadType.FORMER_INACTIVE local isFormer = type == SquadUtils.SquadType.FORMER or type == SquadUtils.SquadType.FORMER_INACTIVE - local name = self:useContext(SquadContexts.HeaderName, {Th{children = {'Name'}}}) - local inactive = isInactive and self:useContext(SquadContexts.Inactive, { + local name = self:useContext(SquadContexts.NameSection, {Th{children = {'Name'}}}) + local inactive = isInactive and self:useContext(SquadContexts.InactiveSection, { Th{children = {'Inactive Date'}} }) or nil - local former = isFormer and self:useContext(SquadContexts.Former, { + local former = isFormer and self:useContext(SquadContexts.FormerSection, { Th{children = {'Leave Date'}}, Th{children = {'New Team'}}, }) or nil - local role = self:useContext(SquadContexts.Role, {Th{}}) + local role = {Th{children = {self:useContext(SquadContexts.RoleTitle)}}} return Tr{ classes = {'HeaderRow'}, diff --git a/components/widget/widget.lua b/components/widget/widget.lua index 975dad4eac6..ca64971343b 100644 --- a/components/widget/widget.lua +++ b/components/widget/widget.lua @@ -107,13 +107,14 @@ function Widget:tryChildren(injector) end) end -function Widget:useContext(otherContext, default) +function Widget:useContext(widget, default) -- For some reason this is not working, I don't understand why... --local Lua = require('Module:Lua') --local WidgetContext = Lua.import('Module:Widget/Context') - --assert(Class.instanceOf(otherContext, WidgetContext), 'Context must be a Context Widget') + --assert(Class.instanceOf(widget, WidgetContext), 'Context must be a Context Widget') + --Might be because widget is not instantiated? local context = Array.find(self.context, function(node) - return Class.instanceOf(node, otherContext) + return Class.instanceOf(node, widget) -- This is also not working?!? end) if context then ---@cast context WidgetContext