refactor: categroy tag

This commit is contained in:
somnetsak123 2023-11-30 18:04:52 +07:00
parent 10a63f26e2
commit 87582651c8
2 changed files with 64 additions and 30 deletions

View file

@ -30,7 +30,6 @@ const {
updateFile,
deleteFile,
checkFile,
checkFileName,
} = useTreeDataStore()
const currentIcon = computed(() =>
@ -61,7 +60,7 @@ const fileFormData = ref<{
category?: string
}>({})
const fileFormType = ref<'edit' | 'create'>('create')
const fileFormError = ref<{ fileExist?: boolean; fileName2Long?: boolean }>({})
const fileFormError = ref<{ fileExist?: boolean }>({})
const fileExistNotification = ref<boolean>(false)
function triggerFolderDelete(pathname: string) {
@ -134,8 +133,8 @@ async function submitFileForm(
file?: File
title: string
description: string
keyword: string
category: string
keyword: string[]
category: string[]
},
force = false,
) {
@ -150,8 +149,8 @@ async function submitFileForm(
await uploadFile(currentPath.value, value.file, {
title: value.title,
description: value.description,
keyword: value.keyword,
category: value.category,
keyword: value.keyword.join(''),
category: value.category.join(''),
})
} else {
await updateFile(
@ -159,8 +158,8 @@ async function submitFileForm(
{
title: value.title,
description: value.description,
keyword: value.keyword,
category: value.category,
keyword: value.keyword.join(''),
category: value.category.join(''),
},
value.file,
)
@ -369,12 +368,7 @@ async function submitFileForm(
v-model:description="fileFormData.description"
v-model:keyword="fileFormData.keyword"
v-model:category="fileFormData.category"
@filechange="
(name: string) => (
(fileFormError.fileExist = checkFile(name)),
(fileFormError.fileName2Long = checkFileName(name))
)
"
@filechange="(name: string) => (fileFormError.fileExist = checkFile(name))"
@submit="submitFileForm"
/>