Module:Tasks
Jump to navigation
Jump to search
Documentation for Module:Tasks does not exist yet [create] (How does this work?)
local getArgs = require("Module:Arguments").getArgs
local yesno = require("Module:Yesno")
local SMWTable = require("Module:SMWTable")
local p = {}
function p.table(frame)
local args = getArgs(frame)
local groupByParent = yesno(args["group by parent"])
local groupOptions
if groupByParent then
groupOptions = {
property = "Has parent",
headerFormat = ("="):rep(args["heading level"] or 3) .. "%s" .. ("="):rep(args["heading level"] or 3)
}
end
local table = SMWTable.new({
selection = "[[Has task description::+]]" .. (args.query or ""),
attributes = {
class = "stdt__table_v2 sortable",
},
group = groupOptions
})
:column({
label = "",
printouts = {
[""] = "=#", -- "pagename"
["Has task status"] = ""
},
render = function(item)
return frame:expandTemplate({
title = "todo",
args = {
[1] = item["Has task status"],
["link"] = item[1]
}
})
end
})
:column({
label = "",
printouts = {
["Is sprout friendly"] = "",
},
render = function(item)
if yesno(item["Is sprout friendly"]) then
return "[[File:New adventurer status icon1.png|24px|Sprout/new editor friendly!|link=]]"
else
return ""
end
end
})
:column(SMWTable.textColumn({
label = "Task",
property = "Has task description",
}))
if not groupByParent then
table:column({
label = "Part of",
printouts = {
[""] = "=#", -- "pagename" (parent page and anchor) of task subobject
},
render = function(item)
local link = item[1]
local label = mw.title.new(link).text -- remove fragment with subobject ID; remove namespace/interwiki prefix
return "[[" .. link .. "|" .. label .. "]]"
end
})
end
table
:column(SMWTable.textColumn({
label = "Skills",
property = "Requires skill",
valuesep = "<br>"
}))
:column({
label = "Assignee",
printouts = {
["Has assignee"] = "#",
[""] = "=#", -- "pagename" (for links)
},
render = function(item)
local assignees = item["Has assignee"]
local out = ""
if not assignees or #assignees == 0 then
return "''None - [[Special:EditPage/" .. item[1] .."|claim]]''"
elseif type(assignees) == "string" then
assignees = {assignees}
end
for _, username in ipairs(assignees) do
username = username:gsub("^User:", "")
if out ~= "" then
out = out .. "<br>"
end
out = out
.. "[[User:" .. username .. "|" .. username .. "]] "
.. "([[User talk:" .. username .. "|talk]])"
end
return out
end
})
return table
end
return p