feat(bookstack) : add shelf select to ProjectDrawer
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -43,6 +43,16 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</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">
|
<div class="mt-6 flex justify-end">
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
@@ -71,8 +81,10 @@
|
|||||||
import type { Project, ProjectWrite } from '~/services/dto/project'
|
import type { Project, ProjectWrite } from '~/services/dto/project'
|
||||||
import type { Client } from '~/services/dto/client'
|
import type { Client } from '~/services/dto/client'
|
||||||
import type { GiteaRepository } from '~/services/dto/gitea'
|
import type { GiteaRepository } from '~/services/dto/gitea'
|
||||||
|
import type { BookStackShelf } from '~/services/dto/bookstack'
|
||||||
import { useProjectService } from '~/services/projects'
|
import { useProjectService } from '~/services/projects'
|
||||||
import { useGiteaService } from '~/services/gitea'
|
import { useGiteaService } from '~/services/gitea'
|
||||||
|
import { useBookStackService } from '~/services/bookstack'
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
modelValue: boolean
|
modelValue: boolean
|
||||||
@@ -100,6 +112,13 @@ const giteaRepoOptions = computed(() =>
|
|||||||
giteaRepos.value.map(r => ({ label: r.fullName, value: r.fullName }))
|
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({
|
const form = reactive({
|
||||||
code: '',
|
code: '',
|
||||||
name: '',
|
name: '',
|
||||||
@@ -107,6 +126,7 @@ const form = reactive({
|
|||||||
color: '#222783',
|
color: '#222783',
|
||||||
clientId: null as number | null,
|
clientId: null as number | null,
|
||||||
giteaRepoFullName: null as string | null,
|
giteaRepoFullName: null as string | null,
|
||||||
|
bookstackShelfId: null as number | null,
|
||||||
})
|
})
|
||||||
|
|
||||||
const touched = reactive({
|
const touched = reactive({
|
||||||
@@ -129,6 +149,7 @@ watch(() => props.modelValue, (open) => {
|
|||||||
form.giteaRepoFullName = props.project?.giteaOwner && props.project?.giteaRepo
|
form.giteaRepoFullName = props.project?.giteaOwner && props.project?.giteaRepo
|
||||||
? `${props.project.giteaOwner}/${props.project.giteaRepo}`
|
? `${props.project.giteaOwner}/${props.project.giteaRepo}`
|
||||||
: null
|
: null
|
||||||
|
form.bookstackShelfId = props.project.bookstackShelfId ?? null
|
||||||
} else {
|
} else {
|
||||||
form.code = ''
|
form.code = ''
|
||||||
form.name = ''
|
form.name = ''
|
||||||
@@ -136,6 +157,7 @@ watch(() => props.modelValue, (open) => {
|
|||||||
form.color = '#222783'
|
form.color = '#222783'
|
||||||
form.clientId = null
|
form.clientId = null
|
||||||
form.giteaRepoFullName = null
|
form.giteaRepoFullName = null
|
||||||
|
form.bookstackShelfId = null
|
||||||
}
|
}
|
||||||
touched.code = false
|
touched.code = false
|
||||||
touched.name = false
|
touched.name = false
|
||||||
@@ -168,6 +190,15 @@ async function handleSubmit() {
|
|||||||
payload.giteaRepo = null
|
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) {
|
if (isEditing.value && props.project) {
|
||||||
await update(props.project.id, payload)
|
await update(props.project.id, payload)
|
||||||
} else {
|
} else {
|
||||||
@@ -203,5 +234,10 @@ onMounted(async () => {
|
|||||||
} catch {
|
} catch {
|
||||||
// Gitea not configured, ignore
|
// Gitea not configured, ignore
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
bookstackShelves.value = await listShelves()
|
||||||
|
} catch {
|
||||||
|
// BookStack not configured, ignore
|
||||||
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ export type Project = {
|
|||||||
client: Client | null
|
client: Client | null
|
||||||
giteaOwner: string | null
|
giteaOwner: string | null
|
||||||
giteaRepo: string | null
|
giteaRepo: string | null
|
||||||
|
bookstackShelfId: number | null
|
||||||
|
bookstackShelfName: string | null
|
||||||
archived: boolean
|
archived: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -21,5 +23,7 @@ export type ProjectWrite = {
|
|||||||
client: string | null // IRI : "/api/clients/1" ou null
|
client: string | null // IRI : "/api/clients/1" ou null
|
||||||
giteaOwner?: string | null
|
giteaOwner?: string | null
|
||||||
giteaRepo?: string | null
|
giteaRepo?: string | null
|
||||||
|
bookstackShelfId?: number | null
|
||||||
|
bookstackShelfName?: string | null
|
||||||
archived?: boolean
|
archived?: boolean
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user