From cd7a728fb9d9131a26e7eb46588ea2f9b9497e96 Mon Sep 17 00:00:00 2001
From: mgfcf <m.giller@tu-braunschweig.de>
Date: Thu, 23 Sep 2021 23:30:32 +0200
Subject: [PATCH] Implemented simple save button

---
 editor/editor.php         | 1 +
 editor/js/interactions.js | 6 +++++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/editor/editor.php b/editor/editor.php
index bdf353b..96866b5 100644
--- a/editor/editor.php
+++ b/editor/editor.php
@@ -14,6 +14,7 @@
             <ul id="selected-targets"></ul>
         </section>
     </section>
+    <button id="save" type="submit" class="primary">Save and publish</button>
     <section>
         <h3>Collected items</h3>
         <ul id="selected-items"></ul>
diff --git a/editor/js/interactions.js b/editor/js/interactions.js
index c2957e3..a0583f1 100644
--- a/editor/js/interactions.js
+++ b/editor/js/interactions.js
@@ -1,5 +1,6 @@
 import jQuery from "jquery";
-import { state } from "./editor";
+import { state, graph } from "./editor";
+import { saveGraphJson } from "../../datasets/datasets";
 
 /**
  * Initiates all the handlers for button presses and input changes.
@@ -8,4 +9,7 @@ export function initInteractions() {
     jQuery("button#clear-collection").on("click", () => {
         state.clearSelectedItems();
     });
+    jQuery("button#save").on("click", () => {
+        saveGraphJson(space_id, graph.getCleanData());    // space_id defined globaly through knowledge-space.php
+    });
 }
-- 
GitLab