better representiation of delete/edit notes

This commit is contained in:
Thomas Nahuel Rusiecki 2025-01-07 21:13:28 -03:00
parent e58a83ddc2
commit f3c04cdba8
2 changed files with 18 additions and 8 deletions

View file

@ -73,7 +73,6 @@ class AddNoteView(View):
class UpdateNoteView(UpdateView):
model = Note
fields = ['description']
template_name = "blank.html"
pk_url_kwarg = 'pk'
def form_valid(self, form):

View file

@ -27,15 +27,19 @@
<small class="text-muted">
{{ note.date|timesince }} {% trans "ago" %}
</small>
</div>
{% if user == note.user or user.is_admin %}
<span class="badge bg-warning text-dark ms-2">{% trans "Editable" %}</span>
</div>
<blockquote
class="blockquote mt-2 p-2 bg-light fst-italic"
contenteditable="true"
style="font-size: 1em!important"
data-note-id="{{ note.id }}"
title="{% trans 'Click to edit this note' %}"
oninput="toggleSaveLink(this)">
{% else %}
</div>
<blockquote style="font-size: 1em!important" class="blockquote mt-2 p-2 fst-italic">
{% endif %}
<p data-note-id="{{ note.id }}">
@ -69,18 +73,25 @@
<i class="fas fa-save"></i>
</a>
</form>
<!-- delete note button -->
<button type="button" class="btn btn-link btn-outline-danger btn-sm text-danger" id="deleteIcon{{ note.id }}" title="{% trans 'Delete note' %}" data-bs-toggle="collapse" data-bs-target="#confirmDelete{{ note.id }}">
<i class="bi bi-trash"></i>
</button>
</div>
<form class="d-inline" method="post" action="{% url 'action:delete_note' note.id %}">
{% csrf_token %}
<div class="collapse mt-2 text-end" id="confirmDelete{{ note.id }}">
<a href="#" class="btn btn-sm btn-outline-danger" onclick="submitDeleteForm({{ note.id }}); return false;">
{% trans 'Confirm delete' %}
</a>
{% csrf_token %}
<div class="collapse mt-2" id="confirmDelete{{ note.id }}">
<div class="card card-body border border-danger text-center">
<p class="mb-2">{% trans 'Are you sure you want to delete this note?' %}</p>
<a
href="#"
class="btn btn-sm btn-outline-danger"
onclick="submitDeleteForm({{ note.id }}); return false;"
>
{% trans 'Confirm delete' %}
</a>
</div>
</div>
</form>
{% endif %}