feat(bookstack) : add shelf select to ProjectDrawer

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-15 18:15:34 +01:00
parent c9a3c7c5f8
commit f53b2f3d1f
2 changed files with 40 additions and 0 deletions

View File

@@ -43,6 +43,16 @@
/>
</div>
<div v-if="bookstackShelves.length" class="mt-4">
<MalioSelect
v-model="form.bookstackShelfId"
:options="bookstackShelfOptions"
label="Étagère BookStack"
empty-option-label="Aucune étagère"
min-width="w-full"
/>
</div>
<div class="mt-6 flex justify-end">
<button
type="submit"
@@ -71,8 +81,10 @@
import type { Project, ProjectWrite } from '~/services/dto/project'
import type { Client } from '~/services/dto/client'
import type { GiteaRepository } from '~/services/dto/gitea'
import type { BookStackShelf } from '~/services/dto/bookstack'
import { useProjectService } from '~/services/projects'
import { useGiteaService } from '~/services/gitea'
import { useBookStackService } from '~/services/bookstack'
const props = defineProps<{
modelValue: boolean
@@ -100,6 +112,13 @@ const giteaRepoOptions = computed(() =>
giteaRepos.value.map(r => ({ label: r.fullName, value: r.fullName }))
)
const { listShelves } = useBookStackService()
const bookstackShelves = ref<BookStackShelf[]>([])
const bookstackShelfOptions = computed(() =>
bookstackShelves.value.map(s => ({ label: s.name, value: s.id }))
)
const form = reactive({
code: '',
name: '',
@@ -107,6 +126,7 @@ const form = reactive({
color: '#222783',
clientId: null as number | null,
giteaRepoFullName: null as string | null,
bookstackShelfId: null as number | null,
})
const touched = reactive({
@@ -129,6 +149,7 @@ watch(() => props.modelValue, (open) => {
form.giteaRepoFullName = props.project?.giteaOwner && props.project?.giteaRepo
? `${props.project.giteaOwner}/${props.project.giteaRepo}`
: null
form.bookstackShelfId = props.project.bookstackShelfId ?? null
} else {
form.code = ''
form.name = ''
@@ -136,6 +157,7 @@ watch(() => props.modelValue, (open) => {
form.color = '#222783'
form.clientId = null
form.giteaRepoFullName = null
form.bookstackShelfId = null
}
touched.code = false
touched.name = false
@@ -168,6 +190,15 @@ async function handleSubmit() {
payload.giteaRepo = null
}
if (form.bookstackShelfId) {
const shelf = bookstackShelves.value.find(s => s.id === form.bookstackShelfId)
payload.bookstackShelfId = form.bookstackShelfId
payload.bookstackShelfName = shelf?.name ?? null
} else {
payload.bookstackShelfId = null
payload.bookstackShelfName = null
}
if (isEditing.value && props.project) {
await update(props.project.id, payload)
} else {
@@ -203,5 +234,10 @@ onMounted(async () => {
} catch {
// Gitea not configured, ignore
}
try {
bookstackShelves.value = await listShelves()
} catch {
// BookStack not configured, ignore
}
})
</script>

View File

@@ -10,6 +10,8 @@ export type Project = {
client: Client | null
giteaOwner: string | null
giteaRepo: string | null
bookstackShelfId: number | null
bookstackShelfName: string | null
archived: boolean
}
@@ -21,5 +23,7 @@ export type ProjectWrite = {
client: string | null // IRI : "/api/clients/1" ou null
giteaOwner?: string | null
giteaRepo?: string | null
bookstackShelfId?: number | null
bookstackShelfName?: string | null
archived?: boolean
}