Sort views by title

This commit is contained in:
Brieuc Dubois 2024-01-24 16:15:42 +01:00
parent 05fa41d9ee
commit baf3474c29
2 changed files with 7 additions and 1 deletions

View File

@ -53,7 +53,7 @@
<h2>{project.title}</h2>
{#if views}
<ul>
{#each $views as view (view.id)}
{#each [...$views].sort(View.compare) as view (view.id)}
<!-- svelte-ignore a11y-no-noninteractive-element-to-interactive-role -->
<li
on:click={() => {

View File

@ -51,6 +51,10 @@ export default class View {
this._filters = filters;
}
static compare(a: View, b: View): number {
return a.title.localeCompare(b.title);
}
get id(): number {
return this._id;
}
@ -166,6 +170,8 @@ export default class View {
this._title = title;
views.reload(this);
return true;
}