Module:AVDevice: Difference between revisions

Connectivity section: group inputs/outputs by location with left stripe (mirrors TBC group pattern) (via update-page on MediaWiki MCP Server)
Connectivity: keep Inputs/Outputs as main rows, add location stripe groups inside each value cell (via update-page on MediaWiki MCP Server)
Line 160: Line 160:
local count = tonumber(trim(result)) or 0
local count = tonumber(trim(result)) or 0
return count
return count
end
-- Helper to build location-grouped I/O content for a value cell
-- Returns HTML string with stripe groups per location, or nil if empty
local function buildLocationGroupedIO(frame, fullPageName, ioType, locations, locationLabels)
local html = ''
local locationCount = 0
for _, loc in ipairs(locations) do
local count = countIOByLocation(frame, fullPageName, ioType, loc)
if count > 0 then
local locContent = queryIOByLocation(frame, fullPageName, ioType, loc)
if locContent and locContent ~= '' then
locationCount = locationCount + 1
html = html ..
'<div class="infobox-io-location-group">' ..
'<div class="infobox-io-location-header">' .. locationLabels[loc] .. '</div>' ..
locContent ..
'</div>'
end
end
end
if html == '' then return nil end
return html
end
end


Line 295: Line 320:
end
end


-- Connectivity section - query structured inputs and outputs grouped by location
-- Connectivity section - Inputs and Outputs as main rows,
-- with location stripe groups inside each value cell
local locations = {'front', 'rear', 'side'}
local locations = {'front', 'rear', 'side'}
local locationLabels = {front = 'Front', rear = 'Rear', side = 'Side'}
local locationLabels = {front = 'Front', rear = 'Rear', side = 'Side'}
-- Count total inputs and outputs
local inputsHtml = buildLocationGroupedIO(frame, fullPageName, 'input', locations, locationLabels)
local totalInputs = 0
local outputsHtml = buildLocationGroupedIO(frame, fullPageName, 'output', locations, locationLabels)
local totalOutputs = 0
for _, loc in ipairs(locations) do
totalInputs = totalInputs + countIOByLocation(frame, fullPageName, 'input', loc)
totalOutputs = totalOutputs + countIOByLocation(frame, fullPageName, 'output', loc)
end
local hasInputs = totalInputs > 0
local hasOutputs = totalOutputs > 0


if hasInputs or hasOutputs then
if inputsHtml or outputsHtml then
addSectionRow(container, 'Connectivity')
addSectionRow(container, 'Connectivity')
-- Group by location: each location with I/O gets a stripe group
if inputsHtml then
for _, loc in ipairs(locations) do
addRow(container, 'Inputs', inputsHtml, true)
local inputCount = countIOByLocation(frame, fullPageName, 'input', loc)
end
local outputCount = countIOByLocation(frame, fullPageName, 'output', loc)
if outputsHtml then
if inputCount > 0 or outputCount > 0 then
addRow(container, 'Outputs', outputsHtml, true)
-- Create a location group with left stripe (mirrors TBC group pattern)
local group = container:tag('div')
group:addClass('infobox-io-location-group')
css(group, 'grid-column: 1 / -1; display:grid; grid-template-columns:auto 1fr; gap:3px;')
-- Location header spanning full width
local locHeader = group:tag('div')
locHeader:addClass('infobox-io-location-header')
css(locHeader, 'grid-column: 1 / -1; padding:0.2em 0.4em; font-weight:bold; font-size:0.92em;')
locHeader:wikitext(locationLabels[loc])
-- Inputs for this location
if inputCount > 0 then
local locInputs = queryIOByLocation(frame, fullPageName, 'input', loc)
if locInputs and locInputs ~= '' then
local inputLabelDiv = group:tag('div')
inputLabelDiv:addClass('infobox-label')
css(inputLabelDiv, 'padding:0.2em 0.4em; font-weight:bold; text-align:left;')
inputLabelDiv:wikitext('Inputs')
local inputValueDiv = group:tag('div')
inputValueDiv:addClass('infobox-value')
css(inputValueDiv, 'padding:0.2em 0.4em;')
inputValueDiv:node(mw.html.create('span'):wikitext(locInputs))
end
end
-- Outputs for this location
if outputCount > 0 then
local locOutputs = queryIOByLocation(frame, fullPageName, 'output', loc)
if locOutputs and locOutputs ~= '' then
local outputLabelDiv = group:tag('div')
outputLabelDiv:addClass('infobox-label')
css(outputLabelDiv, 'padding:0.2em 0.4em; font-weight:bold; text-align:left;')
outputLabelDiv:wikitext('Outputs')
local outputValueDiv = group:tag('div')
outputValueDiv:addClass('infobox-value')
css(outputValueDiv, 'padding:0.2em 0.4em;')
outputValueDiv:node(mw.html.create('span'):wikitext(locOutputs))
end
end
end
end
end
end
end
MediaWiki Appliance - Powered by TurnKey Linux