diff options
-rw-r--r-- | static/saclay/js/interface.js | 20 | ||||
-rw-r--r-- | templates/chimere/edit.html | 15 | ||||
-rw-r--r-- | urls.py | 6 | ||||
-rw-r--r-- | views.py | 6 |
4 files changed, 46 insertions, 1 deletions
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.<br/>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("<p class='warning'>"+ + default_error_message+"</p>"); + } + }); + }); +}; + 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 %}</div> {% if is_modification and is_superuser %}<div class='warning'><p>{% trans "You are logged as an administrator. Your modifications will be taking into account immediately." %}</p></div>{% endif %} <div class='edit'> -{% block legend %}{% endblock %} + {% block editactions %} + {% for main_action, subactions in actions %} + {% ifequal main_action.id 'contribute' %} + <ul class="nav nav-pills"> + {% with "edit-"|add:geom_name as current_url %}{% for subaction in subactions %} + <li{% ifequal subaction.id current_url %} class="active"{% endifequal %}><a class="subactions" data-link="{% url subaction.id|add:'-tab' area_name|add:'/' %}" href="#">{{ subaction.label }}</a></li> + {% endfor %}{% endwith %} + </ul> + {% endifequal %} + {% endfor %} + {% endblock %} <form enctype="multipart/form-data" method='post' action='{% block edit_url %}{% endblock %}{% url "editmarker" %}' id='proposition_form'> {% csrf_token %} @@ -144,6 +154,7 @@ var success_msg = "<h3>Merci pour votre contribution au projet !</h3>"; success_msg += "<p>Votre proposition va être examinée par un modérateur et être validée dans les jours à venir.</p>" $(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) @@ -51,15 +51,21 @@ urlpatterns += [ views.DynCSS.as_view(), name="dyn-css"), url(r'^(?P<area_name>[a-zA-Z0-9_-]+/)?edit-marker/' r'(?P<submited>\w+)?$', views.editMarker, name="editmarker"), + url(r'^(?P<area_name>[a-zA-Z0-9_-]+/)?edit-marker-tab/' + r'(?P<submited>\w+)?$', views.editMarkerTab, name="edit-marker-tab"), url(r'^(?P<area_name>[a-zA-Z0-9_-]+/)?edit-marker/(?P<item_id>\w+)/' r'(?P<submited>\w+)?$', views.editMarker, name="editmarker-item"), url(r'^(?P<area_name>[a-zA-Z0-9_-]+/)?edit-route/$', views.editRoute, name="editroute"), + url(r'^(?P<area_name>[a-zA-Z0-9_-]+/)?edit-route-tab/$', views.editRouteTab, + name="edit-route-tab"), url(r'^(?P<area_name>[a-zA-Z0-9_-]+/)?edit-route/(?P<item_id>\w+)/' r'(?P<submited>\w+)?$', views.editRoute, name="editroute-item"), url(r'^(?P<area_name>[a-zA-Z0-9_-]+/)?edit-polygon/$', views.editPolygon, name="editpolygon"), + url(r'^(?P<area_name>[a-zA-Z0-9_-]+/)?edit-polygon-tab/$', + views.editPolygonTab, name="edit-polygon-tab"), url(r'^(?P<area_name>[a-zA-Z0-9_-]+/)?edit-polygon/(?P<item_id>\w+)/' r'(?P<submited>\w+)?$', views.editPolygon, name="editpolygon-item"), @@ -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) |