add sibling navigation
This commit is contained in:
parent
5b33ec5f35
commit
57c523dd13
4 changed files with 168 additions and 1 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue