模組:AFC submission/RejectReasonSheet
外观
local p = {}
local function catWikitext(boxType, prefix, arr, color)
if not arr or arr[1] == '' then
return ''
end
local div = mw.html.create('div')
:addClass('afc-submission-rejectreasonsheet-item')
:addClass('afc-submission-rejectreasonsheet-' .. boxType)
:css('padding-bottom', '0.5em')
div:tag('span')
:css('color', color)
:wikitext(prefix)
:done()
local str = ':'
for k, v in pairs(arr) do
str = str .. '\n*' .. arr[k]
end
return tostring(div:wikitext(str):done()) .. '\n'
end
local function assignArgs(args)
local result = {}
local testMap = {
{ prefix = 'fn', key = 'fixNeeded' },
{ prefix = 'prr', key = 'possibleRejectReasons' },
{ prefix = 'rr', key = 'rejectReasons'} ,
{ prefix = 'srr', key = 'seriousRejectReasons' },
}
for _, entry in ipairs(testMap) do
local collection = {}
local i = 1
while true do
local value = args[entry.prefix .. tostring(i)]
if value == nil or not mw.text.trim(value) then
break
end
collection[#collection + 1] = mw.text.trim(value)
i = i + 1
end
if #collection ~= 0 then
result.maxLevel = entry.key
result[entry.key] = collection
end
end
return result
end
function p._main(args)
local result = assignArgs(args)
if not result.maxLevel then
return '<span style="color:#f00;font-size:125%;font-weight:bold;">错误:没有拒绝理据</span>'
end
local footer = ''
local sideBarColor
local bgColor
if result.maxLevel == 'fixNeeded' then
footer = '注意:此次拒绝不代表此审核员认为该版本不可发布,仅作为修改意见,您若不愿接受该修改意见,可直接重新提交。'
sideBarColor = '#39c5bb'
bgColor = '#c4fffb'
elseif result.maxLevel == 'possibleRejectReasons' then
footer = '注意:此次拒绝不代表此审核员认为该版本不可发布,但仍可能被其他审核员拒绝,您若确实无念修正上述问题,可直接重新提交。'
sideBarColor = '#66ccff'
bgColor = '#dcfdff'
elseif result.maxLevel == 'rejectReasons' then
sideBarColor = '#ff9b4a'
bgColor = '#fff1e6'
elseif result.maxLevel == 'seriousRejectReasons' then
sideBarColor = '#ff0000'
bgColor = '#ffeded'
end
if args.suffix then
if footer ~= '' then
footer = footer .. '<br>' .. args.suffix
else
footer = args.suffix
end
end
local div = mw.html.create( 'div' )
div
:addClass('afc-submission-rejectreasonsheet')
:css('width', 'auto')
:css('border-left', '4px solid ' .. sideBarColor)
:css('background', bgColor)
:css('padding', '10px')
:wikitext(
catWikitext('seriousreject', '以下项目严重阻止条目审核通过', result.seriousRejectReasons, 'darkred') ..
catWikitext('reject', '以下项目阻止条目审核通过', result.rejectReasons, 'red') ..
catWikitext('possiblereject', '以下项目可能影响条目审核通过', result.possibleRejectReasons, 'orange') ..
catWikitext('fixneeded', '以下项目建议修正', result.fixNeeded, 'blue') ..
footer
)
return tostring(div)
end
function p.main(frame)
local args = frame:getParent().args
return p._main(args)
end
return p