diff --git a/components/squad/commons/squad_row.lua b/components/squad/commons/squad_row.lua index 28657abe768..6566f656835 100644 --- a/components/squad/commons/squad_row.lua +++ b/components/squad/commons/squad_row.lua @@ -8,7 +8,6 @@ local Class = require('Module:Class') local Icon = require('Module:Icon') -local Info = require('Module:Info') local Lua = require('Module:Lua') local OpponentLib = require('Module:OpponentLibraries') local Opponent = OpponentLib.Opponent @@ -34,13 +33,6 @@ local SquadRow = Class.new( end ) -SquadRow.specialTeamsTemplateMapping = { - retired = 'Team/retired', - inactive = 'Team/inactive', - ['passed away'] = 'Team/passed away', - military = 'Team/military', -} - ---@return self function SquadRow:id() local content = {} @@ -159,26 +151,24 @@ end function SquadRow:newteam() local function createContent() local content = {} - local newTeam, newTeamRole = self.model.newteam, self.model.newteamrole + local newTeam, newTeamRole, newTeamSpecial = self.model.newteam, self.model.newteamrole, self.model.newteamspecial local hasNewTeam, hasNewTeamRole = String.isNotEmpty(newTeam), String.isNotEmpty(newTeamRole) + local hasNewTeamSpecial = String.isNotEmpty(newTeamSpecial) - if not hasNewTeam and not hasNewTeamRole then + if not hasNewTeam and not hasNewTeamRole and not hasNewTeamSpecial then 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 not Info.config.squads.hasSpecialTeam and not hasNewTeam then - table.insert(content, mw.html.create('div'):addClass('NewTeamRole'):wikitext(newTeamRole)) + if hasNewTeamSpecial then + table.insert(content, Template.safeExpand(mw.getCurrentFrame(), newTeamSpecial)) return content end - if not mw.ext.TeamTemplate.teamexists(newTeam) then - local newTeamTemplate = SquadRow.specialTeamsTemplateMapping[newTeam] - if Info.config.squads.hasSpecialTeam and newTeamTemplate then - table.insert(content, Template.safeExpand(mw.getCurrentFrame(), newTeamTemplate)) - end + if not hasNewTeam then + table.insert(content, mw.html.create('div'):addClass('NewTeamRole'):wikitext(newTeamRole)) return content end diff --git a/components/squad/commons/squad_utils.lua b/components/squad/commons/squad_utils.lua index d6e492ed0af..3bf520ec198 100644 --- a/components/squad/commons/squad_utils.lua +++ b/components/squad/commons/squad_utils.lua @@ -50,6 +50,13 @@ SquadUtils.SquadTypeToStorageValue = { [SquadUtils.SquadType.FORMER_INACTIVE] = 'former', } +SquadUtils.specialTeamsTemplateMapping = { + retired = 'Team/retired', + inactive = 'Team/inactive', + ['passed away'] = 'Team/passed away', + military = 'Team/military', +} + -- TODO: Decided on all valid types SquadUtils.validPersonTypes = {'player', 'staff'} SquadUtils.defaultPersonType = 'player' @@ -144,6 +151,10 @@ function SquadUtils.readSquadPersonArgs(args) }, } + if Info.config.squads.hasSpecialTeam and not person.newteam and args.newteam then + person.newteamspecial = SquadUtils.specialTeamsTemplateMapping[args.newteam] + end + if person.joindate ~= args.joindate then person.extradata.joindatedisplay = args.joindate end diff --git a/components/squad/wikis/starcraft2/squad_custom.lua b/components/squad/wikis/starcraft2/squad_custom.lua index 4fde5e793c0..b6bdc450940 100644 --- a/components/squad/wikis/starcraft2/squad_custom.lua +++ b/components/squad/wikis/starcraft2/squad_custom.lua @@ -49,7 +49,7 @@ function CustomSquad._playerRow(person, squadType) local isMain = Logic.readBool(squadArgs.main) or Logic.isEmpty(squadArgs.squad) squadPerson.extradata = Table.merge({ismain = tostring(isMain)}, squadPerson.extradata) end - squadPerson.newteam = Logic.emptyOr(squadPerson.newteam, + squadPerson.newteamspecial = Logic.emptyOr(squadPerson.newteamspecial, Logic.readBool(person.retired) and 'retired' or nil, Logic.readBool(person.military) and 'military' or nil) diff --git a/components/squad/wikis/stormgate/squad_custom.lua b/components/squad/wikis/stormgate/squad_custom.lua index 3f9739b841e..41141aa2bed 100644 --- a/components/squad/wikis/stormgate/squad_custom.lua +++ b/components/squad/wikis/stormgate/squad_custom.lua @@ -44,9 +44,9 @@ function CustomSquad._playerRow(person, squadType) local squadPerson = SquadUtils.readSquadPersonArgs(Table.merge(person, {type = squadType})) if Logic.isEmpty(squadPerson.newteam) then if Logic.readBool(person.retired) then - squadPerson.newteam = 'retired' + squadPerson.newteamspecial = 'retired' elseif Logic.readBool(person.military) then - squadPerson.newteam = 'military' + squadPerson.newteamspecial = 'military' end end SquadUtils.storeSquadPerson(squadPerson)