No edit summary |
No edit summary |
||
Line 12: | Line 12: | ||
p.defaultColumns = { | p.defaultColumns = { | ||
' | 'Name', 'Description', 'Requirements (if different)', 'Icon' | ||
} | } | ||
Line 34: | Line 34: | ||
data = d.sort(data, { | data = d.sort(data, { | ||
d.on(d.path{'icon'} | d.on(d.path{'icon'}), | ||
d.on(d.path{'altDescription'} | d.on(d.path{'altDescription'}), | ||
d.on(d.path{'description'} | d.on(d.path{'description'}), | ||
d.on(d.path{'name'}, d.asc) | d.on(d.path{'name'}, d.asc) | ||
}) | }) |
Revision as of 02:38, 14 October 2024
Documentation for this module may be created at Module:Achievements/doc
local p = {} local d = require('Module:Data') local dv = require('Module:Data/View') local capiunto = require 'capiunto' p.view = {} p.view['Name'] = dv.title{'key', text='name'} p.view['Description'] = dv.text{'description'} p.view['Requirements (if different)'] = dv.text{'altDescription'} p.view['Icon'] = dv.text{'icon'} p.defaultColumns = { 'Name', 'Description', 'Requirements (if different)', 'Icon' } p.positionalArgs = function(f) local posArgs = {} for i,posArg in ipairs(f.args) do -- positional arguments don't get trimmed table.insert(posArgs, mw.text.trim(posArg)) end return posArgs end p.list = function(f) local columns = p.positionalArgs (f) if table.getn(columns) == 0 then columns = p.defaultColumns end local data = mw.loadData('Module:Achievements/Data') data = d.sort(data, { d.on(d.path{'icon'}), d.on(d.path{'altDescription'}), d.on(d.path{'description'}), d.on(d.path{'name'}, d.asc) }) return dv.displayTable(data, p.view, columns) end return p