M2 labels frontend: sidebar shell + label filter, chips, picker, manage
- AppShell: persistent left sidebar (Notes · labels · Archive · Trash) + top bar (site name, admin Settings, sign out); BoardView now renders inside it. - labels store (list/create/rename/delete); Note gains labels[]; notes store gains setLabels + label-aware reconcile + /api/notes?label= loading. - /label/:id route → label-filtered board. - LabelPicker (tag a note, create-on-the-fly) in the editor; label chips shown on cards and in the editor; LabelsModal to create/rename/delete labels. - api client PUT; new icons (note/tag/pencil/plus/check); nav-link styles. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FRgehjoz7Yv8LkUfADxACm
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import { defineStore } from "pinia";
|
||||
import { ref } from "vue";
|
||||
import { api } from "../api/client";
|
||||
|
||||
export interface Label {
|
||||
id: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export const useLabelsStore = defineStore("labels", () => {
|
||||
const items = ref<Label[]>([]);
|
||||
const loaded = ref(false);
|
||||
|
||||
function sort() {
|
||||
items.value.sort((a, b) => a.name.localeCompare(b.name));
|
||||
}
|
||||
|
||||
async function load(): Promise<void> {
|
||||
const res = await api.get<{ labels: Label[] }>("/api/labels");
|
||||
items.value = res.labels;
|
||||
loaded.value = true;
|
||||
}
|
||||
|
||||
async function create(name: string): Promise<Label> {
|
||||
const label = await api.post<Label>("/api/labels", { name });
|
||||
if (!items.value.some((lb) => lb.id === label.id)) {
|
||||
items.value.push(label);
|
||||
sort();
|
||||
}
|
||||
return label;
|
||||
}
|
||||
|
||||
async function rename(id: string, name: string): Promise<void> {
|
||||
const updated = await api.patch<Label>(`/api/labels/${id}`, { name });
|
||||
const idx = items.value.findIndex((lb) => lb.id === id);
|
||||
if (idx >= 0) items.value[idx] = updated;
|
||||
sort();
|
||||
}
|
||||
|
||||
async function remove(id: string): Promise<void> {
|
||||
await api.del(`/api/labels/${id}`);
|
||||
items.value = items.value.filter((lb) => lb.id !== id);
|
||||
}
|
||||
|
||||
return { items, loaded, load, create, rename, remove };
|
||||
});
|
||||
Reference in New Issue
Block a user