From 04ffdce42495615b9062022369f950091c129ad1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Laura=20Kl=C3=BCnder?=
Date: Wed, 26 Jul 2017 14:39:15 +0200
Subject: [PATCH] manage active node
---
src/c3nav/editor/static/editor/js/editor.js | 35 ++++++++++++++++++++
src/c3nav/editor/templates/editor/graph.html | 12 +++++++
src/c3nav/editor/views/edit.py | 14 +++++++-
3 files changed, 60 insertions(+), 1 deletion(-)
diff --git a/src/c3nav/editor/static/editor/js/editor.js b/src/c3nav/editor/static/editor/js/editor.js
index 4436d13f..6bc7be76 100644
--- a/src/c3nav/editor/static/editor/js/editor.js
+++ b/src/c3nav/editor/static/editor/js/editor.js
@@ -162,6 +162,33 @@ editor = {
modal_close.remove();
}
+ var active_graph_node = content.find('[data-active-node]');
+ if (active_graph_node.length) {
+ var active_graph_node_id = active_graph_node.attr('data-active-node');
+ if (active_graph_node_id !== '') {
+ if (active_graph_node_id === 'null') {
+ editor._active_graph_node = null;
+ editor._active_graph_node_space_transfer = null;
+ editor._active_graph_node_html = null;
+ } else {
+ editor._active_graph_node = active_graph_node_id;
+ editor._active_graph_node_space_transfer = active_graph_node.is('data-space-transfer');
+ editor._active_graph_node_html = active_graph_node.html();
+ }
+ } else if (editor._active_graph_node_html !== null) {
+ active_graph_node.html(editor._active_graph_node_html);
+ } else {
+ active_graph_node.remove();
+ }
+ } else if (!editor._active_graph_node_space_transfer && !editor._in_modal) {
+ editor._active_graph_node = null;
+ editor._active_graph_node_space_transfer = null;
+ editor._active_graph_node_html = null;
+ }
+ if (editor._active_graph_node !== null) {
+ content.find('#id_active_node').val(editor._active_graph_node);
+ }
+
var geometry_url = content.find('[data-geometry-url]');
var $body = $('body');
if (geometry_url.length) {
@@ -249,6 +276,9 @@ editor = {
_creating: false,
_next_zoom: true,
_graph_editing: null,
+ _active_graph_node: null,
+ _active_graph_node_space_transfer: null,
+ _active_graph_node_html: null,
init_geometries: function () {
// init geometries and edit listeners
editor._highlight_layer = L.layerGroup().addTo(editor.map);
@@ -369,6 +399,11 @@ editor = {
style.fillOpacity = 0.5;
}
}
+ if (feature.properties.type === 'graphnode' && feature.properties.id === editor._active_graph_node) {
+ style.stroke = true;
+ style.weight = 3;
+ style.color = '#ffff00';
+ }
if (feature.geometry.type === 'LineString') {
style = editor._line_draw_geometry_style(style);
}
diff --git a/src/c3nav/editor/templates/editor/graph.html b/src/c3nav/editor/templates/editor/graph.html
index 1f097e39..eee67c99 100644
--- a/src/c3nav/editor/templates/editor/graph.html
+++ b/src/c3nav/editor/templates/editor/graph.html
@@ -23,6 +23,18 @@
{% bootstrap_messages %}
+{% if set_active_node %}
+
+ {% trans 'Active node:' %} {{ active_node.pk }}{% if active_node.space_transfer %} ({% trans 'space transfer node' %}){% endif %}
+ {% with space_title=active_node.space.title level_title=active_node.space.level.title %}
+ {% blocktrans %}in space {{ space_title }}{% endblocktrans %}
+ {% blocktrans %}on level {{ level_title }}{% endblocktrans %}
+ {% endwith %}
+
+{% else %}
+
+{% endif %}
+