Show placeholders in empty circuit lists
This commit is contained in:
@@ -113,7 +113,7 @@ export function filterAndSortCircuitSections(
|
|||||||
|
|
||||||
return { ...section, circuits };
|
return { ...section, circuits };
|
||||||
})
|
})
|
||||||
.filter((section) => section.circuits.length > 0);
|
.filter((section) => activeFilters.length === 0 || section.circuits.length > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeVisibleGridRow(
|
function makeVisibleGridRow(
|
||||||
|
|||||||
@@ -78,6 +78,41 @@ const sections: CircuitTreeSectionDto[] = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
describe("circuit grid projection", () => {
|
describe("circuit grid projection", () => {
|
||||||
|
it("keeps empty sections and their free placeholders when no filter is active", () => {
|
||||||
|
const emptySections: CircuitTreeSectionDto[] = [
|
||||||
|
{
|
||||||
|
id: "empty-lighting",
|
||||||
|
key: "lighting",
|
||||||
|
displayName: "Lighting",
|
||||||
|
prefix: "-1F",
|
||||||
|
sortOrder: 10,
|
||||||
|
circuits: [],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "empty-single-phase",
|
||||||
|
key: "single_phase",
|
||||||
|
displayName: "Single-phase circuits",
|
||||||
|
prefix: "-2F",
|
||||||
|
sortOrder: 20,
|
||||||
|
circuits: [],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const projectedSections = filterAndSortCircuitSections(emptySections, {}, null);
|
||||||
|
const rows = buildVisibleGridRows(projectedSections);
|
||||||
|
|
||||||
|
assert.equal(projectedSections.length, 2);
|
||||||
|
assert.deepEqual(
|
||||||
|
rows.map((row) => row.rowKey),
|
||||||
|
[
|
||||||
|
"section:empty-lighting",
|
||||||
|
"placeholder:empty-lighting",
|
||||||
|
"section:empty-single-phase",
|
||||||
|
"placeholder:empty-single-phase",
|
||||||
|
]
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it("keeps every device row in a circuit block when one device matches a filter", () => {
|
it("keeps every device row in a circuit block when one device matches a filter", () => {
|
||||||
const result = filterAndSortCircuitSections(sections, { roomNumberSnapshot: ["1.01"] }, null);
|
const result = filterAndSortCircuitSections(sections, { roomNumberSnapshot: ["1.01"] }, null);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user