Move more logic into bookmark form

This commit is contained in:
Sascha Ißbrücker
2025-03-09 23:11:48 +01:00
parent 9dfc9b03b4
commit b9bee24047
9 changed files with 119 additions and 116 deletions

View File

@@ -1,5 +1,4 @@
{% extends 'bookmarks/layout.html' %}
{% load bookmarks %}
{% block content %}
<div class="bookmarks-form-page">
@@ -9,7 +8,7 @@
</div>
<form action="{% url 'linkding:bookmarks.edit' bookmark_id %}?return_url={{ return_url|urlencode }}" method="post"
novalidate>
{% bookmark_form form return_url bookmark_id %}
{% include 'bookmarks/form.html' %}
</form>
</section>
</div>

View File

@@ -91,12 +91,12 @@
{% endif %}
<div class="divider"></div>
<div class="form-group d-flex justify-between">
{% if auto_close %}
{% if form.is_auto_close %}
<input type="submit" value="Save and close" class="btn btn-primary btn-wide">
{% else %}
<input type="submit" value="Save" class="btn btn-primary btn btn-primary btn-wide">
{% endif %}
<a href="{{ cancel_url }}" class="btn">Nevermind</a>
<a href="{{ return_url }}" class="btn">Nevermind</a>
</div>
<script type="application/javascript">
/**
@@ -112,7 +112,7 @@
const unreadCheckbox = document.getElementById('{{ form.unread.id_for_label }}');
const sharedCheckbox = document.getElementById('{{ form.shared.id_for_label }}');
const bookmarkExistsHint = document.querySelector('.form-input-hint.bookmark-exists');
const editedBookmarkId = {{ bookmark_id }};
const editedBookmarkId = {{ form.instance.id|default:0 }};
let isTitleModified = !!titleInput.value;
let isDescriptionModified = !!descriptionInput.value;

View File

@@ -1,5 +1,4 @@
{% extends 'bookmarks/layout.html' %}
{% load bookmarks %}
{% block content %}
<div class="bookmarks-form-page">
@@ -8,7 +7,7 @@
<h2>New bookmark</h2>
</div>
<form action="{% url 'linkding:bookmarks.new' %}" method="post" novalidate>
{% bookmark_form form return_url auto_close=auto_close %}
{% include 'bookmarks/form.html' %}
</form>
</section>
</div>