add sibling navigation

This commit is contained in:
Yisroel Baum 2026-06-21 22:49:49 +03:00
parent 5b33ec5f35
commit 57c523dd13
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9
4 changed files with 168 additions and 1 deletions

View file

@ -20,6 +20,7 @@ type ElementFileType = 'iconImage' | 'shortPdf' | 'longPdf'
interface ElementResponse {
element: Element
childElements: ChildElement[]
siblingElements: ChildElement[]
}
export interface UpdateElementInput {
@ -58,6 +59,7 @@ const ELEMENT_UPDATE_URL = `${API_BASE_URL}/api/element/update`
export const useElementsStore = defineStore('elements', () => {
const element = ref<Element | null>(null)
const childElements = ref<ChildElement[]>([])
const siblingElements = ref<ChildElement[]>([])
const isLoading = ref(false)
const error = ref<string | null>(null)
const isSaving = ref(false)
@ -71,6 +73,7 @@ export const useElementsStore = defineStore('elements', () => {
async function fetchElement(elementId: string): Promise<void> {
element.value = null
childElements.value = []
siblingElements.value = []
error.value = null
saveError.value = null
childActionError.value = null
@ -94,8 +97,10 @@ export const useElementsStore = defineStore('elements', () => {
const data: ElementResponse = await response.json()
element.value = data.element
childElements.value = data.childElements
siblingElements.value = data.siblingElements
} catch {
childElements.value = []
siblingElements.value = []
error.value = 'Network error - could not load element'
} finally {
isLoading.value = false
@ -388,6 +393,7 @@ export const useElementsStore = defineStore('elements', () => {
return {
element,
childElements,
siblingElements,
isLoading,
error,
isSaving,