diff --git a/lua/wikis/commons/Role/Util.lua b/lua/wikis/commons/Role/Util.lua index 7cbafd93112..6b8e58535d3 100644 --- a/lua/wikis/commons/Role/Util.lua +++ b/lua/wikis/commons/Role/Util.lua @@ -12,6 +12,8 @@ local String = Lua.import('Module:StringUtils') local Roles = Lua.import('Module:Roles') +local Html = Lua.import('Module:Widget/Html') + --- TODO: In the future this should be moved to role data entry local POSITION_ICON_DATA = Lua.requireIfExists('Module:PositionIcon/data', {loadData = true}) @@ -21,10 +23,12 @@ local RoleUtil = {} ---@field display string ---@field category string ---@field sortOrder integer? +---@field abbreviation string? ---@class RoleData: RoleBaseData ---@field key string? ---@field type RoleTypes +---@field abbreviation string? ---@field icon string? ---@enum RoleTypes @@ -86,6 +90,10 @@ function RoleUtil._createRoleData(roleKey) key = key, type = roleType(), sortOrder = roleData.sortOrder, + abbreviation = roleData.abbreviation and Html.Abbr{ + children = roleData.abbreviation, + title = roleData.display, + } or nil, icon = POSITION_ICON_DATA and POSITION_ICON_DATA[key] or nil, } end diff --git a/lua/wikis/commons/Widget/Participants/Team/Roster.lua b/lua/wikis/commons/Widget/Participants/Team/Roster.lua index 071f33ea6dd..0b8cf195a96 100644 --- a/lua/wikis/commons/Widget/Participants/Team/Roster.lua +++ b/lua/wikis/commons/Widget/Participants/Team/Roster.lua @@ -56,7 +56,7 @@ end -- * Returns an array of labels to display (can be multiple) -- * Left-role: -- * If the first role has an icon, we use that to render the left-role --- * If not then we instead display the icon or text of the first ingame role +-- * If not then we instead display the icon of the first ingame role with icon ---@param player table ---@return string?, string[]? local function getRoleDisplays(player) @@ -69,8 +69,8 @@ local function getRoleDisplays(player) return firstRole.icon end for _, role in ipairs(roles) do - if role.type == RoleUtil.ROLE_TYPE.INGAME then - return role.icon or role.display + if role.type == RoleUtil.ROLE_TYPE.INGAME and role.icon then + return role.icon end end end @@ -85,7 +85,7 @@ local function getRoleDisplays(player) -- Add non-ingame role if present for _, role in ipairs(roles) do if role.type ~= RoleUtil.ROLE_TYPE.INGAME then - table.insert(rightRoles, role.display) + table.insert(rightRoles, role.abbreviation or role.display) break end end @@ -138,6 +138,7 @@ function ParticipantsTeamRoster:render() end ---@param groups {label: string?, players: table[]}[] + ---@return Widget local makeRostersDisplay = function(groups) local children = {} for _, group in ipairs(groups) do