Skip to content

Commit

Permalink
bla
Browse files Browse the repository at this point in the history
  • Loading branch information
Rathoz committed Sep 24, 2024
1 parent 8a41748 commit d8726e1
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 21 deletions.
10 changes: 5 additions & 5 deletions components/squad/commons/squad_utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion components/squad/wikis/dota2/squad_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions components/squad/wikis/overwatch/squad_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions components/squad/wikis/smash/squad_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions components/widget/contexts/widget_contexts_squad.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
8 changes: 4 additions & 4 deletions components/widget/squad/widget_squad_core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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'},
Expand Down
7 changes: 4 additions & 3 deletions components/widget/widget.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d8726e1

Please sign in to comment.