JourneySystem: Difference between revisions
From Dune Awakening DB
mNo edit summary |
mNo edit summary |
||
| Line 1: | Line 1: | ||
-- Module:JourneySystem | -- Module:JourneySystem | ||
-- | -- Minimal module for Journey display - focuses only on formatting, not data retrieval | ||
-- | -- All external data queries are handled by the wiki template for better caching | ||
local p = {} | local p = {} | ||
local parser = require('Module:DataTableParserV2') | |||
local | |||
-------------------------------------------------- | -------------------------------------------------- | ||
-- Function: | -- Function: renderObjectives | ||
-- | -- Called via AJAX to render objectives for a specific journey | ||
-- Data should be passed from JavaScript | |||
-------------------------------------------------- | -------------------------------------------------- | ||
function p. | function p.renderObjectives(frame) | ||
local | local journeyId = frame.args.id or frame.args[1] or "" | ||
if journeyId == "" then | |||
return '<div class="objectives-list"><div class="objective-item"><div class="objective-header"><div class="objective-title" style="color: var(--color-secondary);">No journey selected</div></div></div></div>' | |||
-- | |||
end | end | ||
-- | -- This would be called via AJAX with the journey ID | ||
-- The actual data fetching happens in JavaScript | |||
return string.format([[<div class="loading-objectives" data-journey-id="%s">Loading objectives...</div>]], journeyId) | |||
end | end | ||
-------------------------------------------------- | -------------------------------------------------- | ||
-- Function: | -- Function: renderMaterials | ||
-- | -- Called via AJAX to render materials for a specific journey | ||
-- Data should be passed from JavaScript | |||
-------------------------------------------------- | -------------------------------------------------- | ||
function p. | function p.renderMaterials(frame) | ||
local | local journeyId = frame.args.id or frame.args[1] or "" | ||
if journeyId == "" then | |||
if | return '<div class="materials-list">No journey selected</div>' | ||
return | |||
end | end | ||
-- | -- This would be called via AJAX with the journey ID | ||
-- The actual data fetching happens in JavaScript | |||
return string.format([[<div class="loading-materials" data-journey-id="%s">Loading materials...</div>]], journeyId) | |||
-- | |||
end | end | ||
-------------------------------------------------- | -------------------------------------------------- | ||
-- Function: | -- Function: formatObjectiveItem | ||
-- | -- Formats a single objective with its tasks | ||
-- Called from JavaScript with data | |||
-------------------------------------------------- | -------------------------------------------------- | ||
function p. | function p.formatObjectiveItem(frame) | ||
local | local objectiveId = frame.args.id or "" | ||
local title = frame.args.title or "" | |||
local seq = frame.args.seq or "1" | |||
local tasks = frame.args.tasks or "" | |||
local totalTasks = frame.args.totalTasks or "0" | |||
local collapsedClass = tonumber(seq) > 1 and " collapsed" or "" | |||
local | |||
local | |||
local output = string.format([[ | |||
local | |||
<div class="objective-item%s"> | <div class="objective-item%s"> | ||
<div class="objective-header" data-objective-id="%s"> | <div class="objective-header" data-objective-id="%s"> | ||
<div class="objective-icon">%s</div> | <div class="objective-icon">%s</div> | ||
<div class="objective-title">%s</div> | <div class="objective-title">%s</div> | ||
<div class="objective-progress">0/ | <div class="objective-progress">0/%s</div> | ||
</div> | </div> | ||
<div class="objective-tasks"> | <div class="objective-tasks">%s</div> | ||
</div>]], collapsedClass, objectiveId, seq, title, totalTasks, tasks) | |||
return output | return output | ||
| Line 145: | Line 68: | ||
-------------------------------------------------- | -------------------------------------------------- | ||
-- Function: | -- Function: formatTaskItem | ||
-- | -- Formats a single task item | ||
-------------------------------------------------- | -------------------------------------------------- | ||
function p. | function p.formatTaskItem(frame) | ||
local | local taskId = frame.args.id or "" | ||
local | local description = frame.args.description or "" | ||
local | local qty = frame.args.qty or "" | ||
-- | -- Apply iconization to the description | ||
local iconizedDesc = frame:preprocess('{{#invoke:DataTableParserV2|iconize|' .. description .. '}}') | |||
local qtyHtml = "" | |||
if qty ~= "" and qty ~= "0" then | |||
qtyHtml = string.format('<div class="task-qty">%s pcs</div>', qty) | |||
end | end | ||
return string.format([[ | |||
<div class=" | <div class="task-item" data-task-id="%s"> | ||
< | <div class="task-checkbox"></div> | ||
< | <div class="task-description">%s</div> | ||
</div> | %s | ||
</div>]], taskId, iconizedDesc, qtyHtml) | |||
end | |||
-------------------------------------------------- | |||
-- Function: formatMaterialItem | |||
-- Formats a single material item | |||
-------------------------------------------------- | |||
function p.formatMaterialItem(frame) | |||
local name = frame.args.name or "" | |||
local qty = frame.args.qty or "1" | |||
local index = frame.args.index or "0" | |||
-- Try to get icon | |||
local iconFile = name:gsub("%s+", "_") .. "_-_Icon.png" | |||
local iconHtml = string.format('[[File:%s|20px|link=]]', iconFile) | |||
return string.format([=[ | |||
<div class="material-item" data-material-index="%s"> | |||
<div class="material-checkbox"></div> | |||
<div class="material-icon">%s</div> | |||
<div class="material-name">[[%s]]</div> | |||
<div class="material-qty">%s</div> | |||
</div>]=], index, iconHtml, name, qty) | |||
end | end | ||
return p | return p | ||
Latest revision as of 01:41, 26 May 2025
Documentation for this module may be created at Module:JourneySystem/doc
-- Module:JourneySystem
-- Minimal module for Journey display - focuses only on formatting, not data retrieval
-- All external data queries are handled by the wiki template for better caching
local p = {}
local parser = require('Module:DataTableParserV2')
--------------------------------------------------
-- Function: renderObjectives
-- Called via AJAX to render objectives for a specific journey
-- Data should be passed from JavaScript
--------------------------------------------------
function p.renderObjectives(frame)
local journeyId = frame.args.id or frame.args[1] or ""
if journeyId == "" then
return '<div class="objectives-list"><div class="objective-item"><div class="objective-header"><div class="objective-title" style="color: var(--color-secondary);">No journey selected</div></div></div></div>'
end
-- This would be called via AJAX with the journey ID
-- The actual data fetching happens in JavaScript
return string.format([[<div class="loading-objectives" data-journey-id="%s">Loading objectives...</div>]], journeyId)
end
--------------------------------------------------
-- Function: renderMaterials
-- Called via AJAX to render materials for a specific journey
-- Data should be passed from JavaScript
--------------------------------------------------
function p.renderMaterials(frame)
local journeyId = frame.args.id or frame.args[1] or ""
if journeyId == "" then
return '<div class="materials-list">No journey selected</div>'
end
-- This would be called via AJAX with the journey ID
-- The actual data fetching happens in JavaScript
return string.format([[<div class="loading-materials" data-journey-id="%s">Loading materials...</div>]], journeyId)
end
--------------------------------------------------
-- Function: formatObjectiveItem
-- Formats a single objective with its tasks
-- Called from JavaScript with data
--------------------------------------------------
function p.formatObjectiveItem(frame)
local objectiveId = frame.args.id or ""
local title = frame.args.title or ""
local seq = frame.args.seq or "1"
local tasks = frame.args.tasks or ""
local totalTasks = frame.args.totalTasks or "0"
local collapsedClass = tonumber(seq) > 1 and " collapsed" or ""
local output = string.format([[
<div class="objective-item%s">
<div class="objective-header" data-objective-id="%s">
<div class="objective-icon">%s</div>
<div class="objective-title">%s</div>
<div class="objective-progress">0/%s</div>
</div>
<div class="objective-tasks">%s</div>
</div>]], collapsedClass, objectiveId, seq, title, totalTasks, tasks)
return output
end
--------------------------------------------------
-- Function: formatTaskItem
-- Formats a single task item
--------------------------------------------------
function p.formatTaskItem(frame)
local taskId = frame.args.id or ""
local description = frame.args.description or ""
local qty = frame.args.qty or ""
-- Apply iconization to the description
local iconizedDesc = frame:preprocess('{{#invoke:DataTableParserV2|iconize|' .. description .. '}}')
local qtyHtml = ""
if qty ~= "" and qty ~= "0" then
qtyHtml = string.format('<div class="task-qty">%s pcs</div>', qty)
end
return string.format([[
<div class="task-item" data-task-id="%s">
<div class="task-checkbox"></div>
<div class="task-description">%s</div>
%s
</div>]], taskId, iconizedDesc, qtyHtml)
end
--------------------------------------------------
-- Function: formatMaterialItem
-- Formats a single material item
--------------------------------------------------
function p.formatMaterialItem(frame)
local name = frame.args.name or ""
local qty = frame.args.qty or "1"
local index = frame.args.index or "0"
-- Try to get icon
local iconFile = name:gsub("%s+", "_") .. "_-_Icon.png"
local iconHtml = string.format('[[File:%s|20px|link=]]', iconFile)
return string.format([=[
<div class="material-item" data-material-index="%s">
<div class="material-checkbox"></div>
<div class="material-icon">%s</div>
<div class="material-name">[[%s]]</div>
<div class="material-qty">%s</div>
</div>]=], index, iconHtml, name, qty)
end
return p
