Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable node interaction when no metadata is available in network area diagram viewer #115

Merged
merged 2 commits into from
Nov 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,15 @@ export class NetworkAreaDiagramViewer {
this.originalWidth = 0;
this.originalHeight = 0;
this.dynamicCssRules = customDynamicCssRules ?? DEFAULT_DYNAMIC_CSS_RULES;
this.init(minWidth, minHeight, maxWidth, maxHeight, enableNodeInteraction, enableLevelOfDetail);
this.init(
minWidth,
minHeight,
maxWidth,
maxHeight,
enableNodeInteraction,
enableLevelOfDetail,
diagramMetadata !== null
);
this.svgParameters = new SvgParameters(diagramMetadata?.svgParameters);
this.layoutParameters = new LayoutParameters(diagramMetadata?.layoutParameters);
this.onMoveNodeCallback = onMoveNodeCallback;
Expand Down Expand Up @@ -191,7 +199,8 @@ export class NetworkAreaDiagramViewer {
maxWidth: number,
maxHeight: number,
enableNodeInteraction: boolean,
enableLevelOfDetail: boolean
enableLevelOfDetail: boolean,
hasMetadata: boolean
): void {
if (!this.container || !this.svgContent) {
return;
Expand Down Expand Up @@ -220,7 +229,7 @@ export class NetworkAreaDiagramViewer {
drawnSvg.style.overflow = 'visible';

// add events
if (enableNodeInteraction) {
if (enableNodeInteraction && hasMetadata) {
this.svgDraw.on('mousedown', (e: Event) => {
if ((e as MouseEvent).button == 0) {
this.onMouseLeftDown(e as MouseEvent);
Expand All @@ -235,9 +244,11 @@ export class NetworkAreaDiagramViewer {
}
});
}
this.svgDraw.on('mouseover', (e: Event) => {
this.onHover(e as MouseEvent);
});
if (hasMetadata) {
this.svgDraw.on('mouseover', (e: Event) => {
this.onHover(e as MouseEvent);
});
}
this.svgDraw.on('panStart', function () {
if (drawnSvg.parentElement != undefined) {
drawnSvg.parentElement.style.cursor = 'move';
Expand Down Expand Up @@ -282,7 +293,7 @@ export class NetworkAreaDiagramViewer {
observer.observe(targetNode, { attributeFilter: ['viewBox'] });
}

if (enableNodeInteraction) {
if (enableNodeInteraction && hasMetadata) {
// fill empty elements: unknown buses and three windings transformers
const emptyElements: NodeListOf<SVGGraphicsElement> = this.container.querySelectorAll(
'.nad-unknown-busnode, .nad-3wt-nodes .nad-winding'
Expand Down
Loading