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 | ||
-- | -- Inputs, Outputs, and Control Ports as separate sections | ||
-- | -- 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'} | ||
-- Helper closure to render an I/O section with location-based rows | |||
local | local function renderIOSection(sectionTitle, ioType) | ||
local locationData = {} | |||
for _, loc in ipairs(locations) do | |||
local count = countIOByLocation(frame, fullPageName, ioType, loc) | |||
if count > 0 then | |||
local content = queryIOByLocation(frame, fullPageName, ioType, loc) | |||
local | if content and content ~= '' then | ||
table.insert(locationData, {location = loc, content = content}) | |||
end | |||
end | |||
end | end | ||
if | if #locationData > 0 then | ||
local labelDiv = container:tag('div') | addSectionRow(container, sectionTitle) | ||
for _, data in ipairs(locationData) do | |||
local labelDiv = container:tag('div') | |||
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') | |||
valueDiv:addClass('infobox-value') | |||
css(valueDiv, 'padding:0.2em 0.4em;') | |||
valueDiv:node(mw.html.create('span'):wikitext(data.content)) | |||
end | |||
end | end | ||
end | |||
renderIOSection('Inputs', 'input') | |||
renderIOSection('Outputs', 'output') | |||
renderIOSection('Control Ports', 'control') | |||
-- 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 | ||