Skip to content

Commit

Permalink
refactor(ItemPorts): Utilize config.blocklist_itemport_name
Browse files Browse the repository at this point in the history
  • Loading branch information
octfx committed Apr 1, 2024
1 parent ead88e8 commit 1df4723
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions ItemPorts/ItemPorts.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,10 @@ end
--- @param page string the item page containing data
--- @return table
local function makeSmwQueryObject( page )
local ignores = config.blocklist_itemport_name or {}

local itemPortName = translate( 'SMW_ItemPortName' )
return {
mw.ustring.format(
'[[-Has subobject::' .. page .. ']][[%s::+]]',
itemPortName
),
local query = {
mw.ustring.format( '?%s#-=name', itemPortName ),
mw.ustring.format( '?%s#-=display_name', translate( 'SMW_ItemPortDisplayName' ) ),
mw.ustring.format( '?%s#-=min_size', translate( 'SMW_ItemPortMinimumSize' ) ),
Expand All @@ -45,6 +43,20 @@ local function makeSmwQueryObject( page )
'order=asc',
'limit=1000'
}

table.insert( query, 1, mw.ustring.format(
'[[-Has subobject::' .. page .. ']][[%s::+]]',
itemPortName
) )

for _, portName in ipairs(ignores) do
table.insert( query, 2, mw.ustring.format(
'[[%s::!' .. portName .. ']]',
itemPortName
))
end

return query
end


Expand Down Expand Up @@ -82,10 +94,6 @@ function methodtable.out( self )

local containerHtml = mw.html.create( 'div' ):addClass( 'template-itemPorts' )

-- FIXME: This does nothing since I don't know how to achieve this in Lua
-- When port.name equals to one of the value in blockedPortNames, skip the iteration.
-- local blockedPortNames = config.blocklist_itemport_name

for _, port in ipairs( smwData ) do
local size_text, title, subtitle

Expand Down

0 comments on commit 1df4723

Please sign in to comment.