Sort columns by title

This commit is contained in:
Brieuc Dubois 2024-01-24 15:40:06 +01:00
parent 12e38589e9
commit 26ef17eb40
3 changed files with 20 additions and 8 deletions

View File

@ -71,6 +71,15 @@
card.showModal = true; card.showModal = true;
} }
async function setOptionValue() {
if (!option || !primaryTag) return;
if (newOptionValue === option.value) return;
await option.setValue(newOptionValue);
newOptionValue = option.value;
currentView.reload();
}
</script> </script>
<div <div
@ -86,12 +95,11 @@
<input <input
bind:value={newOptionValue} bind:value={newOptionValue}
type="text" type="text"
on:blur={async () => { on:blur={setOptionValue}
if (!option || !primaryTag) return; on:keydown={(e) => {
if (newOptionValue === option.value) return; if (e.key === 'Enter') {
setOptionValue();
await option.setValue(newOptionValue); }
newOptionValue = option.value;
}} }}
disabled={option === null} disabled={option === null}
/> />

View File

@ -5,7 +5,7 @@
import type Project from '$lib/types/Project'; import type Project from '$lib/types/Project';
import type ProjectTag from '$lib/types/ProjectTag'; import type ProjectTag from '$lib/types/ProjectTag';
import { projectTags } from '$lib/types/ProjectTag'; import { projectTags } from '$lib/types/ProjectTag';
import type TagOption from '$lib/types/TagOption'; import TagOption from '$lib/types/TagOption';
import type View from '$lib/types/View'; import type View from '$lib/types/View';
import Column from './Column.svelte'; import Column from './Column.svelte';
import Header from './Header.svelte'; import Header from './Header.svelte';
@ -118,7 +118,7 @@
{#if $cards} {#if $cards}
<div class="grid"> <div class="grid">
{#if $currentView.primaryTag} {#if $currentView.primaryTag}
{#each $currentView.primaryTag.options as option (option.id)} {#each [...$currentView.primaryTag.options].sort(TagOption.compare) as option (option.id)}
{#if columnPassFilters(option, $currentView.filters)} {#if columnPassFilters(option, $currentView.filters)}
<Column <Column
{option} {option}

View File

@ -13,6 +13,10 @@ export default class TagOption {
this._value = value; this._value = value;
} }
static compare(a: TagOption, b: TagOption): number {
return a.value.localeCompare(b.value);
}
get id(): number { get id(): number {
return this._id; return this._id;
} }