Module:Issue: Difference between revisions

From atwg
No edit summary
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 5: Line 5:
name = "High Level",
name = "High Level",
property = "High Level Property",
property = "High Level Property",
label = "High Level Properties",
values = {
values = {
"Product Strategy",
"Product Strategy",
Line 16: Line 17:
name = "Technology",
name = "Technology",
property = "Technology Property",
property = "Technology Property",
label = "Technology Properites",
values = {
values = {
"APIs",
"APIs",
Line 30: Line 32:
name = "Customers",
name = "Customers",
property = "Customer Property",
property = "Customer Property",
label = "Customer Properties",
values = {
values = {
"3rd Party Installs",
"3rd Party Installs",
Line 41: Line 44:
name = "Time",
name = "Time",
property = "Time Property",
property = "Time Property",
label = "Time",
values = {
values = {
"3-12 months",
"3-12 months",
Line 49: Line 53:
name = "Symptom or Cause",
name = "Symptom or Cause",
property = "Symptom or Cause",
property = "Symptom or Cause",
label = "Symptom or Cause",
values = {
values = {
"Is Symptom",
"Is Symptom",
Line 56: Line 61:
}
}


function p.getValues(frame)
function p.formField(frame)
local group = frame.args['group'];
local group = frame.args['group'];
local result = ''
for k,v in ipairs( p.Taxonomy ) do
for k,v in ipairs( p.Taxonomy[group].values ) do
if v.name == group then
result = result .. '*' .. v .. '\n'
local result = '{{{field|' .. v.label .. '|input type=tree|height=300px|width=300px|list|structure='
for k,v in ipairs( v.values ) do
result = result .. '*' .. v .. '\n'
end
result = result .. '}}}'
return result
end
end
end
return result
end
end

Latest revision as of 12:29, 17 January 2018

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

local p = {}

p.Taxonomy = {
	{
		name = "High Level",
		property = "High Level Property",
		label = "High Level Properties",
		values = {
			"Product Strategy",
			"Platform Strategy",
			"Culture",
			"Process",
			"Department Alignment"
		}
	},
	{
		name = "Technology",
		property = "Technology Property",
		label = "Technology Properites",
		values = {
			"APIs",
			"SOA",
			"MediaWiki",
			"Caching / Storage",
			"Performance / Scaling",
			"Build / Dev / Deploy",
			"Analytics / A/B testing",
			"(Isomorphic) JS"
		}
	},
	{
		name = "Customers",
		property = "Customer Property",
		label = "Customer Properties",
		values = {
			"3rd Party Installs",
			"3rd Party Clients",
			"Operational Burden",
			"Maintenance Burden",
			"Development Burden"
		}
	},
	{
		name = "Time",
		property = "Time Property",
		label = "Time",
		values = {
			"3-12 months",
			"2-5 years"
		}
	},
	{
		name = "Symptom or Cause",
		property = "Symptom or Cause",
		label = "Symptom or Cause",
		values = {
			"Is Symptom",
			"Is Cause"
		}
	}
}

function p.formField(frame)
	local group = frame.args['group'];
	for k,v in ipairs( p.Taxonomy ) do
		if v.name == group then
			local result = '{{{field|' .. v.label .. '|input type=tree|height=300px|width=300px|list|structure='
			for k,v in ipairs( v.values ) do
				result = result .. '*' .. v .. '\n'
			end
			result = result .. '}}}'
			return result
		end
	end
end
	
function p.displayMatrix(frame)

	local query = '[[Category:Issues]]'
	if frame.args['tag'] ~= nil then
		query = query .. '[[Tag::' .. frame.args['tag'] .. ']]'
	end
	query = query .. "|?Description"
	for k,v in ipairs( p.Taxonomy ) do
		query = query .. '|?' .. v.property
	end
	query = query .. "|limit=1000";
    local issues = mw.smw.getQueryResult( query )

    if issues == nil or #issues.results == 0 then
        return "no issues found"
    end

	result = #issues.results .. ' issues.\n\n'
	result = result .. '{| class="wikitable issue_table sortable"\n'
	result = result .. '! rowspan="2" | Issue\n'

	for k,v in ipairs( p.Taxonomy ) do
		result = result .. '! colspan=' .. #v.values .. ' | ' .. v.name .. '\n'
	end

	result = result .. '|-\n'
	for k1,v1 in ipairs( p.Taxonomy ) do
		for k2,v2 in ipairs( v1.values ) do
			result = result .. '! ' ..
				frame:expandTemplate{ title = 'Tag Link', args = { v2 } } .. '\n'
		end
	end

	result = result .. '|-\n!<br/>'
	for k1,v1 in ipairs( p.Taxonomy ) do
		for k2,v2 in ipairs( v1.values ) do
			result = result .. '!!'
		end
	end
	result = result .. '\n'

	for k1,v1 in pairs( issues.results ) do
		result = result .. '|-\n'
		result = result .. '| [[' .. v1.fulltext .. '|' .. v1.printouts['Description'][1] .. ']]\n'
		for k2,v2 in ipairs( p.Taxonomy ) do
			local query_values = v1.printouts[v2.property]
			for k3,v3 in ipairs( v2.values ) do
				result = result .. '| style="text-align:center;min-width:60px;" |'
				for k4,v4 in pairs(query_values) do
					if v3 == v4 then
						result = result .. 'X'
					end
				end
				result = result .. '\n'
			end
		end
	end

	result = result .. '|}'
    return result
end

return p