diff --git a/editor/editor.php b/editor/editor.php index 6818b7b02a282d897bc3630461d7148cf2c1b7fa..acdbb04ef143bfc2c5e076f721ef6adb6f61b0ba 100644 --- a/editor/editor.php +++ b/editor/editor.php @@ -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> diff --git a/editor/js/tools/connecttool.js b/editor/js/tools/connecttool.js index 5fb9de144545ec2e6d2940a7833e832ad2884243..12538865c0332372677aea16df7418cf8446df8e 100644 --- a/editor/js/tools/connecttool.js +++ b/editor/js/tools/connecttool.js @@ -1,6 +1,7 @@ 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) { diff --git a/editor/js/tools/menus/connectmenu.js b/editor/js/tools/menus/connectmenu.js index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..d901fffac534e5593b9ea3af08d14059c099e6f5 100644 --- a/editor/js/tools/menus/connectmenu.js +++ b/editor/js/tools/menus/connectmenu.js @@ -0,0 +1,15 @@ +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