From 85b51e5b56a7f71e7a6a18ebeb39eef1bb4076f7 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Sun, 1 Oct 2017 18:46:09 +0200 Subject: Manage different type of editions --- static/saclay/js/interface.js | 20 ++++++++++++++++++++ templates/chimere/edit.html | 15 ++++++++++++++- urls.py | 6 ++++++ views.py | 6 ++++++ 4 files changed, 46 insertions(+), 1 deletion(-) diff --git a/static/saclay/js/interface.js b/static/saclay/js/interface.js index 3ddf749..229624a 100644 --- a/static/saclay/js/interface.js +++ b/static/saclay/js/interface.js @@ -1,6 +1,26 @@ var msg_edit_route = "Cliquez sur la carte pour tracer le trajet. Chaque nouveau clic rajoute un nœud. Double-cliquez pour terminer le trajet.
Pour modifier le trajet sélectionnez un nœud puis glissez-déposez pour le déplacer."; var msg_edit = "Cliquez sur la carte pour placer le lieu. Pour modifier ce lieu sélectionnez-le puis glissez-déposez pour le déplacer."; +var register_subactions = function(){ + $('.subactions').click(function(){ + var link = $(this).attr("data-link"); + $.ajax({url: link, + dataType: "html", + success: function (data) { + $("#map-edit").remove(); + $("#modal-edit .modal-body").html(data); + $("#modal-edit .modal-body").find("script").each(function(i) { + eval($(this).text()); + }); + }, + error: function (data) { + $('#frm-edit-marker').html("

"+ + default_error_message+"

"); + } + }); + }); +}; + var update_editmarker = function(){ /*$("#main-map").chimere('cleanRoute'); $('.map_button').hide(); diff --git a/templates/chimere/edit.html b/templates/chimere/edit.html index ded22bb..48f18ef 100644 --- a/templates/chimere/edit.html +++ b/templates/chimere/edit.html @@ -6,7 +6,17 @@ {% endif %} {% if is_modification and is_superuser %}

{% trans "You are logged as an administrator. Your modifications will be taking into account immediately." %}

{% endif %}
-{% block legend %}{% endblock %} + {% block editactions %} + {% for main_action, subactions in actions %} + {% ifequal main_action.id 'contribute' %} + + {% endifequal %} + {% endfor %} + {% endblock %}
{% csrf_token %} @@ -144,6 +154,7 @@ var success_msg = "

Merci pour votre contribution au projet !

"; success_msg += "

Votre proposition va être examinée par un modérateur et être validée dans les jours à venir.

" $(function(){ + register_subactions(); if (typeof tinyMCE !== 'undefined'){ tinyMCE.init({ mode : "textareas", @@ -157,6 +168,7 @@ toolbar3: "" }); } + {% comment %} {% if route %} var edition_type = 'route'; @@ -168,6 +180,7 @@ $('#main_map').chimere('updateMarkerInput'); {% endif %} {% endcomment %} + $('#modal-edit button.btn-primary').click(function(){ // JS tests because if a file is submited there is no way // to refill the form with (browser security issue) diff --git a/urls.py b/urls.py index 20ec9ef..117ab18 100644 --- a/urls.py +++ b/urls.py @@ -51,15 +51,21 @@ urlpatterns += [ views.DynCSS.as_view(), name="dyn-css"), url(r'^(?P[a-zA-Z0-9_-]+/)?edit-marker/' r'(?P\w+)?$', views.editMarker, name="editmarker"), + url(r'^(?P[a-zA-Z0-9_-]+/)?edit-marker-tab/' + r'(?P\w+)?$', views.editMarkerTab, name="edit-marker-tab"), url(r'^(?P[a-zA-Z0-9_-]+/)?edit-marker/(?P\w+)/' r'(?P\w+)?$', views.editMarker, name="editmarker-item"), url(r'^(?P[a-zA-Z0-9_-]+/)?edit-route/$', views.editRoute, name="editroute"), + url(r'^(?P[a-zA-Z0-9_-]+/)?edit-route-tab/$', views.editRouteTab, + name="edit-route-tab"), url(r'^(?P[a-zA-Z0-9_-]+/)?edit-route/(?P\w+)/' r'(?P\w+)?$', views.editRoute, name="editroute-item"), url(r'^(?P[a-zA-Z0-9_-]+/)?edit-polygon/$', views.editPolygon, name="editpolygon"), + url(r'^(?P[a-zA-Z0-9_-]+/)?edit-polygon-tab/$', + views.editPolygonTab, name="edit-polygon-tab"), url(r'^(?P[a-zA-Z0-9_-]+/)?edit-polygon/(?P\w+)/' r'(?P\w+)?$', views.editPolygon, name="editpolygon-item"), diff --git a/views.py b/views.py index 39ddcb4..0266696 100644 --- a/views.py +++ b/views.py @@ -65,8 +65,14 @@ class DynCSS(TemplateView): editMarker = edit_page(get_edit_marker, ['M', 'B'], 'marker', PointChooserWidget, init_widget=False) +editMarkerTab = edit_page(get_edit_marker, ['M', 'B'], 'marker', + PointChooserWidget) editRoute = edit_page(get_edit_route, ['R', 'B'], 'route', RouteChooserWidget, init_widget=False) +editRouteTab = edit_page(get_edit_route, ['R', 'B'], 'route', + RouteChooserWidget) editPolygon = edit_page(get_edit_polygon, ['P'], 'polygon', PolygonChooserWidget, init_widget=False) +editPolygonTab = edit_page(get_edit_polygon, ['P'], 'polygon', + PolygonChooserWidget) -- cgit v1.2.3