diff --git a/bookmarks/frontend/utils/element.js b/bookmarks/frontend/utils/element.js index 2cf82fc..0b6c078 100644 --- a/bookmarks/frontend/utils/element.js +++ b/bookmarks/frontend/utils/element.js @@ -12,6 +12,15 @@ document.addEventListener("turbo:render", () => { isTopFrameVisit = false; }); +document.addEventListener("turbo:before-morph-element", (event) => { + if (event.target instanceof TurboLitElement) { + // Prevent Turbo from morphing Lit elements, which would remove rendered + // contents. For now this means that any Lit element / widget can not be + // updated from the server when using morphing. + event.preventDefault(); + } +}); + export class TurboLitElement extends LitElement { constructor() { super(); diff --git a/bookmarks/styles/settings.css b/bookmarks/styles/settings.css index 1398538..789eebc 100644 --- a/bookmarks/styles/settings.css +++ b/bookmarks/styles/settings.css @@ -9,7 +9,7 @@ h2 { font-size: var(--font-size-lg); - margin-bottom: var(--unit-3); + margin-bottom: var(--unit-4); } } diff --git a/bookmarks/styles/tags.css b/bookmarks/styles/tags.css index 14d1df0..715b05f 100644 --- a/bookmarks/styles/tags.css +++ b/bookmarks/styles/tags.css @@ -4,3 +4,9 @@ margin: 0 auto; } } + +.tag-edit-modal { + .modal-container { + max-width: 400px; + } +} diff --git a/bookmarks/styles/theme/forms.css b/bookmarks/styles/theme/forms.css index 7d0e741..10567a0 100644 --- a/bookmarks/styles/theme/forms.css +++ b/bookmarks/styles/theme/forms.css @@ -20,9 +20,6 @@ } .form-group { - &:first-of-type { - margin-top: var(--unit-4); - } &:not(:last-child) { margin-bottom: var(--unit-4); } diff --git a/bookmarks/templates/settings/create_api_token_modal.html b/bookmarks/templates/settings/create_api_token_modal.html index 44d5000..6129d42 100644 --- a/bookmarks/templates/settings/create_api_token_modal.html +++ b/bookmarks/templates/settings/create_api_token_modal.html @@ -21,7 +21,7 @@ diff --git a/bookmarks/templates/tags/edit.html b/bookmarks/templates/tags/edit.html index 663320f..0d7a04f 100644 --- a/bookmarks/templates/tags/edit.html +++ b/bookmarks/templates/tags/edit.html @@ -1,23 +1,19 @@ -{% extends "bookmarks/layout.html" %} -{% load shared %} - -{% block head %} - {% with page_title="Edit tag - Linkding" %} - {{ block.super }} - {% endwith %} -{% endblock %} - -{% block content %} -
-
-
-

Edit tag

+ +
+ {% csrf_token %} + + + - - - {% csrf_token %} - {% include 'tags/form.html' %} - -
-
-{% endblock %} + + + diff --git a/bookmarks/templates/tags/form.html b/bookmarks/templates/tags/form.html index 77e4111..86e71f7 100644 --- a/bookmarks/templates/tags/form.html +++ b/bookmarks/templates/tags/form.html @@ -2,18 +2,13 @@
- {{ form.name|add_class:"form-input"|attr:"autocomplete:off"|attr:"placeholder: " }} -
Tag names are case-insensitive and cannot contain spaces (spaces will be replaced with hyphens).
+ {{ form.name|add_class:"form-input"|attr:"autocomplete:off"|attr:"placeholder: "|attr:"autofocus" }} +
Tag names are case-insensitive and cannot contain spaces (spaces will be replaced with + hyphens). +
{% if form.name.errors %}
{{ form.name.errors }}
{% endif %}
- -
- -
- - Cancel -
diff --git a/bookmarks/templates/tags/index.html b/bookmarks/templates/tags/index.html index 5ed2176..0bd45f4 100644 --- a/bookmarks/templates/tags/index.html +++ b/bookmarks/templates/tags/index.html @@ -14,8 +14,8 @@

Tags

- Add Tag - Merge Tags + Create Tag + Merge Tags
@@ -96,7 +96,8 @@ - Edit + Edit + + - -
- - How to merge tags - -
    -
  1. Enter the name of the tag you want to keep
  2. -
  3. Enter the names of tags to merge into the target tag
  4. -
  5. The target tag is added to all bookmarks that have any of the merge tags
  6. -
  7. The merged tags are deleted
  8. -
-
- - - {% csrf_token %} - -
- - - -
- Enter the name of the tag you want to keep. The tags entered below will be merged into this one. -
- {% if form.target_tag.errors %} -
- {{ form.target_tag.errors }} -
- {% endif %} -
- -
- - - -
Enter the names of tags to merge into the target tag, separated by spaces. These - tags will be deleted after merging. -
- {% if form.merge_tags.errors %} -
- {{ form.merge_tags.errors }} -
- {% endif %} -
- -
- -
- - Cancel -
- - - -{% endblock %} + + + diff --git a/bookmarks/templates/tags/new.html b/bookmarks/templates/tags/new.html index 8b6abbb..a2ac700 100644 --- a/bookmarks/templates/tags/new.html +++ b/bookmarks/templates/tags/new.html @@ -1,23 +1,19 @@ -{% extends "bookmarks/layout.html" %} -{% load shared %} - -{% block head %} - {% with page_title="Add tag - Linkding" %} - {{ block.super }} - {% endwith %} -{% endblock %} - -{% block content %} -
-
-
-

New tag

+ +
+ {% csrf_token %} + + + - - - {% csrf_token %} - {% include 'tags/form.html' %} - -
-
-{% endblock %} + + + diff --git a/bookmarks/tests/test_tags_merge_view.py b/bookmarks/tests/test_tags_merge_view.py index 50e70f1..7d67d07 100644 --- a/bookmarks/tests/test_tags_merge_view.py +++ b/bookmarks/tests/test_tags_merge_view.py @@ -1,3 +1,5 @@ +from bs4 import TemplateString +from bs4.element import NavigableString, CData from django.test import TestCase from django.urls import reverse @@ -10,6 +12,11 @@ class TagsMergeViewTestCase(TestCase, BookmarkFactoryMixin, HtmlTestMixin): self.user = self.get_or_create_test_user() self.client.force_login(self.user) + def get_text(self, element): + # Invalid form responses are wrapped in