feat: disable certain field if created from external service
This commit is contained in:
parent
9be4469223
commit
6396618674
4 changed files with 43 additions and 0 deletions
|
|
@ -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<File | undefined>()
|
|||
? 'ไม่สามารถเพิ่มไฟล์ที่ชื่อยาวเกิน 85 ตัวอักษรได้'
|
||||
: ''
|
||||
"
|
||||
:disable="disableFields?.includes('file')"
|
||||
id="inputFile"
|
||||
:rules="[
|
||||
(v) => v !== undefined || mode === 'edit' || 'โปรดอัปโหลดไฟล์',
|
||||
|
|
@ -186,6 +214,7 @@ const file = ref<File | undefined>()
|
|||
dense
|
||||
class="q-my-sm"
|
||||
placeholder="กรอกชื่อเรื่อง"
|
||||
:disable="disableFields?.includes('title')"
|
||||
:model-value="title"
|
||||
:rules="[
|
||||
(v) =>
|
||||
|
|
@ -204,6 +233,7 @@ const file = ref<File | undefined>()
|
|||
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<File | undefined>()
|
|||
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<File | undefined>()
|
|||
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<File | undefined>()
|
|||
dense
|
||||
class="q-my-sm"
|
||||
placeholder="เจ้าของผลงาน"
|
||||
:disable="disableFields?.includes('author')"
|
||||
:model-value="author"
|
||||
:rules="[
|
||||
(v) =>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue