diff --git a/.gitignore b/.gitignore index dc99747..63907f5 100644 --- a/.gitignore +++ b/.gitignore @@ -222,7 +222,8 @@ typings/ .next ### Custom - +# Rollup compilation output +/build # Collected static files for deployment /static # Build output, etc. diff --git a/README.md b/README.md index fdf5055..c65f4b9 100644 --- a/README.md +++ b/README.md @@ -102,6 +102,10 @@ Create a user for the frontend: ``` python3 manage.py createsuperuser --username=joe --email=joe@example.com ``` +Start the Node.js development server (used for compiling JavaScript components like tag auto-completion) with: +``` +npm run dev +``` Start the Django development server with: ``` python3 manage.py runserver diff --git a/bookmarks/components/TagAutocomplete.svelte b/bookmarks/components/TagAutocomplete.svelte new file mode 100644 index 0000000..a3676cb --- /dev/null +++ b/bookmarks/components/TagAutocomplete.svelte @@ -0,0 +1,155 @@ + + +
+ +
+ + +
+ + + +
+ + \ No newline at end of file diff --git a/bookmarks/components/index.js b/bookmarks/components/index.js new file mode 100644 index 0000000..7a56156 --- /dev/null +++ b/bookmarks/components/index.js @@ -0,0 +1,6 @@ +import TagAutoComplete from './TagAutocomplete.svelte' + +export default { + TagAutoComplete +} + diff --git a/bookmarks/queries.py b/bookmarks/queries.py index 1bb8b03..564f4d8 100644 --- a/bookmarks/queries.py +++ b/bookmarks/queries.py @@ -78,6 +78,10 @@ def query_tags(user: User, query_string: str): return query_set.distinct() +def get_user_tags(user: User): + return Tag.objects.filter(owner=user).all() + + def _parse_query_string(query_string): # Sanitize query params if not query_string: diff --git a/bookmarks/styles/index.scss b/bookmarks/styles/index.scss index 8797384..556c57c 100644 --- a/bookmarks/styles/index.scss +++ b/bookmarks/styles/index.scss @@ -10,6 +10,7 @@ $alternative-color-dark: darken($alternative-color, 5%); // Import Spectre CSS lib @import "../../node_modules/spectre.css/src/spectre"; +@import "../../node_modules/spectre.css/src/autocomplete"; // Import Spectre icons @import "../../node_modules/spectre.css/src/icons/icons-core"; @import "../../node_modules/spectre.css/src/icons/icons-navigation"; diff --git a/bookmarks/templates/bookmarks/edit.html b/bookmarks/templates/bookmarks/edit.html index 7d5c795..d5e6f54 100644 --- a/bookmarks/templates/bookmarks/edit.html +++ b/bookmarks/templates/bookmarks/edit.html @@ -8,7 +8,7 @@

Edit bookmark

- {% bookmark_form form %} + {% bookmark_form form all_tags %}
diff --git a/bookmarks/templates/bookmarks/form.html b/bookmarks/templates/bookmarks/form.html index 5949d64..377c4c6 100644 --- a/bookmarks/templates/bookmarks/form.html +++ b/bookmarks/templates/bookmarks/form.html @@ -1,4 +1,5 @@ {% load widget_tweaks %} +{% load static %}
{% csrf_token %} @@ -13,7 +14,7 @@ {% endif %}
- + {{ form.tag_string|add_class:"form-input" }}
Enter any number of tags separated by space and without the hash (#). If a tag does not @@ -54,6 +55,26 @@ Nevermind
+ {# Replace tag input with auto-complete component #} + +