From 9f998157f06639175fdd3ac228a3662f5015d453 Mon Sep 17 00:00:00 2001 From: ddelpiano Date: Mon, 15 Apr 2024 15:24:31 +0200 Subject: [PATCH] fixing build issue --- .../ProofingTab/GraphDiagram/GraphDiagram.tsx | 14 +++++++++----- .../GraphDiagram/Models/CustomNodeModel.tsx | 4 +++- .../GraphDiagram/Widgets/DestinationNodeWidget.tsx | 6 +++--- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/frontend/src/components/ProofingTab/GraphDiagram/GraphDiagram.tsx b/frontend/src/components/ProofingTab/GraphDiagram/GraphDiagram.tsx index aee9b655..9447fe0f 100644 --- a/frontend/src/components/ProofingTab/GraphDiagram/GraphDiagram.tsx +++ b/frontend/src/components/ProofingTab/GraphDiagram/GraphDiagram.tsx @@ -25,10 +25,10 @@ export enum NodeTypes { } export interface CustomNodeOptions extends BasePositionModelOptions { + forward_connection: any[]; to?: Array<{ name: string; type: string }>; from?: Array<{ name: string; type: string }>; anatomicalType?: string; - forward_connection?: any[]; } const ViaTypeMapping: Record = { @@ -81,7 +81,7 @@ const processData = ( origins: AnatomicalEntity[] | undefined, vias: ViaSerializerDetails[] | undefined, destinations: DestinationSerializerDetails[] | undefined, - forward_connection?: any[] | undefined + forward_connection: any[], ): { nodes: CustomNodeModel[], links: DefaultLinkModel[] } => { const nodes: CustomNodeModel[] = []; const links: DefaultLinkModel[] = []; @@ -97,11 +97,13 @@ const processData = ( const id = getId(NodeTypes.Origin, origin) const name = origin.simple_entity !== null ? origin.simple_entity.name : origin.region_layer.region.name + '(' + origin.region_layer.layer.name + ')'; const ontology_uri = origin.simple_entity !== null ? origin.simple_entity.ontology_uri : origin.region_layer.region.ontology_uri + ', ' + origin.region_layer.layer.ontology_uri; + const fws: never[] = [] const originNode = new CustomNodeModel( NodeTypes.Origin, name, ontology_uri, { + forward_connection: fws, to: [], } ); @@ -120,11 +122,13 @@ const processData = ( const id = getId(NodeTypes.Via + layerIndex, entity) const name = entity.simple_entity !== null ? entity.simple_entity.name : entity.region_layer.region.name + '(' + entity.region_layer.layer.name + ')'; const ontology_uri = entity.simple_entity !== null ? entity.simple_entity.ontology_uri : entity.region_layer.region.ontology_uri + ', ' + entity.region_layer.layer.ontology_uri; + const fws: never[] = [] const viaNode = new CustomNodeModel( NodeTypes.Via, name, ontology_uri, { + forward_connection: fws, from: [], to: [], anatomicalType: via?.type ? ViaTypeMapping[via.type] : '' @@ -162,7 +166,7 @@ const processData = ( destination.anatomical_entities.forEach(entity => { const name = entity.simple_entity !== null ? entity.simple_entity.name : entity.region_layer.region.name + '(' + entity.region_layer.layer.name + ')'; const ontology_uri = entity.simple_entity !== null ? entity.simple_entity.ontology_uri : entity.region_layer.region.ontology_uri + ', ' + entity.region_layer.layer.ontology_uri; - const fws = forward_connection?.filter(single_fw => { + const fws = forward_connection.filter(single_fw => { const origins = single_fw.origins.map((origin: { id: string } | string) => typeof origin === 'object' ? origin.id : origin); if (origins.includes(entity.id)) { return true; @@ -174,9 +178,9 @@ const processData = ( name, ontology_uri, { + forward_connection: fws, from: [], anatomicalType: destination?.type ? DestinationTypeMapping[destination.type] : '', - forward_connection: fws } ); destinationNode.setPosition(xDestination, yDestination); @@ -202,7 +206,7 @@ const processData = ( return {nodes, links}; }; -const GraphDiagram: React.FC = ({origins, vias, destinations, forward_connection}) => { +const GraphDiagram: React.FC = ({origins, vias, destinations, forward_connection = []}) => { const [engine] = useState(() => createEngine()); const [modelUpdated, setModelUpdated] = useState(false) const [modelFitted, setModelFitted] = useState(false) diff --git a/frontend/src/components/ProofingTab/GraphDiagram/Models/CustomNodeModel.tsx b/frontend/src/components/ProofingTab/GraphDiagram/Models/CustomNodeModel.tsx index bbe4c511..4caa33bf 100644 --- a/frontend/src/components/ProofingTab/GraphDiagram/Models/CustomNodeModel.tsx +++ b/frontend/src/components/ProofingTab/GraphDiagram/Models/CustomNodeModel.tsx @@ -6,7 +6,9 @@ export class CustomNodeModel extends NodeModel { customType: NodeTypes; name: string; externalId: string; - constructor(customType: NodeTypes, name: string, externalId: string = '', options: CustomNodeOptions = {}) { + constructor(customType: NodeTypes, name: string, externalId: string = '', options: CustomNodeOptions = { + forward_connection: [] + }) { super({ ...options, type: 'custom', diff --git a/frontend/src/components/ProofingTab/GraphDiagram/Widgets/DestinationNodeWidget.tsx b/frontend/src/components/ProofingTab/GraphDiagram/Widgets/DestinationNodeWidget.tsx index 5270e658..bcb5d98d 100644 --- a/frontend/src/components/ProofingTab/GraphDiagram/Widgets/DestinationNodeWidget.tsx +++ b/frontend/src/components/ProofingTab/GraphDiagram/Widgets/DestinationNodeWidget.tsx @@ -16,7 +16,6 @@ interface DestinationNodeProps { export const DestinationNodeWidget: React.FC = ({ model, engine, - forwardConnection, }) => { // State to toggle the color const [isActive, setIsActive] = useState(false); @@ -30,6 +29,7 @@ export const DestinationNodeWidget: React.FC = ({ const inPort = model.getPort("in"); + const hasForwardConnections = model.getOptions()?.forward_connection?.length > 0; return ( = ({ > {model.name} - {forwardConnection && } + {model.getOptions().forward_connection?.length > 0 && } {inPort &&
@@ -191,7 +191,7 @@ export const DestinationNodeWidget: React.FC = ({ - {!forwardConnection && } + {model.getOptions()?.forward_connection?.length > 0 && }