mirror of
https://codeberg.org/diginaut/digimarks.git
synced 2026-02-04 13:50:27 +01:00
Also order z-a
This commit is contained in:
@@ -58,15 +58,17 @@ document.addEventListener('alpine:init', () => {
|
|||||||
i => i.title.match(new RegExp(this.search, "i"))
|
i => i.title.match(new RegExp(this.search, "i"))
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
async sortAlphabetically() {
|
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));
|
this.bookmarks.sort((a, b) => a.title.localeCompare(b.title));
|
||||||
|
}
|
||||||
},
|
},
|
||||||
async sortCreated(order = 'asc') {
|
async sortCreated(order = 'asc') {
|
||||||
if (order === 'desc') {
|
if (order === 'desc') {
|
||||||
this.bookmarks.sort((a, b) => b.created_date.localeCompare(a.created_date));
|
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));
|
this.bookmarks.sort((a, b) => a.created_date.localeCompare(b.created_date));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
<p>
|
<p>
|
||||||
<button @click="$store.digimarks.sortAlphabetically()">sort a-z</button>
|
<button @click="$store.digimarks.sortAlphabetically()">sort a-z</button>
|
||||||
|
<button @click="$store.digimarks.sortAlphabetically('desc')">sort z-a</button>
|
||||||
<button @click="$store.digimarks.sortCreated()">sort date asc</button>
|
<button @click="$store.digimarks.sortCreated()">sort date asc</button>
|
||||||
<button @click="$store.digimarks.sortCreated('desc')">sort date desc</button>
|
<button @click="$store.digimarks.sortCreated('desc')">sort date desc</button>
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
Reference in New Issue
Block a user