Skip to content
This repository has been archived by the owner on Jul 31, 2024. It is now read-only.

Commit

Permalink
f-dag-app Unlink feature
Browse files Browse the repository at this point in the history
  • Loading branch information
vikas-cldcvr committed Jul 2, 2024
1 parent 7f5eb3b commit b3bd65f
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 44 deletions.
41 changes: 0 additions & 41 deletions packages/flow-lineage/src/components/f-dag/f-dag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,28 +206,6 @@ export class FDag extends FRoot {
);
}

unGroup() {
const id = this.currentClickedNode!.node.id;
this.config.groups
.filter(g => g.group === id)
.forEach(g => {
g.group = undefined;
});
this.config.nodes
.filter(n => n.group === id)
.forEach(n => {
n.group = undefined;
});
const groupIndex = this.config.groups.findIndex(e => e.id === id);
if (groupIndex > -1) {
this.config.groups.splice(groupIndex, 1);
}

this.config.links = this.config.links.filter(
l => !(l.from.elementId === id || l.to.elementId === id)
);
this.requestUpdate();
}
deleteElement() {
const nodeType = this.currentClickedNode?.element.dataset.nodeType;
if (nodeType === "node") {
Expand Down Expand Up @@ -317,29 +295,10 @@ export class FDag extends FRoot {
}
}

selectNode(event: PointerEvent) {
event.stopPropagation();

if (this.currentClickedNode) {
const nodeElement = this.currentClickedNode.element;
nodeElement.classList.add("selected");
this.nodeActions.style.display = "none";

this.selectedNodes.push(this.currentClickedNode.node);
this.addGroupButton.style.display = "flex";
this.linkToButton.style.display = "flex";
}
}

handleViewPortClick() {
this.nodeActions.style.display = "none";
}

openLinkTo() {
const linkToPopOver = this.querySelector<FPopover>(`#link-to-popover`)!;
linkToPopOver.target = this.currentClickedNode!.element;
linkToPopOver.open = true;
}
openBulkLinkTo() {
const linkToPopOver = this.querySelector<FPopover>(`#link-to-popover`)!;
linkToPopOver.target = this.linkToButton;
Expand Down
68 changes: 65 additions & 3 deletions packages/flow-lineage/src/components/f-dag/node-group-actions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,58 @@
import { html } from "lit";
import type { FDag } from "./f-dag";
import type { FPopover } from "@ollion/flow-core";

export default function getNodeGroupActions(this: FDag) {
const selectNode = (event: PointerEvent) => {
event.stopPropagation();

if (this.currentClickedNode) {
const nodeElement = this.currentClickedNode.element;
nodeElement.classList.add("selected");
this.nodeActions.style.display = "none";

this.selectedNodes.push(this.currentClickedNode.node);
this.addGroupButton.style.display = "flex";
this.linkToButton.style.display = "flex";
}
};

const unGroup = () => {
const id = this.currentClickedNode!.node.id;
this.config.groups
.filter(g => g.group === id)
.forEach(g => {
g.group = undefined;
});
this.config.nodes
.filter(n => n.group === id)
.forEach(n => {
n.group = undefined;
});
const groupIndex = this.config.groups.findIndex(e => e.id === id);
if (groupIndex > -1) {
this.config.groups.splice(groupIndex, 1);
}

this.config.links = this.config.links.filter(
l => !(l.from.elementId === id || l.to.elementId === id)
);
this.requestUpdate();
};

const openLinkTo = () => {
const linkToPopOver = this.querySelector<FPopover>(`#link-to-popover`)!;
linkToPopOver.target = this.currentClickedNode!.element;
linkToPopOver.open = true;
};

const unlink = () => {
const nodeId = this.currentClickedNode!.node.id;
this.config.links = this.config.links.filter(
l => l.from.elementId !== nodeId && l.to.elementId !== nodeId
);
this.requestUpdate();
};
return html` <f-div
id="nodeActions"
style="position:absolute;z-index:12;display:none"
Expand All @@ -12,7 +63,7 @@ export default function getNodeGroupActions(this: FDag) {
state="default"
>
<f-div
@click=${this.selectNode}
@click=${selectNode}
clickable
width="hug-content"
align="middle-center"
Expand All @@ -22,15 +73,15 @@ export default function getNodeGroupActions(this: FDag) {
</f-div>
<f-divider></f-divider>
<f-div id="ungroup-action" @click=${this.unGroup}>
<f-div id="ungroup-action" @click=${unGroup}>
<f-div clickable width="hug-content" align="middle-center" padding="x-small small">
<f-text size="x-small">Ungroup</f-text>
</f-div>
<f-divider></f-divider>
</f-div>
<f-div
@click=${this.openLinkTo}
@click=${openLinkTo}
clickable
width="hug-content"
align="middle-center"
Expand All @@ -39,6 +90,17 @@ export default function getNodeGroupActions(this: FDag) {
<f-text size="x-small">Link To</f-text>
</f-div>
<f-divider></f-divider>
<f-div
@click=${unlink}
clickable
width="hug-content"
align="middle-center"
padding="x-small small"
>
<f-text size="x-small">Unlink</f-text>
</f-div>
<f-divider></f-divider>
<f-div
@click=${this.deleteElement}
Expand Down

0 comments on commit b3bd65f

Please sign in to comment.