Module:CRTModel: Difference between revisions
No edit summary |
No edit summary |
||
| Line 195: | Line 195: | ||
-- Documents section | -- Documents section | ||
local | -- Check if there are any documents first | ||
local documentsCheckWikitext = | |||
'{{#ask:\n' .. | '{{#ask:\n' .. | ||
' [[Category:Documents]]\n' .. | ' [[Category:Documents]]\n' .. | ||
' [[Has related CRT model::' .. fullPageName .. ']]\n' .. | ' [[Has related CRT model::' .. fullPageName .. ']]\n' .. | ||
' |format=count\n' .. | |||
' |format= | |||
'}}' | '}}' | ||
local | local documentCount = frame:preprocess(documentsCheckWikitext) | ||
local hasDocuments = documentCount and tonumber(trim(documentCount)) and tonumber(trim(documentCount)) > 0 | |||
-- Build the upload link | -- Build the upload link | ||
| Line 217: | Line 216: | ||
) | ) | ||
-- Always show Documents section | |||
-- Always show Documents section | |||
addSectionRow(tbl, 'Documents') | addSectionRow(tbl, 'Documents') | ||
if hasDocuments then | if hasDocuments then | ||
-- | -- Build bulleted list of documents using the template | ||
local docListWikitext = | local docListWikitext = | ||
'{{#ask:\n' .. | '{{#ask:\n' .. | ||
' [[Category:Documents]]\n' .. | ' [[Category:Documents]]\n' .. | ||
' [[Has related CRT model::' .. fullPageName .. ']]\n' .. | ' [[Has related CRT model::' .. fullPageName .. ']]\n' .. | ||
' |?Has document type= | ' |?Has document type=type\n' .. | ||
' |?Has document URL= | ' |?Has document URL=url\n' .. | ||
' |format=ul\n' .. | ' |format=ul\n' .. | ||
' |template=Document link inline\n' .. | ' |template=Document link inline\n' .. | ||
| Line 238: | Line 234: | ||
local docListHtml = frame:preprocess(docListWikitext) | local docListHtml = frame:preprocess(docListWikitext) | ||
-- Add the documents list | -- Add the documents list, then the upload link on a new line with different styling | ||
local combinedHtml = docListHtml .. '\n | local combinedHtml = docListHtml .. '\n\n<div style="margin-top:0.5em; font-style:italic;">[' .. tostring(uploadUrl) .. ' Upload a document]</div>' | ||
addFullRow(tbl, combinedHtml, 'padding:0.2em 0.4em;', true) | addFullRow(tbl, combinedHtml, 'padding:0.2em 0.4em;', true) | ||
else | else | ||
-- Just show the upload link | -- Just show the upload link styled as italic | ||
local | local uploadLinkWikitext = '<div style="font-style:italic;">[' .. tostring(uploadUrl) .. ' Upload a document]</div>' | ||
addFullRow(tbl, | addFullRow(tbl, uploadLinkWikitext, 'padding:0.2em 0.4em;', true) | ||
end | end | ||