diff --git a/src/digimarks/static/js/digimarks.js b/src/digimarks/static/js/digimarks.js index 7a889d9..9214d6f 100644 --- a/src/digimarks/static/js/digimarks.js +++ b/src/digimarks/static/js/digimarks.js @@ -58,15 +58,17 @@ document.addEventListener('alpine:init', () => { i => i.title.match(new RegExp(this.search, "i")) ) }, - async sortAlphabetically() { - this.bookmarks.sort((a, b) => a.title.localeCompare(b.title)); + async sortAlphabetically(order = 'asc') { + if (order === 'desc') { + this.bookmarks.sort((a, b) => b.title.localeCompare(a.title)); + } else { + this.bookmarks.sort((a, b) => a.title.localeCompare(b.title)); + } }, async sortCreated(order = 'asc') { if (order === 'desc') { this.bookmarks.sort((a, b) => b.created_date.localeCompare(a.created_date)); - } else - { - + } else { this.bookmarks.sort((a, b) => a.created_date.localeCompare(b.created_date)); } } diff --git a/src/digimarks/templates/user_index.html b/src/digimarks/templates/user_index.html index df3bf25..7edb870 100644 --- a/src/digimarks/templates/user_index.html +++ b/src/digimarks/templates/user_index.html @@ -7,33 +7,34 @@ x-init="$store.digimarks.userKey = '{{ user_key }}'; $store.digimarks.loadCache(); $store.digimarks.getBookmarks()" x-data=""> - + - - - digimarks - tags - add bookmark - - - - + + + digimarks + tags + add bookmark + + + + Welcome user ! - Loading... + Loading... - sort a-z - sort date asc - sort date desc + sort a-z + sort z-a + sort date asc + sort date desc - - - - - + + + + + {% endblock %}
Welcome user !
- sort a-z - sort date asc - sort date desc + sort a-z + sort z-a + sort date asc + sort date desc