convert _graph_editing to bool

This commit is contained in:
Laura Klünder 2017-07-26 16:18:16 +02:00
parent 072edfd84b
commit 09e77b4917
2 changed files with 14 additions and 7 deletions

View file

@ -188,7 +188,11 @@ editor = {
var graph_editing = content.find('[data-graph-editing]'); var graph_editing = content.find('[data-graph-editing]');
if (graph_editing.length) { if (graph_editing.length) {
editor._graph_editing = graph_editing.attr('data-graph-editing'); graph_editing = graph_editing.attr('data-graph-editing');
editor._graph_editing = true;
editor._graph_creating = (graph_editing === 'edit-create-nodes' ||
(graph_editing === 'edit-create-if-none-active-nodes' &&
editor._active_graph_node === null));
editor._last_graph_path = editor.get_location_path(); editor._last_graph_path = editor.get_location_path();
} else if (!editor._in_modal) { } else if (!editor._in_modal) {
editor._last_graph_path = null; editor._last_graph_path = null;
@ -280,7 +284,8 @@ editor = {
_highlight_geometries: {}, _highlight_geometries: {},
_creating: false, _creating: false,
_next_zoom: true, _next_zoom: true,
_graph_editing: null, _graph_editing: false,
_graph_creating: false,
_active_graph_node: null, _active_graph_node: null,
_active_graph_node_space_transfer: null, _active_graph_node_space_transfer: null,
_active_graph_node_html: null, _active_graph_node_html: null,
@ -463,7 +468,7 @@ editor = {
editor._bounds_layer = layer; editor._bounds_layer = layer;
} else if (feature.properties.bounds === true) { } else if (feature.properties.bounds === true) {
editor._bounds_layer = layer; editor._bounds_layer = layer;
if (editor._graph_editing === 'edit-create-nodes') { if (editor._graph_creating) {
var space_layer = L.geoJSON(layer.feature, { var space_layer = L.geoJSON(layer.feature, {
style: function() { style: function() {
return { return {
@ -476,7 +481,7 @@ editor = {
}).getLayers()[0].addTo(editor._highlight_layer); }).getLayers()[0].addTo(editor._highlight_layer);
space_layer.on('click', editor._click_graph_current_space); space_layer.on('click', editor._click_graph_current_space);
} }
} else if (feature.properties.type === 'graphnode' && editor._graph_editing !== null) { } else if (feature.properties.type === 'graphnode' && editor._graph_editing) {
var node_layer = L.geoJSON(layer.feature, { var node_layer = L.geoJSON(layer.feature, {
style: function() { style: function() {
return { return {
@ -491,8 +496,7 @@ editor = {
node_layer.on('mouseover', editor._hover_graph_item) node_layer.on('mouseover', editor._hover_graph_item)
.on('mouseout', editor._unhover_graph_item) .on('mouseout', editor._unhover_graph_item)
.on('click', editor._click_graph_node); .on('click', editor._click_graph_node);
} else if (feature.properties.type === 'space' && editor._graph_editing !== null && } else if (feature.properties.type === 'space' && !editor._graph_creating) {
(editor._sublevel_control.current_level_id === feature.properties.level || editor._graph_editing === 'edit-nodes')) {
var other_space_layer = L.geoJSON(layer.feature, { var other_space_layer = L.geoJSON(layer.feature, {
style: function() { style: function() {
return { return {
@ -657,7 +661,8 @@ editor = {
editor._creating = false; editor._creating = false;
editor.map.editTools.stopDrawing(); editor.map.editTools.stopDrawing();
} }
editor._graph_editing = null; editor._graph_editing = false;
editor._graph_creating = false;
if (editor._editing_layer !== null) { if (editor._editing_layer !== null) {
editor._editing_layer.disableEdit(); editor._editing_layer.disableEdit();
editor._editing_layer = null; editor._editing_layer = null;

View file

@ -378,6 +378,8 @@ def graph_edit(request, level=None, space=None):
}) })
if graph_editing_settings['click_anywhere'] != 'noop': if graph_editing_settings['click_anywhere'] != 'noop':
graph_editing = 'edit-create-nodes' graph_editing = 'edit-create-nodes'
if graph_editing_settings['click_anywhere'] == 'create_node_if_none_active':
graph_editing = 'edit-create-if-none-active-nodes'
allow_clicked_position = True allow_clicked_position = True
if request.method == 'POST': if request.method == 'POST':