feat: add author field
This commit is contained in:
parent
257a112eae
commit
04f33808d5
3 changed files with 43 additions and 10 deletions
|
|
@ -19,6 +19,7 @@ const props = withDefaults(
|
||||||
description?: string
|
description?: string
|
||||||
keyword?: string[]
|
keyword?: string[]
|
||||||
category?: string[]
|
category?: string[]
|
||||||
|
author?: string
|
||||||
}>(),
|
}>(),
|
||||||
{
|
{
|
||||||
open: false,
|
open: false,
|
||||||
|
|
@ -34,6 +35,7 @@ const emit = defineEmits([
|
||||||
'update:description',
|
'update:description',
|
||||||
'update:keyword',
|
'update:keyword',
|
||||||
'update:category',
|
'update:category',
|
||||||
|
'update:author',
|
||||||
'filechange',
|
'filechange',
|
||||||
'reset',
|
'reset',
|
||||||
'submit',
|
'submit',
|
||||||
|
|
@ -56,6 +58,7 @@ function reset() {
|
||||||
emit('update:description', '')
|
emit('update:description', '')
|
||||||
emit('update:keyword', '')
|
emit('update:keyword', '')
|
||||||
emit('update:category', '')
|
emit('update:category', '')
|
||||||
|
emit('update:author', '')
|
||||||
emit('reset')
|
emit('reset')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -67,6 +70,7 @@ function submit() {
|
||||||
description: props.description ?? '',
|
description: props.description ?? '',
|
||||||
keyword: props.keyword,
|
keyword: props.keyword,
|
||||||
category: props.category,
|
category: props.category,
|
||||||
|
author: props.author,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -165,7 +169,9 @@ const file = ref<File | undefined>()
|
||||||
: ''
|
: ''
|
||||||
"
|
"
|
||||||
id="inputFile"
|
id="inputFile"
|
||||||
:rules="[(v) => (v !== undefined || mode === 'edit' ) || ('โปรดอัปโหลดไฟล์')]"
|
:rules="[
|
||||||
|
(v) => v !== undefined || mode === 'edit' || 'โปรดอัปโหลดไฟล์',
|
||||||
|
]"
|
||||||
>
|
>
|
||||||
<template v-slot:prepend>
|
<template v-slot:prepend>
|
||||||
<q-icon name="attach_file" />
|
<q-icon name="attach_file" />
|
||||||
|
|
@ -181,7 +187,10 @@ const file = ref<File | undefined>()
|
||||||
class="q-my-sm"
|
class="q-my-sm"
|
||||||
placeholder="กรอกชื่อเรื่อง"
|
placeholder="กรอกชื่อเรื่อง"
|
||||||
:model-value="title"
|
:model-value="title"
|
||||||
:rules="[(v) => (v != undefined && v.length > 3) || 'ชื่อต้องยาวกว่า 3 ตัวอักษร']"
|
:rules="[
|
||||||
|
(v) =>
|
||||||
|
(v != undefined && v.length > 3) || 'ชื่อต้องยาวกว่า 3 ตัวอักษร',
|
||||||
|
]"
|
||||||
@update:model-value="(v) => $emit('update:title', v)"
|
@update:model-value="(v) => $emit('update:title', v)"
|
||||||
id="inputTitle"
|
id="inputTitle"
|
||||||
/>
|
/>
|
||||||
|
|
@ -217,7 +226,6 @@ const file = ref<File | undefined>()
|
||||||
@new-value="createCategory"
|
@new-value="createCategory"
|
||||||
:options="filterDataCategory"
|
:options="filterDataCategory"
|
||||||
@filter="filterCategory"
|
@filter="filterCategory"
|
||||||
style="width: 250px"
|
|
||||||
@update:model-value="(v) => $emit('update:category', v)"
|
@update:model-value="(v) => $emit('update:category', v)"
|
||||||
data-testid="filterDataCategory"
|
data-testid="filterDataCategory"
|
||||||
>
|
>
|
||||||
|
|
@ -237,7 +245,6 @@ const file = ref<File | undefined>()
|
||||||
multiple
|
multiple
|
||||||
hide-dropdown-icon
|
hide-dropdown-icon
|
||||||
input-debounce="0"
|
input-debounce="0"
|
||||||
style="width: 250px"
|
|
||||||
:model-value="props.keyword"
|
:model-value="props.keyword"
|
||||||
@update:model-value="(v) => $emit('update:keyword', v)"
|
@update:model-value="(v) => $emit('update:keyword', v)"
|
||||||
@new-value="createKeyword"
|
@new-value="createKeyword"
|
||||||
|
|
@ -247,6 +254,23 @@ const file = ref<File | undefined>()
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<section class="q-mb-md">
|
||||||
|
<span class="text-weight-bold">เจ้าของผลงาน</span>
|
||||||
|
<q-input
|
||||||
|
outlined
|
||||||
|
dense
|
||||||
|
class="q-my-sm"
|
||||||
|
placeholder="เจ้าของผลงาน"
|
||||||
|
:model-value="author"
|
||||||
|
:rules="[
|
||||||
|
(v) =>
|
||||||
|
(v != undefined && v.length > 3) || 'ชื่อต้องยาวกว่า 3 ตัวอักษร',
|
||||||
|
]"
|
||||||
|
@update:model-value="(v) => $emit('update:author', v)"
|
||||||
|
id="inputAuthor"
|
||||||
|
/>
|
||||||
|
</section>
|
||||||
|
|
||||||
<section :style="{ display: 'flex', gap: '.5rem' }">
|
<section :style="{ display: 'flex', gap: '.5rem' }">
|
||||||
<q-btn
|
<q-btn
|
||||||
label="บันทึก"
|
label="บันทึก"
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ const fileFormData = ref<{
|
||||||
description?: string
|
description?: string
|
||||||
keyword?: string[]
|
keyword?: string[]
|
||||||
category?: string[]
|
category?: string[]
|
||||||
|
author?: string
|
||||||
}>({})
|
}>({})
|
||||||
const fileFormType = ref<'edit' | 'create'>('create')
|
const fileFormType = ref<'edit' | 'create'>('create')
|
||||||
const fileFormError = ref<{ fileExist?: boolean; fileName2Long?: boolean }>({})
|
const fileFormError = ref<{ fileExist?: boolean; fileName2Long?: boolean }>({})
|
||||||
|
|
@ -68,7 +69,7 @@ function checkFileExist(name: string, except?: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkFileName2Long(name: string, except?: string) {
|
function checkFileName2Long(name: string, except?: string) {
|
||||||
return Boolean(name.length > 85)
|
return name !== except && Boolean(name.length > 85)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function submitFileForm(
|
async function submitFileForm(
|
||||||
|
|
@ -79,6 +80,7 @@ async function submitFileForm(
|
||||||
description: string
|
description: string
|
||||||
keyword: string[]
|
keyword: string[]
|
||||||
category: string[]
|
category: string[]
|
||||||
|
author: string
|
||||||
},
|
},
|
||||||
force = false,
|
force = false,
|
||||||
) {
|
) {
|
||||||
|
|
@ -101,6 +103,7 @@ async function submitFileForm(
|
||||||
description: value.description,
|
description: value.description,
|
||||||
keyword: value.keyword,
|
keyword: value.keyword,
|
||||||
category: value.category,
|
category: value.category,
|
||||||
|
author: value.author,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
await updateFile(
|
await updateFile(
|
||||||
|
|
@ -110,6 +113,7 @@ async function submitFileForm(
|
||||||
description: value.description,
|
description: value.description,
|
||||||
keyword: value.keyword,
|
keyword: value.keyword,
|
||||||
category: value.category,
|
category: value.category,
|
||||||
|
author: value.author,
|
||||||
},
|
},
|
||||||
value.file,
|
value.file,
|
||||||
)
|
)
|
||||||
|
|
@ -132,11 +136,15 @@ async function submitFileForm(
|
||||||
v-model:description="fileFormData.description"
|
v-model:description="fileFormData.description"
|
||||||
v-model:keyword="fileFormData.keyword"
|
v-model:keyword="fileFormData.keyword"
|
||||||
v-model:category="fileFormData.category"
|
v-model:category="fileFormData.category"
|
||||||
|
v-model:author="fileFormData.author"
|
||||||
@reset="() => (fileFormError = {})"
|
@reset="() => (fileFormError = {})"
|
||||||
@filechange="
|
@filechange="
|
||||||
(name: string) => {
|
(name: string) => {
|
||||||
;(fileFormError.fileExist = checkFileExist(name, fileNameLabel)),
|
;(fileFormError.fileExist = checkFileExist(name, fileNameLabel)),
|
||||||
(fileFormError.fileName2Long = checkFileName2Long(name, fileNameLabel))
|
(fileFormError.fileName2Long = checkFileName2Long(
|
||||||
|
name,
|
||||||
|
fileNameLabel,
|
||||||
|
))
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
@submit="submitFileForm"
|
@submit="submitFileForm"
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ export interface StorageFile {
|
||||||
fileType: string
|
fileType: string
|
||||||
title: string
|
title: string
|
||||||
description: string
|
description: string
|
||||||
author: string,
|
author: string
|
||||||
metadata: Record<string, unknown>
|
metadata: Record<string, unknown>
|
||||||
category: string[]
|
category: string[]
|
||||||
keyword: string[]
|
keyword: string[]
|
||||||
|
|
@ -393,6 +393,7 @@ const useStorage = defineStore('storageStore', () => {
|
||||||
description?: string
|
description?: string
|
||||||
category?: string[]
|
category?: string[]
|
||||||
keyword?: string[]
|
keyword?: string[]
|
||||||
|
author?: string
|
||||||
}
|
}
|
||||||
async function createFile(
|
async function createFile(
|
||||||
file: File,
|
file: File,
|
||||||
|
|
@ -441,9 +442,9 @@ const useStorage = defineStore('storageStore', () => {
|
||||||
},
|
},
|
||||||
to: file?.name
|
to: file?.name
|
||||||
? {
|
? {
|
||||||
file: file.name,
|
file: file.name,
|
||||||
path: arr,
|
path: arr,
|
||||||
}
|
}
|
||||||
: undefined,
|
: undefined,
|
||||||
upload: !!file,
|
upload: !!file,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue