|
1 | 1 | {% load crispy_forms_tags %} |
2 | 2 |
|
| 3 | +{% if formset.non_form_errors %} |
| 4 | +<div class="alert alert-danger"> |
| 5 | + {{ formset.non_form_errors }} |
| 6 | +</div> |
| 7 | +{% else %} |
| 8 | + |
3 | 9 | {% if formset %} |
4 | | - <div class="card border-light"> |
5 | | - <div class="card-body"> |
6 | | - <form action="{% url 'add-publication' project_pk %}" method="post"> |
7 | | - {% csrf_token %} |
8 | | - <div class="table-responsive"> |
9 | | - <table class="table table-sm table-hover"> |
10 | | - <thead> |
11 | | - <tr> |
12 | | - <th> |
13 | | - <input type="checkbox" class="form-check-input" id="selectAll"> |
14 | | - </th> |
15 | | - <th scope="col">#</th> |
16 | | - <th scope="col">Publication</th> |
17 | | - <th scope="col">Unique ID</th> |
18 | | - </tr> |
19 | | - </thead> |
20 | | - <tbody> |
21 | | - {% for form in formset %} |
22 | | - <tr> |
23 | | - <td>{{ form.selected }}</td> |
24 | | - <td>{{ forloop.counter }}</td> |
25 | | - <td> |
26 | | - <strong>Title: </strong>{{ form.title.value }} <br> |
27 | | - <strong>Author: </strong>{{ form.author.value }} <br> |
28 | | - <strong>Year: </strong>{{ form.year.value }} <br> |
29 | | - <strong>Journal: </strong>{{ form.journal.value }} |
30 | | - </td> |
31 | | - <td class="text-nowrap">{{ form.unique_id.value }}</td> |
32 | | - </tr> |
33 | | - {% endfor %} |
34 | | - </tbody> |
35 | | - </table> |
36 | | - </div> |
37 | | - {{ formset.management_form }} |
38 | | - <div> |
39 | | - <button type="submit" class="btn btn-primary"><i class="fas fa-user-minus" aria-hidden="true"></i> Add Selected Publications to Project</button> |
40 | | - <a class="btn btn-secondary" href="{% url 'project-detail' project_pk %}" role="button"><i class="fas fa-long-arrow-left" aria-hidden="true"></i> Back to Project</a> |
41 | | - <input id="search_ids" type="hidden" name="search_ids" value="{{search_ids}}"> |
42 | | - <input id="pubs" type="hidden" name="pubs" value="{{pubs}}"> |
43 | | - </div> |
44 | | - </form> |
45 | | - </div> |
46 | | - </div> |
| 10 | +<div class="card border-light"> |
| 11 | + <div class="card-body"> |
| 12 | + <form action="{% url 'add-publication' project_pk %}" method="post"> |
| 13 | + {% csrf_token %} |
| 14 | + <div class="table-responsive"> |
| 15 | + <table class="table table-sm table-hover"> |
| 16 | + <thead> |
| 17 | + <tr> |
| 18 | + <th> |
| 19 | + <input type="checkbox" class="form-check-input" id="selectAll"> |
| 20 | + </th> |
| 21 | + <th scope="col">#</th> |
| 22 | + <th scope="col">Publication</th> |
| 23 | + <th scope="col">Unique ID</th> |
| 24 | + </tr> |
| 25 | + </thead> |
| 26 | + <tbody> |
| 27 | + {% for form in formset %} |
| 28 | + <tr> |
| 29 | + <td>{{ form.selected }}</td> |
| 30 | + <td>{{ forloop.counter }}</td> |
| 31 | + <td> |
| 32 | + <strong>Title:</strong>{{ form.title.value }} <br> |
| 33 | + <strong>Author:</strong>{{ form.author.value }} <br> |
| 34 | + <strong>Year:</strong>{{ form.year.value }} <br> |
| 35 | + <strong>Journal:</strong>{{ form.journal.value }} |
| 36 | + </td> |
| 37 | + <td class="text-nowrap">{{ form.unique_id.value }}</td> |
| 38 | + </tr> |
| 39 | + {% endfor %} |
| 40 | + </tbody> |
| 41 | + </table> |
| 42 | + </div> |
| 43 | + {{ formset.management_form }} |
| 44 | + <div> |
| 45 | + <button type="submit" class="btn btn-primary"><i class="fas fa-user-minus" aria-hidden="true"></i> |
| 46 | + Add Selected Publications to Project</button> |
| 47 | + <a class="btn btn-secondary" href="{% url 'project-detail' project_pk %}" role="button"><i class="fas fa-long-arrow-left" aria-hidden="true"></i> |
| 48 | + Back to Project</a> |
| 49 | + <input id="search_ids" type="hidden" name="search_ids" value="{{search_ids}}"> |
| 50 | + <input id="pubs" type="hidden" name="pubs" value="{{pubs}}"> |
| 51 | + </div> |
| 52 | + </form> |
| 53 | + </div> |
| 54 | +</div> |
47 | 55 | {% else %} |
48 | | - <a class="btn btn-secondary mb-3" href="{% url 'project-detail' project.pk %}" role="button"><i class="fas fa-long-arrow-left" aria-hidden="true"></i> Back to Project</a> |
49 | | - <div class="alert alert-info"> |
50 | | - No users to remove! |
51 | | - </div> |
| 56 | +<a class="btn btn-secondary mb-3" href="{% url 'project-detail' project.pk %}" role="button"><i class="fas fa-long-arrow-left" aria-hidden="true"></i> |
| 57 | +Back to Project</a> |
| 58 | +<div class="alert alert-info"> |
| 59 | + No users to remove! |
| 60 | +</div> |
52 | 61 | {% endif %} |
53 | 62 |
|
54 | | -<script> |
55 | | - $("#selectAll").click(function() { |
56 | | - $("input[name^='pubform-']").prop('checked', $(this).prop('checked')); |
57 | | - }); |
| 63 | +{% endif %} |
58 | 64 |
|
59 | | - $("input[name^='pubform-']").click(function(ele) { |
60 | | - var id = $(this).attr('id'); |
61 | | - if (id != "selectAll") { |
62 | | - $("#selectAll").prop('checked', false); |
63 | | - } |
64 | | - }); |
| 65 | +<script> |
| 66 | + $("#selectAll").click(function() { |
| 67 | + $("input[name^='pubform-']").prop('checked', $(this).prop('checked')); |
| 68 | + }); |
| 69 | + |
| 70 | + $("input[name^='pubform-']").click(function(ele) { |
| 71 | + var id = $(this).attr('id'); |
| 72 | + if (id != "selectAll") { |
| 73 | + $("#selectAll").prop('checked', false); |
| 74 | + } |
| 75 | + }); |
65 | 76 | </script> |
0 commit comments