Module:CRTModel: Difference between revisions

Unify connectivity rendering with AV Device: replace separate Inputs/Outputs/Control Ports sections with single Connectivity section using location-grouped display (Front/Rear/Side stripe groups). Uses new CRT input row, CRT output row, and CRT control port row templates. (via update-page on MediaWiki MCP Server)
Refactor Connectivity section: split into separate Inputs/Outputs/Control Ports sections with location (Front/Rear/Side) as row labels instead of sub-groups (via update-page on MediaWiki MCP Server)
Line 179: Line 179:
end
end


-- Helper to build location-grouped I/O content
-- Helper to build location-grouped I/O content (used by Module:AVDevice pattern)
-- Returns HTML string with stripe groups per location, or nil if empty
-- Returns HTML string with stripe groups per location, or nil if empty
local function buildLocationGroupedIO(frame, fullPageName, ioType, locations, locationLabels)
local function buildLocationGroupedIO(frame, fullPageName, ioType, locations, locationLabels)
Line 664: Line 664:
end
end


-- Connectivity section: Inputs, Outputs, and Control Ports grouped by location
-- Inputs, Outputs, and Control Ports as separate sections
-- Uses the same visual pattern as Module:AVDevice for consistency
-- Each section uses location (Front/Rear/Side) as the row label
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'}


local inputsHtml = buildLocationGroupedIO(frame, fullPageName, 'input', locations, locationLabels)
-- Helper closure to render an I/O section with location-based rows
local outputsHtml = buildLocationGroupedIO(frame, fullPageName, 'output', locations, locationLabels)
local function renderIOSection(sectionTitle, ioType)
local controlPortsHtml = buildLocationGroupedIO(frame, fullPageName, 'control', locations, locationLabels)
local locationData = {}


if inputsHtml or outputsHtml or controlPortsHtml then
for _, loc in ipairs(locations) do
addSectionRow(container, 'Connectivity')
local count = countIOByLocation(frame, fullPageName, ioType, loc)
 
if count > 0 then
if inputsHtml then
local content = queryIOByLocation(frame, fullPageName, ioType, loc)
local labelDiv = container:tag('div')
if content and content ~= '' then
labelDiv:addClass('infobox-label')
table.insert(locationData, {location = loc, content = content})
css(labelDiv, 'padding:0.2em 0.4em; font-weight:bold; text-align:left;')
end
labelDiv:wikitext('Inputs')
end
 
local valueDiv = container:tag('div')
valueDiv:addClass('infobox-value')
css(valueDiv, 'padding:0;')
valueDiv:node(mw.html.create('span'):wikitext(inputsHtml))
end
end


if outputsHtml then
if #locationData > 0 then
local labelDiv = container:tag('div')
addSectionRow(container, sectionTitle)
labelDiv:addClass('infobox-label')
for _, data in ipairs(locationData) do
css(labelDiv, 'padding:0.2em 0.4em; font-weight:bold; text-align:left;')
local labelDiv = container:tag('div')
labelDiv:wikitext('Outputs')
labelDiv:addClass('infobox-label')
labelDiv:addClass('infobox-label-top')
css(labelDiv, 'padding:0.2em 0.4em; font-weight:bold; text-align:left;')
labelDiv:wikitext(locationLabels[data.location])


local valueDiv = container:tag('div')
local valueDiv = container:tag('div')
valueDiv:addClass('infobox-value')
valueDiv:addClass('infobox-value')
css(valueDiv, 'padding:0;')
css(valueDiv, 'padding:0.2em 0.4em;')
valueDiv:node(mw.html.create('span'):wikitext(outputsHtml))
valueDiv:node(mw.html.create('span'):wikitext(data.content))
end
end
end
end


if controlPortsHtml then
renderIOSection('Inputs', 'input')
local labelDiv = container:tag('div')
renderIOSection('Outputs', 'output')
labelDiv:addClass('infobox-label')
renderIOSection('Control Ports', 'control')
css(labelDiv, 'padding:0.2em 0.4em; font-weight:bold; text-align:left;')
labelDiv:wikitext('Control')
 
local valueDiv = container:tag('div')
valueDiv:addClass('infobox-value')
css(valueDiv, 'padding:0;')
valueDiv:node(mw.html.create('span'):wikitext(controlPortsHtml))
end
end


-- Accessories section: Query for non-remote accessories linked via Has related CRT model
-- Accessories section: Query for non-remote accessories linked via Has related CRT model
MediaWiki Appliance - Powered by TurnKey Linux