fix(kæde): palle-varer får egen status og linjen med frie marker passer i fanen
This commit is contained in:
@@ -13,17 +13,20 @@ ADChainView.INDENT = " "
|
||||
-- Antaget ~11,5 px pr. tegn (spuInfoText: 800 px ~ 70 tegn), fed ~12,5 px; c3 har kun tal (~10 px pr. tegn).
|
||||
ADChainView.CELL_CHARS = {15, 14, 6, 21, 8}
|
||||
ADChainView.MAX_SOURCE_NAMES = 2
|
||||
-- Tegnbudget for en tekstlinje (addTextRow/spuInfoText: 800 px ~ 70 tegn), fx linjen med frie marker.
|
||||
ADChainView.TEXT_ROW_CHARS = 70
|
||||
-- "stramt": lager for en mark-afgrøde under så mange måneders behov -> gul
|
||||
ADChainView.TIGHT_MONTHS = 3
|
||||
-- nøgler rækkerne bruger (til l10n-testen)
|
||||
ADChainView.TEXT_KEYS = {"spu_chain_empty", "spu_chain_approve", "spu_chain_dismiss", "spu_chain_auto",
|
||||
"spu_chain_flowOk", "spu_chain_flowMissing", "spu_chain_flowNone", "spu_chain_flowStopped", "spu_chain_bottleneck",
|
||||
"spu_chain_flowOk", "spu_chain_flowMissing", "spu_chain_flowPallet", "spu_chain_flowNone", "spu_chain_flowStopped", "spu_chain_bottleneck",
|
||||
"spu_chain_buy", "spu_chain_cycle", "spu_chain_fieldShort", "spu_chain_tight", "spu_chain_noField", "spu_chain_buySource",
|
||||
"spu_chain_pause", "spu_chain_resume", "spu_chain_scanning", "spu_chain_rootOk", "spu_chain_rootError", "spu_chain_rootWaiting",
|
||||
"spu_chain_rootPaused", "spu_chain_rootSummary", "spu_chain_free", "spu_chain_switches", "spu_chain_gone", "spu_chain_col_item",
|
||||
"spu_chain_col_source", "spu_chain_col_perMonth", "spu_chain_col_status", "spu_chain_col_stock"}
|
||||
|
||||
local FLOW_KEYS = {ok = "spu_chain_flowOk", missing = "spu_chain_flowNone", stopped = "spu_chain_flowStopped", noVehicle = "spu_chain_flowMissing"}
|
||||
local FLOW_KEYS = {ok = "spu_chain_flowOk", missing = "spu_chain_flowNone", stopped = "spu_chain_flowStopped", noVehicle = "spu_chain_flowMissing",
|
||||
pallet = "spu_chain_flowPallet"}
|
||||
local ROOT_STATUS = {running = "spu_chain_rootOk", error = "spu_chain_rootError", waiting = "spu_chain_rootWaiting", stopped = "spu_chain_rootPaused"}
|
||||
|
||||
local function identity(value) return tostring(value) end
|
||||
@@ -259,6 +262,21 @@ local function pausedRows(rows, last, ctx)
|
||||
return #keys
|
||||
end
|
||||
|
||||
-- "Marker fri til kæden: F1, F2 +k" — så mange navne som tekstlinjen kan rumme, resten talt.
|
||||
function ADChainView.freeText(names, textOf)
|
||||
local format = textOf("spu_chain_free")
|
||||
if #names == 0 then return string.format(format, "-") end
|
||||
for count = #names, 1, -1 do
|
||||
local shown = {}
|
||||
for index = 1, count do shown[index] = names[index] end
|
||||
local list = table.concat(shown, ", ")
|
||||
if count < #names then list = list .. " +" .. tostring(#names - count) end
|
||||
local text = string.format(format, list)
|
||||
if ADChainView.textLength(text) <= ADChainView.TEXT_ROW_CHARS then return text end
|
||||
end
|
||||
return ADChainView.fit(string.format(format, "+" .. tostring(#names)), ADChainView.TEXT_ROW_CHARS)
|
||||
end
|
||||
|
||||
local function footerRows(rows, last, textOf)
|
||||
local free = {}
|
||||
for _, field in ipairs(last.fields or {}) do
|
||||
@@ -267,8 +285,7 @@ local function footerRows(rows, last, textOf)
|
||||
table.sort(free)
|
||||
local names = {}
|
||||
for _, id in ipairs(free) do table.insert(names, "F" .. tostring(id)) end
|
||||
local freeText = string.format(textOf("spu_chain_free"), #names > 0 and table.concat(names, ", ") or "-")
|
||||
table.insert(rows, {kind = "info", indent = 0, text = freeText})
|
||||
table.insert(rows, {kind = "info", indent = 0, text = ADChainView.freeText(names, textOf)})
|
||||
table.insert(rows, {kind = "info", indent = 0, text = string.format(textOf("spu_chain_switches"), last.switchCount or 0)})
|
||||
if last.fieldsIncomplete then table.insert(rows, {kind = "info", indent = 0, text = textOf("spu_chain_scanning")}) end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user