diff --git a/Services/client/src/components/FileForm.vue b/Services/client/src/components/FileForm.vue index 5289238..afc0e62 100644 --- a/Services/client/src/components/FileForm.vue +++ b/Services/client/src/components/FileForm.vue @@ -14,6 +14,7 @@ const props = withDefaults( fileName2Long?: boolean } mode: 'create' | 'edit' + fileNameLabel?: string title?: string description?: string keyword?: string[] @@ -146,7 +147,13 @@ const file = ref() outlined v-model="file" @update:model-value="(v) => $emit('filechange', v.name)" - :label="file?.name ? undefined : 'เลือกไฟล์'" + :label=" + mode === 'edit' && fileNameLabel && !file?.name + ? fileNameLabel + : file?.name + ? undefined + : 'เลือกไฟล์' + " :error="!!error.fileExist || !!error.fileName2Long" :error-message=" error.fileExist diff --git a/Services/client/src/components/FileFormWrapper.vue b/Services/client/src/components/FileFormWrapper.vue index 7b3dc92..9e71e45 100644 --- a/Services/client/src/components/FileFormWrapper.vue +++ b/Services/client/src/components/FileFormWrapper.vue @@ -22,6 +22,7 @@ const fileFormType = ref<'edit' | 'create'>('create') const fileFormError = ref<{ fileExist?: boolean; fileName2Long?: boolean }>({}) const fileExistNotification = ref(false) const fileFormComponent = ref>() +const fileNameLabel = ref() function triggerFileCreate() { fileFormType.value = 'create' @@ -37,6 +38,7 @@ function triggerFileEdit( category: string[] }, pathname: string, + file?: string, ) { fileFormState.value = true fileFormType.value = 'edit' @@ -47,6 +49,7 @@ function triggerFileEdit( keyword: value.keyword, category: value.category, } + fileNameLabel.value = file } defineExpose({ @@ -56,9 +59,11 @@ defineExpose({ const currentParam = ref[0]>() -function checkFileExist(name: string) { +function checkFileExist(name: string, except?: string) { return Boolean( - file.value[currentInfo.value.path].find((v) => v.fileName === name), + file.value[currentInfo.value.path].find( + (v) => v.fileName === name && v.fileName !== except, + ), ) } @@ -117,6 +122,7 @@ async function submitFileForm( ref="fileFormComponent" :mode="fileFormType" :error="fileFormError" + :fileNameLabel="fileNameLabel" v-model:open="fileFormState" v-model:title="fileFormData.title" v-model:description="fileFormData.description" @@ -124,7 +130,8 @@ async function submitFileForm( v-model:category="fileFormData.category" @reset="() => (fileFormError = {})" @filechange=" - (name: string) => (fileFormError.fileExist = checkFileExist(name)) + (name: string) => + (fileFormError.fileExist = checkFileExist(name, fileNameLabel)) " @submit="submitFileForm" /> diff --git a/Services/client/src/components/FileItem.vue b/Services/client/src/components/FileItem.vue index 0a14030..1182942 100644 --- a/Services/client/src/components/FileItem.vue +++ b/Services/client/src/components/FileItem.vue @@ -248,6 +248,7 @@ function triggerFileDelete(pathname: string) { category: value.category, }, value.pathname, + value.fileName, ) " @delete="() => triggerFileDelete(value.pathname)" diff --git a/Services/client/src/components/ListView.vue b/Services/client/src/components/ListView.vue index 73080a7..4762cdf 100644 --- a/Services/client/src/components/ListView.vue +++ b/Services/client/src/components/ListView.vue @@ -312,6 +312,7 @@ const onRowClick = ((_, row) => { fileFormComponent?.triggerFileEdit( data.row, data.row.pathname, + data.row.fileName, ) " id="listViewFileEdit"