feat: hasAttachments as store computed

This commit is contained in:
Dominik Pschenitschni 2024-11-18 14:56:54 +01:00 committed by konrad
parent 1563c462a2
commit 1f55e3f866
2 changed files with 6 additions and 3 deletions

View File

@ -1,4 +1,4 @@
import {ref, readonly} from 'vue'
import {ref, computed, readonly} from 'vue'
import {defineStore, acceptHMRUpdate} from 'pinia'
import {findIndexById} from '@/helpers/utils'
@ -23,11 +23,14 @@ export const useAttachmentStore = defineStore('attachment', () => {
console.debug('Remove attachement', id)
}
const hasAttachments = computed(() => attachments.value.length > 0)
return {
attachments: readonly(attachments),
set,
add,
removeById,
hasAttachments,
}
})

View File

@ -587,6 +587,7 @@
<script lang="ts" setup>
import {ref, reactive, shallowReactive, computed, watch, nextTick, onMounted, onBeforeUnmount} from 'vue'
import {useRouter, type RouteLocation} from 'vue-router'
import {storeToRefs} from 'pinia'
import {useI18n} from 'vue-i18n'
import {unrefElement} from '@vueuse/core'
import {klona} from 'klona/lite'
@ -657,6 +658,7 @@ const {t} = useI18n({useScope: 'global'})
const projectStore = useProjectStore()
const attachmentStore = useAttachmentStore()
const {hasAttachments} = storeToRefs(attachmentStore)
const taskStore = useTaskStore()
const kanbanStore = useKanbanStore()
const authStore = useAuthStore()
@ -710,8 +712,6 @@ const color = computed(() => {
return color
})
const hasAttachments = computed(() => attachmentStore.attachments.length > 0)
const isModal = computed(() => Boolean(props.backdropView))
function attachmentUpload(file: File, onSuccess?: (url: string) => void) {