diff --git a/Services/client/src/components/FileForm.vue b/Services/client/src/components/FileForm.vue index c9f545c..8705164 100644 --- a/Services/client/src/components/FileForm.vue +++ b/Services/client/src/components/FileForm.vue @@ -13,6 +13,14 @@ const props = withDefaults( fileExist?: boolean fileName2Long?: boolean } + disableFields?: ( + | 'file' + | 'title' + | 'description' + | 'keyword' + | 'category' + | 'author' + )[] mode: 'create' | 'edit' fileNameLabel?: string title?: string @@ -63,6 +71,25 @@ function reset() { } function submit() { + if (props.mode === 'edit') { + return emit('submit', { + mode: props.mode, + file: props.disableFields?.includes('file') ? undefined : file.value, + title: props.disableFields?.includes('title') ? undefined : props.title, + description: props.disableFields?.includes('description') + ? undefined + : props.description ?? '', + keyword: props.disableFields?.includes('keyword') + ? undefined + : props.keyword, + category: props.disableFields?.includes('category') + ? undefined + : props.category, + author: props.disableFields?.includes('author') + ? undefined + : props.author, + }) + } emit('submit', { mode: props.mode, file: file.value, @@ -168,6 +195,7 @@ const file = ref() ? 'ไม่สามารถเพิ่มไฟล์ที่ชื่อยาวเกิน 85 ตัวอักษรได้' : '' " + :disable="disableFields?.includes('file')" id="inputFile" :rules="[ (v) => v !== undefined || mode === 'edit' || 'โปรดอัปโหลดไฟล์', @@ -186,6 +214,7 @@ const file = ref() dense class="q-my-sm" placeholder="กรอกชื่อเรื่อง" + :disable="disableFields?.includes('title')" :model-value="title" :rules="[ (v) => @@ -204,6 +233,7 @@ const file = ref() class="q-mt-sm no-resize" type="textarea" placeholder="กรอกรายละเอียด" + :disable="disableFields?.includes('description')" :model-value="description" @update:model-value="(v) => $emit('update:description', v)" id="inputDescription" @@ -224,6 +254,7 @@ const file = ref() multiple input-debounce="0" @new-value="createCategory" + :disable="disableFields?.includes('category')" :options="filterDataCategory" @filter="filterCategory" @update:model-value="(v) => $emit('update:category', v)" @@ -245,6 +276,7 @@ const file = ref() multiple hide-dropdown-icon input-debounce="0" + :disable="disableFields?.includes('keyword')" :model-value="props.keyword" @update:model-value="(v) => $emit('update:keyword', v)" @new-value="createKeyword" @@ -261,6 +293,7 @@ const file = ref() dense class="q-my-sm" placeholder="เจ้าของผลงาน" + :disable="disableFields?.includes('author')" :model-value="author" :rules="[ (v) => diff --git a/Services/client/src/components/FileFormWrapper.vue b/Services/client/src/components/FileFormWrapper.vue index 86198c9..81603f0 100644 --- a/Services/client/src/components/FileFormWrapper.vue +++ b/Services/client/src/components/FileFormWrapper.vue @@ -18,6 +18,7 @@ const fileFormData = ref<{ keyword?: string[] category?: string[] author?: string + metadata?: Record }>({}) const fileFormType = ref<'edit' | 'create'>('create') const fileFormError = ref<{ fileExist?: boolean; fileName2Long?: boolean }>({}) @@ -38,6 +39,7 @@ function triggerFileEdit( keyword: string[] category: string[] author: string + metadata?: Record }, pathname: string, file?: string, @@ -51,6 +53,7 @@ function triggerFileEdit( keyword: value.keyword, category: value.category, author: value.author, + metadata: value.metadata, } fileNameLabel.value = file } @@ -133,6 +136,11 @@ async function submitFileForm( :mode="fileFormType" :error="fileFormError" :fileNameLabel="fileNameLabel" + :disableFields=" + fileFormData.metadata && Object.keys(fileFormData.metadata).length > 1 + ? ['file', 'title', 'author'] + : [] + " v-model:open="fileFormState" v-model:title="fileFormData.title" v-model:description="fileFormData.description" diff --git a/Services/client/src/components/FileItem.vue b/Services/client/src/components/FileItem.vue index aa7fef2..36b921e 100644 --- a/Services/client/src/components/FileItem.vue +++ b/Services/client/src/components/FileItem.vue @@ -247,6 +247,7 @@ function triggerFileDelete(pathname: string) { keyword: value.keyword, category: value.category, author: value.author, + metadata: value.metadata, }, value.pathname, value.fileName, diff --git a/Services/client/src/components/FileSearched.vue b/Services/client/src/components/FileSearched.vue index 36a2f72..f1161bb 100644 --- a/Services/client/src/components/FileSearched.vue +++ b/Services/client/src/components/FileSearched.vue @@ -235,6 +235,7 @@ onMounted(() => { keyword: value.keyword, category: value.category, author: value.author, + metadata: value.metadata, }, value.pathname, value.fileName,