close modal when graph editing settings are saved

This commit is contained in:
Laura Klünder 2017-07-25 10:17:12 +02:00
parent d5041414e6
commit eda5099190
3 changed files with 17 additions and 2 deletions

View file

@ -146,6 +146,10 @@ editor = {
if (!is_modal) {
editor._last_non_modal_path = editor.get_location_path();
} else if (editor._last_non_modal_path !== null) {
if (content.find('[data-close-modal-now]').length) {
editor.sidebar_get(editor._last_non_modal_path);
return;
}
modal_close.attr('href', editor._last_non_modal_path).show();
} else {
modal_close.remove();

View file

@ -2,7 +2,7 @@
{% load i18n %}
{% include 'editor/fragment_modal_close.html' %}
<h3>{% trans 'Graph Editing Settings' %}</h3>
<h3 {% if closemodal %}data-close-modal-now{% endif %}>{% trans 'Graph Editing Settings' %}</h3>
<form action="{{ request.path }}" method="post">
{% csrf_token %}

View file

@ -380,6 +380,17 @@ def graph_edit(request, level=None, space=None):
@sidebar_view
def graph_editing_settings(request):
ctx = {
'form': GraphEditorSettingsForm(),
'closemodal': False,
}
if request.method == 'POST':
form = GraphEditorSettingsForm(data=request.POST)
if form.is_valid():
messages.success(request, _('Graph Editing Settings were successfully saved.'))
ctx['closemodal'] = True
else:
form = GraphEditorSettingsForm()
ctx.update({
'form': form,
})
return render(request, 'editor/graph_editing_settings.html', ctx)