Skip to content
Snippets Groups Projects
Commit 49d2d05e authored by Maximilian Giller's avatar Maximilian Giller
Browse files

Implemented simple prototype connect tool menu

parent 74fcfba3
No related branches found
No related tags found
No related merge requests found
......@@ -2,7 +2,16 @@
<h1>Interface</h1>
<div id="2d-graph"></div>
<section id="toolbar"></section>
<section id="tool-menu" class="hidden"></section>
<section id="tool-menu">
<div id="connect-menu" class="hidden">
<label for="link-type">Link Type</label>
<select id="link-type" name="link-type">
<option value="Vorlesung">Lecture</option>
<option value="Algorithmus">Algorithm</option>
<option value="Definition">Definition</option>
</select>
</div>
</section>
<section>
<h3 id="selected-item">Nothing selected</h3>
<ul id="selected-params"></ul>
......
import Tool from "./tool";
import { graph, state } from "../editor";
import * as Graph from "../graph";
import ConnectMenu from "./menus/connectmenu";
const KEEP_SOURCE_KEY_ID = 17;
......@@ -8,6 +9,7 @@ export default class ConnectTool extends Tool {
constructor(key) {
super("Connect two nodes", "connect", key);
this.keepSource = false;
this.menu = new ConnectMenu(this);
}
onNodeClick(node) {
......@@ -21,9 +23,13 @@ export default class ConnectTool extends Tool {
}
// Add new link
var details = {};
details[Graph.LINK_TYPE] = this.menu.value("link-type");
var link = graph.addLink(
state.selectedItem[Graph.NODE_ID],
node[Graph.NODE_ID]
node[Graph.NODE_ID],
details
);
if (link === undefined) {
......
import ToolMenu from "./toolmenu";
const LINK_TYPE_SEL = "#link-type";
export default class ConnectMenu extends ToolMenu {
constructor(tool) {
super(tool);
}
beforeGet(key) {
if (key === "link-type") {
return this.getChildren(LINK_TYPE_SEL).val();
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment