feat(ui): ny fane Overblik — flows som tabel (flow/varer/fra/til/kører/status) grupperet Ind/Ud + Wait-puljer; Flows-fanen kun redigering (v1.19.1.0)

This commit is contained in:
2026-09-24 19:37:41 +02:00
parent 99c509ea10
commit a2444661a0
8 changed files with 83 additions and 57 deletions
+21 -34
View File
@@ -11,8 +11,9 @@ local function joinOr(list, empty)
return table.concat(list, " + ")
end
-- "Mælk · Kostald 1 + Kostald 2 → salg · pris ≥ 90 %, lager > 80 % · Virtus · kører (1/1) — SUGAR 78 % af top"
function SmartPickupFrame:describeFlow(adEnv, run, isSelected)
-- Én række i Oversigt: {flow, varer, fra, til, traktorer "kører/i alt", status}.
-- Status = advarsel (!!), ellers begrundelse, ellers flowets regel.
function SmartPickupFrame:flowCells(adEnv, run)
local row = ADRunsController.getFlowRow(adEnv, run)
local i18n = self.i18n
local products
@@ -53,51 +54,37 @@ function SmartPickupFrame:describeFlow(adEnv, run, isSelected)
else
rule = row.loops ~= nil and row.loops > 0 and string.format(i18n:getText("spu_flow_ruleInLoops"), row.loops) or i18n:getText("spu_flow_ruleIn")
end
local vehicles = joinOr(row.vehicleNames, i18n:getText("spu_flow_noVehicle"))
local status = row.running > 0 and string.format(i18n:getText("spu_status_running"), row.running, row.total) or string.format(i18n:getText("spu_status_stopped"), row.total)
local status = rule
if row.warning ~= nil then
status = status .. " — !! " .. row.warning
status = "!! " .. row.warning
elseif row.reason ~= nil then
status = status .. " — " .. row.reason
status = row.reason
end
local prefix = isSelected and "> " or " "
return string.format("%s%s: %s · %s → %s · %s · %s · %s", prefix, run.name, products, from, to, rule, vehicles, status)
local name = (run.id == self.selectedRunId and "> " or "") .. tostring(run.name)
return {name, products, from, to, string.format("%d/%d", row.running, row.total), status}
end
-- Tavlen klones bagest og flyttes derefter forrest i layoutet (foran de faste rækker).
function SmartPickupFrame:fillBoardRows(adEnv)
self.boardRows = {}
local rows = {}
local header = self:addTextRow(self.i18n:getText("spu_section_flows"))
table.insert(rows, header.parent)
-- grupperet: Ind til bygning, så Ud fra bygning — hver efter navn
-- Fanen Oversigt: alle flows som tabel, grupperet Ind/Ud efter navn.
function SmartPickupFrame:fillOverviewRows(adEnv)
self.overviewRows = {}
local i18n = self.i18n
self:addCellRow(self.flowPrefab, {i18n:getText("spu_col_flow"), i18n:getText("spu_col_goods"), i18n:getText("spu_col_from"), i18n:getText("spu_col_to"), i18n:getText("spu_col_tractors"), i18n:getText("spu_col_status")})
for _, group in ipairs(ADFlowView.boardGroups(ADRunsController.store.runs)) do
table.insert(rows, self:addTextRow(self.i18n:getText(group.kind == "outbound" and "spu_board_outbound" or "spu_board_supply")).parent)
self:addTextRow(i18n:getText(group.kind == "outbound" and "spu_board_outbound" or "spu_board_supply"))
for _, run in ipairs(group.runs) do
local title = self:addTextRow(self:describeFlow(adEnv, run, run.id == self.selectedRunId))
table.insert(rows, title.parent)
table.insert(self.boardRows, {run = run, title = title})
table.insert(self.overviewRows, {runId = run.id, cells = self:addCellRow(self.flowPrefab, self:flowCells(adEnv, run))})
end
end
if #ADRunsController.store.runs == 0 then
table.insert(rows, self:addTextRow(self.i18n:getText("spu_noRuns")).parent)
end
local elements = self.boxLayout.elements
for index = #rows, 1, -1 do
for position = #elements, 1, -1 do
if elements[position] == rows[index] then
table.remove(elements, position)
break
end
end
table.insert(elements, 1, rows[index])
self:addTextRow(i18n:getText("spu_noRuns"))
end
end
function SmartPickupFrame:refreshBoard(adEnv)
for _, entry in ipairs(self.boardRows or {}) do
if ADRuns.getRun(ADRunsController.store, entry.run.id) ~= nil then
entry.title:setText(self:describeFlow(adEnv, ADRuns.getRun(ADRunsController.store, entry.run.id), entry.run.id == self.selectedRunId))
function SmartPickupFrame:refreshOverview(adEnv)
for _, entry in ipairs(self.overviewRows or {}) do
local run = ADRuns.getRun(ADRunsController.store, entry.runId)
if run ~= nil then
SmartPickupFrame.setCells(entry.cells, self:flowCells(adEnv, run))
end
end
end