navigate between space graph views
This commit is contained in:
parent
3be8480a58
commit
4bcc7889f4
3 changed files with 36 additions and 7 deletions
|
@ -223,6 +223,10 @@ class GraphEditorActionForm(Form):
|
||||||
if allow_clicked_position:
|
if allow_clicked_position:
|
||||||
self.fields['clicked_position'] = CharField(widget=HiddenInput(), required=False)
|
self.fields['clicked_position'] = CharField(widget=HiddenInput(), required=False)
|
||||||
|
|
||||||
|
Space = self.request.changeset.wrap_model('Space')
|
||||||
|
space_qs = Space.objects.all()
|
||||||
|
self.fields['goto_space'] = ModelChoiceField(space_qs, widget=HiddenInput(), required=False)
|
||||||
|
|
||||||
def clean_clicked_position(self):
|
def clean_clicked_position(self):
|
||||||
return GeometryField(geomtype='point').to_python(self.cleaned_data['clicked_position'])
|
return GeometryField(geomtype='point').to_python(self.cleaned_data['clicked_position'])
|
||||||
|
|
||||||
|
|
|
@ -469,7 +469,7 @@ editor = {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}).getLayers()[0].addTo(editor._highlight_layer);
|
}).getLayers()[0].addTo(editor._highlight_layer);
|
||||||
space_layer.on('click', editor._click_graph_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 !== null) {
|
||||||
var node_layer = L.geoJSON(layer.feature, {
|
var node_layer = L.geoJSON(layer.feature, {
|
||||||
|
@ -483,9 +483,24 @@ editor = {
|
||||||
},
|
},
|
||||||
pointToLayer: editor._point_to_layer
|
pointToLayer: editor._point_to_layer
|
||||||
}).getLayers()[0].addTo(editor._highlight_layer);
|
}).getLayers()[0].addTo(editor._highlight_layer);
|
||||||
node_layer.on('mouseover', editor._hover_graph_node)
|
node_layer.on('mouseover', editor._hover_graph_item)
|
||||||
.on('mouseout', editor._unhover_graph_node)
|
.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) {
|
||||||
|
var other_space_layer = L.geoJSON(layer.feature, {
|
||||||
|
style: function() {
|
||||||
|
return {
|
||||||
|
weight: 3,
|
||||||
|
opacity: 0,
|
||||||
|
fillOpacity: 0,
|
||||||
|
className: 'c3nav-graph-goto-space'
|
||||||
|
};
|
||||||
|
},
|
||||||
|
pointToLayer: editor._point_to_layer
|
||||||
|
}).getLayers()[0].addTo(editor._highlight_layer);
|
||||||
|
other_space_layer.on('mouseover', editor._hover_graph_item)
|
||||||
|
.on('mouseout', editor._unhover_graph_item)
|
||||||
|
.on('dblclick', editor._dblclick_graph_other_space);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -560,7 +575,7 @@ editor = {
|
||||||
},
|
},
|
||||||
|
|
||||||
// graph events
|
// graph events
|
||||||
_hover_graph_node: function(e) {
|
_hover_graph_item: function(e) {
|
||||||
// hover callback for a graph node
|
// hover callback for a graph node
|
||||||
if (editor._loading_geometry) return;
|
if (editor._loading_geometry) return;
|
||||||
e.target.setStyle({
|
e.target.setStyle({
|
||||||
|
@ -570,7 +585,7 @@ editor = {
|
||||||
fillOpacity: 0
|
fillOpacity: 0
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
_unhover_graph_node: function(e) {
|
_unhover_graph_item: function(e) {
|
||||||
// unhover callback for a graph node
|
// unhover callback for a graph node
|
||||||
if (editor._loading_geometry) return;
|
if (editor._loading_geometry) return;
|
||||||
e.target.setStyle({
|
e.target.setStyle({
|
||||||
|
@ -579,8 +594,8 @@ editor = {
|
||||||
fillOpacity: 0
|
fillOpacity: 0
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
_click_graph_space: function(e) {
|
_click_graph_current_space: function(e) {
|
||||||
// click callback for a graph space
|
// click callback for a current graph space
|
||||||
if (editor._loading_geometry) return;
|
if (editor._loading_geometry) return;
|
||||||
$('#id_clicked_position').val(JSON.stringify(L.marker(e.latlng).toGeoJSON().geometry)).closest('form').submit();
|
$('#id_clicked_position').val(JSON.stringify(L.marker(e.latlng).toGeoJSON().geometry)).closest('form').submit();
|
||||||
editor.map.doubleClickZoom.disable();
|
editor.map.doubleClickZoom.disable();
|
||||||
|
@ -591,6 +606,12 @@ editor = {
|
||||||
$('#id_clicked_node').val(e.target.feature.properties.id).closest('form').submit();
|
$('#id_clicked_node').val(e.target.feature.properties.id).closest('form').submit();
|
||||||
editor.map.doubleClickZoom.disable();
|
editor.map.doubleClickZoom.disable();
|
||||||
},
|
},
|
||||||
|
_dblclick_graph_other_space: function(e) {
|
||||||
|
// click callback for an other graph space
|
||||||
|
if (editor._loading_geometry) return;
|
||||||
|
$('#id_goto_space').val(e.target.feature.properties.id).closest('form').submit();
|
||||||
|
editor.map.doubleClickZoom.disable();
|
||||||
|
},
|
||||||
|
|
||||||
// edit and create geometries
|
// edit and create geometries
|
||||||
_check_start_editing: function() {
|
_check_start_editing: function() {
|
||||||
|
|
|
@ -384,6 +384,10 @@ def graph_edit(request, level=None, space=None):
|
||||||
graph_action_form = GraphEditorActionForm(request=request, allow_clicked_position=allow_clicked_position,
|
graph_action_form = GraphEditorActionForm(request=request, allow_clicked_position=allow_clicked_position,
|
||||||
data=request.POST)
|
data=request.POST)
|
||||||
if node_settings_form.is_valid() and edge_settings_form.is_valid() and graph_action_form.is_valid():
|
if node_settings_form.is_valid() and edge_settings_form.is_valid() and graph_action_form.is_valid():
|
||||||
|
goto_space = graph_action_form.cleaned_data['goto_space']
|
||||||
|
if goto_space is not None:
|
||||||
|
return redirect(reverse('editor.spaces.graph', kwargs={'space': goto_space.pk}))
|
||||||
|
|
||||||
set_active_node = False
|
set_active_node = False
|
||||||
active_node = graph_action_form.cleaned_data['active_node']
|
active_node = graph_action_form.cleaned_data['active_node']
|
||||||
clicked_node = graph_action_form.cleaned_data['clicked_node']
|
clicked_node = graph_action_form.cleaned_data['clicked_node']
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue