Module:User:Kai/sandbox: Difference between revisionsGive feedback
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 17: | Line 17: | ||
end | end | ||
-- Renders the individual feedback | -- Renders the individual feedback card | ||
local function renderCard(user, feedback, resolved, pageName) | local function renderCard(user, feedback, resolved, pageName) | ||
local root = mw.html.create('div') | local root = mw.html.create('div') | ||
| Line 62: | Line 62: | ||
-- ========================================================================= | -- ========================================================================= | ||
-- 1. | -- 1. SAVE TO BUCKET & DISPLAY: {{#invoke:Feedback|main|...}} | ||
-- ========================================================================= | -- ========================================================================= | ||
function p.main(frame) | function p.main(frame) | ||
| Line 77: | Line 77: | ||
local currentPage = mw.title.getCurrentTitle().fullText | local currentPage = mw.title.getCurrentTitle().fullText | ||
-- Ingest to Bucket | -- Ingest to Bucket using :put() | ||
if mw.ext and mw.ext.bucket | if mw.ext and mw.ext.bucket then | ||
mw.ext.bucket | mw.ext.bucket('feedback'):put({ | ||
page = currentPage, | page = currentPage, | ||
user = user, | user = user, | ||
| Line 85: | Line 85: | ||
feedback = feedback | feedback = feedback | ||
}) | }) | ||
end | end | ||
| Line 105: | Line 96: | ||
-- ========================================================================= | -- ========================================================================= | ||
function p.dashboard(frame) | function p.dashboard(frame) | ||
local rows = | local rows = {} | ||
if mw.ext and mw.ext.bucket then | |||
if | rows = mw.ext.bucket('feedback') | ||
:select('page', 'user', 'status', 'feedback') | |||
:run() or {} | |||
end | end | ||
local allCards = {} | local allCards = {} | ||
| Line 149: | Line 109: | ||
for _, row in ipairs(rows) do | for _, row in ipairs(rows) do | ||
local pageName = row.page or '' | |||
local pageName = row.page | local user = row.user or 'Anonymous' | ||
local user = row.user | local statusVal = tostring(row.status or 'unresolved'):lower() | ||
local | local feedbackText = row.feedback or '' | ||
local feedbackText = row.feedback | local isResolved = statusVal == 'resolved' or statusVal == 'true' or statusVal == '1' | ||
local isResolved = | |||
local card = renderCard(user, feedbackText, isResolved, pageName) | local card = renderCard(user, feedbackText, isResolved, pageName) | ||
| Line 173: | Line 132: | ||
end | end | ||
local tabberWikitext = string.format( | local tabberWikitext = string.format( | ||
'<tabber>\n' .. | '<tabber>\n' .. | ||