Module:Task: Difference between revisions

From atwg
No edit summary
No edit summary
Line 3: Line 3:
function p.displayCell( s )
function p.displayCell( s )
if ( s ) then
if ( s ) then
return '| style="vertical-align:top;" | ' .. table.concat( s ) .. '\n'
return '| style="vertical-align:top;" | ' .. table.concat( s, ',' ) .. '\n'
else
else
return '|\n'
return '|\n'
Line 70: Line 70:
rowcount = rowcount + #tasks.results
rowcount = rowcount + #tasks.results
for k3,v3 in pairs( tasks.results ) do
for k3,v3 in pairs( tasks.results ) do
rows = rows .. '| style="vertical-align:top;" | [[' .. v3.fulltext .. ']]\n'
rows = rows .. '| [[' .. v3.fulltext .. ']]\n'
rows = rows .. p.displayCell( v3.printouts.Description )
rows = rows .. p.displayCell( v3.printouts.Description )
rows = rows .. p.displayCell( v3.printouts.Type )
rows = rows .. p.displayCell( v3.printouts.Type )

Revision as of 13:06, 11 February 2018

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

local p = {}

function p.displayCell( s )
	if ( s ) then
		return '| style="vertical-align:top;" | ' .. table.concat( s, ',' ) .. '\n'
	else
		return '|\n'
	end
end

function p.displayTable(frame)

	local query = '[[Category:Outcomes]]|?Description|limit=100'
    local outcomes = mw.smw.getQueryResult( query )
    if outcomes == nil or #outcomes.results == 0 then
        return ""
    end
	s = '{| class="wikitable tasktable"\n'
	s = s .. '! Outcome\n'
	s = s .. '! Output\n'
	s = s .. '! Task\n'
	s = s .. '! Description\n'
	s = s .. '! Type\n'
	s = s .. '! Primary Team\n'
	s = s .. '! Collaborating Teams\n'
	s = s .. '! Start Year\n'
	s = s .. '! Duration\n'
	s = s .. '! Depends On Tasks\n'
	s = s .. '! Risks\n'
	s = s .. '! Contingencies\n'
	s = s .. '! Benefits\n'
	s = s .. '! Assumptions\n'
	s = s .. '! Implications\n'
	s = s .. '! Notes\n'
	s = s .. '|-\n'
	
	for k1,v1 in pairs( outcomes.results ) do
		query = '[[Category:Outputs]][[Parent Outcome::' .. v1.fulltext .. ']]' ..
			'|limit=100'
		local outputs = mw.smw.getQueryResult( query )
		if outputs == nil or #outputs.results == 0 then
        	return ""
		end
	    
		local rowcount = 0
		local rows = ''
		for k2,v2 in pairs( outputs.results ) do
			query = '[[Category:Tasks]][[Associated Output::' .. v2.fulltext .. ']]' ..
				'|?Description' ..
				'|?Type' ..
				'|?Primary Team' ..
				'|?Collaborating Team' ..
				'|? Start Year' ..
				'|?Duration' ..
				'|?Depends On Task' ..
				'|?Risks' ..
				'|?Contingencies' ..
				'|?Benefits' ..
				'|?Assumptions' ..
				'|?Implications' ..
				'|?Notes' ..
				'|limit=100'
			local tasks = mw.smw.getQueryResult( query )
			if tasks ~= nil then
				rows = rows .. '| rowspan="' .. #tasks.results .. '" style="vertical-align:top;" | [[' .. v2.fulltext .. ']]\n'
				if ( #tasks.results == 0 ) then
					rowcount = rowcount + 1
					rows = rows .. '|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|-\n'
				else
					rowcount = rowcount + #tasks.results
					for k3,v3 in pairs( tasks.results ) do
						rows = rows .. '| [[' .. v3.fulltext .. ']]\n'
						rows = rows .. p.displayCell( v3.printouts.Description )
						rows = rows .. p.displayCell( v3.printouts.Type )
						rows = rows .. p.displayCell( v3.printouts['Primary Team'] )
						rows = rows .. '| ' .. table.concat( v3.printouts['Collaborating Team'] ) .. '\n'
						rows = rows .. '| ' .. table.concat( v3.printouts['Start Year'] ) .. '\n'
						rows = rows .. '| ' .. table.concat( v3.printouts.Duration ) .. '\n'
--						rows = rows .. '| ' .. table.concat( v3.printouts['Depends On Task'] ) .. '\n'
						rows = rows .. '| ' .. table.concat( v3.printouts.Risks ) .. '\n'
						rows = rows .. '| ' .. table.concat( v3.printouts.Contingencies ) .. '\n'
						rows = rows .. '| ' .. table.concat( v3.printouts.Benefits ) .. '\n'
						rows = rows .. '| ' .. table.concat( v3.printouts.Assumptions ) .. '\n'
						rows = rows .. '| ' .. table.concat( v3.printouts.Implications ) .. '\n'
						rows = rows .. '| ' .. table.concat( v3.printouts.Notes ) .. '\n'
						rows = rows .. '|-\n'
					end
				end
			end
		end
		
		s = s .. '| rowspan="' .. rowcount .. '" style="vertical-align:top;" | [[' .. v1.fulltext .. '|' .. table.concat( v1.printouts.Description ) .. ']]\n'
		s = s .. rows

    end
    
	s = s .. '|}'
    return s
end

return p