fix(kæde): 'Gård' ved slutprodukter gården selv bruger; Sælg/Behold kun ved salgbare (v1.61.7.0)

This commit is contained in:
2026-09-30 17:55:10 +02:00
parent 0c21ba49a0
commit 2290bdde95
6 changed files with 21 additions and 6 deletions
+7 -4
View File
@@ -20,7 +20,7 @@ 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_finalSell", "spu_chain_finalKeep", "spu_chain_suggestHeader", "spu_chain_empty", "spu_chain_approve", "spu_chain_dismiss", "spu_chain_auto",
ADChainView.TEXT_KEYS = {"spu_chain_finalFarm", "spu_chain_finalSell", "spu_chain_finalKeep", "spu_chain_suggestHeader", "spu_chain_empty", "spu_chain_approve", "spu_chain_dismiss", "spu_chain_auto",
"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_fromFields",
"spu_chain_pause", "spu_chain_resume", "spu_chain_scanning", "spu_chain_rootOk", "spu_chain_rootError", "spu_chain_rootWaiting",
@@ -314,11 +314,14 @@ local function rootRows(rows, root, last, ctx, isExpanded)
if #suggestions > 0 then status = string.format(ctx.textOf("spu_chain_rootSummary"), status, #suggestions) end
local marker = (#(root.children or {}) > 0) and (isExpanded and "– " or "+ ") or ""
-- slutproduktet: "Sælg straks" (standard) eller "Behold" — klik på feltet skifter
-- varer gården selv bruger (last.sellable uden roden) sælges aldrig: "Gård" uden klik
local keep = (last.finalKeep or {})[root.key] == true
local sellable = last.sellable == nil or last.sellable[root.key] == true
local finalText = not sellable and "spu_chain_finalFarm" or (keep and "spu_chain_finalKeep" or "spu_chain_finalSell")
local actions = {[5] = {kind = paused and "resume" or "pause", rootKey = root.key}}
if sellable then actions[3] = {kind = "finalMode", rootKey = root.key, keep = not keep} end
table.insert(rows, makeRow("root", 0, level, {marker .. ctx.titleOf(root.name), tostring(root.buildingName or ""),
ctx.textOf(keep and "spu_chain_finalKeep" or "spu_chain_finalSell"), status,
ctx.textOf(paused and "spu_chain_resume" or "spu_chain_pause")},
{[3] = {kind = "finalMode", rootKey = root.key, keep = not keep}, [5] = {kind = paused and "resume" or "pause", rootKey = root.key}}, root.key))
ctx.textOf(finalText), status, ctx.textOf(paused and "spu_chain_resume" or "spu_chain_pause")}, actions, root.key))
if not isExpanded then return end
local shown, problems, told = {}, {}, {}
for _, problem in ipairs((last.chain or {}).problems or {}) do