#26 Return to same page after editing or deleting bookmark

This commit is contained in:
Sascha Ißbrücker
2020-09-13 10:56:03 +02:00
parent 3373667c72
commit c80f26dd34
8 changed files with 55 additions and 16 deletions

View File

@@ -21,9 +21,9 @@
{% endif %}
</div>
<div class="actions">
<a href="{% url 'bookmarks:edit' bookmark.id %}"
<a href="{% url 'bookmarks:edit' bookmark.id %}?return_url={{ return_url }}"
class="btn btn-link btn-sm">Edit</a>
<a href="{% url 'bookmarks:remove' bookmark.id %}"
<a href="{% url 'bookmarks:remove' bookmark.id %}?return_url={{ return_url }}"
class="btn btn-link btn-sm"
onclick="return confirm('Do you really want to delete this bookmark?')">Remove</a>
</div>

View File

@@ -8,7 +8,7 @@
<h2>Edit bookmark</h2>
</div>
<form action="{% url 'bookmarks:edit' bookmark_id %}" method="post" class="col-6 col-md-12" novalidate>
{% bookmark_form form all_tags bookmark_id %}
{% bookmark_form form all_tags return_url bookmark_id %}
</form>
</section>
</div>

View File

@@ -4,6 +4,7 @@
<div class="bookmarks-form">
{% csrf_token %}
{{ form.auto_close|attr:"type:hidden" }}
{{ form.return_url|attr:"type:hidden" }}
<div class="form-group {% if form.url.errors %}has-error{% endif %}">
<label for="{{ form.url.id_for_label }}" class="form-label">URL</label>
{{ form.url|add_class:"form-input"|attr:"autofocus" }}
@@ -55,7 +56,7 @@
{% else %}
<input type="submit" value="Save" class="btn btn-primary mr-2">
{% endif %}
<a href="{% url 'bookmarks:index' %}" class="btn">Nevermind</a>
<a href="{{ cancel_url }}" class="btn">Nevermind</a>
</div>
{# Replace tag input with auto-complete component #}

View File

@@ -23,7 +23,7 @@
{% if empty %}
{% include 'bookmarks/empty_bookmarks.html' %}
{% else %}
{% bookmark_list bookmarks %}
{% bookmark_list bookmarks return_url %}
{% endif %}
</section>

View File

@@ -8,7 +8,7 @@
<h2>New bookmark</h2>
</div>
<form action="{% url 'bookmarks:new' %}" method="post" class="col-6 col-md-12" novalidate>
{% bookmark_form form all_tags auto_close=auto_close %}
{% bookmark_form form all_tags return_url auto_close=auto_close %}
</form>
</section>
</div>