Jump to content

Module:Requests dashboard

From test1-
Revision as of 16:54, 26 October 2024 by mh>NotAracham (testing preprocess alternate)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module may be created at Module:Requests dashboard/doc

local p = {}

local function mark(link, count)
	local div = mw.html.create( 'span' )
	if tonumber(count) ~= 0 then
		div:css('background', '#fdd'):css('font-weight', 'bold')
	end
	div:wikitext(link)
	div:done()
	local sb = mw.html.create( 'sub' )
	if tonumber(count) ~= 0 then
		sb:css('font-weight', 'bold')
	end
	sb:wikitext(tonumber(count))
	sb:done()
	return tostring(div)..tostring(sb).."‌"
end

function p.dashboard(frame)
	local checkuser = frame.args[1]
	local global = frame.args[2]
	local deletions = frame.args[3]
	local restricted = frame.args[4]
	local permissions = frame.args[5]
	local reports = frame.args[6]
	local closure = frame.args[7]
	local misc = frame.args[8]
	local reopen = frame.args[9]
	local an = frame.args[10]
    local iswc = frame:preprocess('{{#ifgroup:wiki-creator|・[[mh:wikicreators:Flagged wikis|Flag Review]]}}')


    local total = checkuser + global + deletions + restricted + permissions + reports + closure + misc + reopen
    
    local congrats = ''
    if total == 0 then
    	congrats = ' 🎉 Resolved all requests!'
    end
    
    local totaltext = frame:expandTemplate{ title = 'small', args = { 'Total: '..total..congrats } }
    
    local purge = frame:expandTemplate{ title = 'purge', args = {} }
    local navbox = frame:expandTemplate{ title = 'navbox', args = {
    	title = 'Requests dashboard ['..purge..']',
    	name = 'Requests dashboard',
    	group1 = '[[Steward requests]]',
    	list1 = mark('[[Steward_requests/CheckUser|CheckUser]]', checkuser)..'・'..
    		mark('[[Steward_requests/Global|Global]]', global)..'・'..
    		mark('[[Steward_requests/(Un)deletions|(Un)deletions]]', deletions)..'・'..
    		mark('[[Steward_requests/Restricted changes|Restricted]]', restricted)..'・'..
    		mark('[[Steward_requests/Permissions|Permissions]]', permissions)..'・'..
    		mark('[[Steward_requests/Wiki reports|Reports]]', reports)..'・'..
    		mark('[[Steward_requests/Discussion closure|Discuss closure]]', closure)..'・'..
    		mark('[[Steward_requests/Requests for reopening wikis|Reopen wikis]]', reopen)..'・'..
    		mark('[[Steward_requests/Miscellaneous|Miscellaneous]]', misc)..' '..totaltext,
    	group2 = '[[Tech:Volunteers|Tech requests]] actions',
    	list2 = '[[Special:RequestImportQueue|Requested import dump]]・[[Special:RequestSSLQueue|Requested SSL certs]]・[[phab:|Phorge]]',
    	group3 = 'Other',
    	list3 = mark('[[Meta:Administrators\' noticeboard|Admins\' noticeboard]]', an)..'・[[Special:RequestWikiQueue|Requested wikis]]・[[Special:GlobalRenameQueue|Global rename]]'..iswc,
    	state = 'uncollapsed',
		bodystyle = 'background-color:#fdfdfd; width:100%; vertical-align:middle; display:inherit;',
		titlestyle = 'background-color:#ccccff; padding-left:1em; padding-right:1em; text-align:center;',
		abovestyle = 'background-color:#ddddff; padding-left:1em; padding-right:1em; text-align:center;',
		belowstyle = 'background-color:#ddddff; padding-left:1em; padding-right:1em; text-align:center;',
		groupstyle = 'background-color:#ddddff; padding-left:1em; padding-right:1em; text-align:right;',
		liststyle = 'background:transparent; text-align:left/center;',
		oddstyle = 'background:transparent;',
		evenstyle = 'background-color:#f7f7f7;'
    } }

    return navbox
end

return p