Update print view and documentation for logical feeds
This commit is contained in:
parent
042a050876
commit
b74b495fab
10 changed files with 278 additions and 158 deletions
|
|
@ -7,10 +7,9 @@ import "../../../../frontend/print/print-document.css";
|
|||
import {
|
||||
deleteDocumentLogo,
|
||||
documentLogoUrl,
|
||||
getCircuitTree,
|
||||
getProjectCircuitTrees,
|
||||
getDocumentBranding,
|
||||
getProject,
|
||||
listCircuitLists,
|
||||
listDistributionBoards,
|
||||
listFloors,
|
||||
listProjectSnapshots,
|
||||
|
|
@ -31,7 +30,7 @@ import {
|
|||
import { PrintDocument } from "../../../../frontend/print/print-document";
|
||||
import {
|
||||
assertPrintRevisionConsistency,
|
||||
buildPreliminaryBoardHierarchy,
|
||||
buildBoardHierarchy,
|
||||
summarizePrintBoard,
|
||||
type PrintBoardSummary,
|
||||
} from "../../../../frontend/print/print-document-model";
|
||||
|
|
@ -89,17 +88,20 @@ export default function ProjectPrintPage() {
|
|||
}
|
||||
let cancelled = false;
|
||||
async function load() {
|
||||
const [project, boards, circuitLists, floors, snapshots, branding] =
|
||||
const [project, boards, projectTrees, floors, snapshots, branding] =
|
||||
await Promise.all([
|
||||
getProject(projectId),
|
||||
listDistributionBoards(projectId),
|
||||
listCircuitLists(projectId),
|
||||
getProjectCircuitTrees(projectId),
|
||||
listFloors(projectId),
|
||||
listProjectSnapshots(projectId),
|
||||
getDocumentBranding(),
|
||||
]);
|
||||
const floorNameById = new Map(floors.map((floor) => [floor.id, floor.name]));
|
||||
const summaries = await Promise.all(
|
||||
const treeByBoardId = new Map(
|
||||
projectTrees.trees.map((tree) => [tree.distributionBoardId, tree])
|
||||
);
|
||||
const summaries =
|
||||
[...boards]
|
||||
.sort(
|
||||
(left, right) =>
|
||||
|
|
@ -107,20 +109,17 @@ export default function ProjectPrintPage() {
|
|||
boardSortCollator.compare(left.name, right.name)
|
||||
)
|
||||
.flatMap((board) => {
|
||||
const circuitList = circuitLists.find(
|
||||
(list) => list.distributionBoardId === board.id
|
||||
);
|
||||
return circuitList ? [{ board, circuitList }] : [];
|
||||
const tree = treeByBoardId.get(board.id);
|
||||
return tree ? [{ board, tree }] : [];
|
||||
})
|
||||
.map(async ({ board, circuitList }) =>
|
||||
.map(({ board, tree }) =>
|
||||
summarizePrintBoard({
|
||||
board,
|
||||
circuitListId: circuitList.id,
|
||||
tree: await getCircuitTree(projectId, circuitList.id),
|
||||
circuitListId: tree.circuitListId,
|
||||
tree,
|
||||
floorName: board.floorId ? floorNameById.get(board.floorId) ?? null : null,
|
||||
})
|
||||
)
|
||||
);
|
||||
);
|
||||
const finalProject = await getProject(projectId);
|
||||
assertPrintRevisionConsistency(project.currentRevision, summaries, finalProject.currentRevision);
|
||||
if (cancelled) {
|
||||
|
|
@ -148,7 +147,7 @@ export default function ProjectPrintPage() {
|
|||
}, [projectId]);
|
||||
|
||||
const entries = useMemo(
|
||||
() => (data ? buildPreliminaryBoardHierarchy(data.summaries) : []),
|
||||
() => (data ? buildBoardHierarchy(data.summaries) : []),
|
||||
[data]
|
||||
);
|
||||
const stand = useMemo(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue