job templates: saving and deleting
[qcg-portal.git] / qcg / templates / qcg / job_templates.html
index 7bdeea1..43c7846 100644 (file)
@@ -1,5 +1,19 @@
 {% extends 'qcg/base.html' %}
 
+{% block extra_js %}
+    <script>
+        $(function() {
+            $('.delete-template').on('click', function() {
+                var $this = $(this),
+                    $modal = $('#delete-modal');
+
+                $modal.attr('action', $this.data('url'));
+                $modal.find('em').text($this.data('name'));
+            });
+        });
+    </script>
+{% endblock %}
+
 {% block container %}
     <h1 class="page-header">{% block title %}Szablony zadania{% endblock %}</h1>
 
                 {% for template in templates %}
                     <tr>
                         <td class="text-right">{{ forloop.counter }}</td>
-                        <td><a href="#">{{ template.name }}</a></td>
+                        <td><a href="{{ template.get_absolute_url }}">{{ template.name }}</a></td>
                         <td>{{ template.created }}</td>
                         <td>{{ template.updated }}</td>
                         <td class="text-right">
-                            <button class="btn btn-xs btn-danger" title="Usuń">
+                            <button class="btn btn-xs btn-danger delete-template" title="Usuń"
+                                    data-url="{% url 'template_delete' template.id %}"
+                                    data-name="{{ template.name }}"
+                                    data-toggle="modal" data-target="#delete-modal">
                                 <span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
                             </button>
                         </td>
         </div>
     {% endif %}
 
+    <form id="delete-modal" action="" method="post" class="modal fade" tabindex="-1"
+          role="dialog" aria-labelledby="delete-modal-label" aria-hidden="true">
+        <div class="modal-dialog">
+            <div class="modal-content">
+                <div class="modal-header">
+                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
+                    <h4 class="modal-title" id="delete-modal-label">Usuwanie szablonu</h4>
+                </div>
+                <div class="modal-body">
+                    {% csrf_token %}
+                    <p>Czy na pewno usunąć szablon <em></em>?</p>
+                </div>
+                <div class="modal-footer">
+                    <button type="button" class="btn btn-default" data-dismiss="modal">Anuluj</button>
+                    <button type="submit" class="btn btn-danger">Usuń</button>
+                </div>
+            </div>
+        </div>
+    </form>
+
 {% endblock %}