Keep a deleted kind's colour, not just its name
A kind that is deleted keeps its tombstone so meals logged as it stay readable, and the chart recovered its name from there — but not its colour, falling back to grey. Grey is what "No kind" uses, so a deleted kind's food and unlabelled food drew as the same colour: two distinct series, indistinguishable in the stack and in the legend beneath it. The tombstone has the colorIndex all along, so reading the whole record rather than just the name fixes it. The check now pins the colour as well as the name, since the name alone was what let this through. Deleting a kind still leaves the meals alone — confirmed as the wanted behaviour. This only makes that behaviour legible.
This commit is contained in:
@@ -147,6 +147,7 @@ suite("what the sentence is allowed to say");
|
||||
"foodTrendMoves", "foodSeriesSentences", "foodSeriesFor"],
|
||||
stubs: {
|
||||
liveFoodKinds: () => kinds,
|
||||
loadFoodKinds: () => kinds,
|
||||
foodKindNames: () => new Map(kinds.map(k => [k.id, k.name])),
|
||||
},
|
||||
});
|
||||
@@ -203,12 +204,16 @@ suite("what the sentence is allowed to say");
|
||||
names: ["NO_KIND", "FOOD_COLORS", "foodTrend", "foodSeriesFor"],
|
||||
stubs: {
|
||||
liveFoodKinds: () => [],
|
||||
foodKindNames: () => new Map([["gone", "Old recipe"]]),
|
||||
// The tombstone: gone from the picker, still carrying name and colour.
|
||||
loadFoodKinds: () => [{ id: "gone", name: "Old recipe", colorIndex: 2, deleted: true }],
|
||||
},
|
||||
});
|
||||
const days = byKind([{ gone: 100 }, { gone: 110 }, { gone: 120 }, { gone: 130 }, { gone: 0 }]);
|
||||
eq(namesOnly.foodSeriesFor(days).map(s => s.name), ["Old recipe"],
|
||||
const series = namesOnly.foodSeriesFor(days);
|
||||
eq(series.map(s => s.name), ["Old recipe"],
|
||||
"it keeps its name rather than vanishing or reading as 'No kind'");
|
||||
eq(series[0].colorIndex, 2,
|
||||
"…and its colour, which grey would confuse with the 'No kind' series");
|
||||
}
|
||||
|
||||
suite("the caption stays bounded as kinds are added");
|
||||
|
||||
Reference in New Issue
Block a user