mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
175 lines
4.1 KiB
175 lines
4.1 KiB
2 years ago
|
<script setup lang="ts">
|
||
2 years ago
|
import type { ColumnType, TableType, ViewType } from 'nocodb-sdk'
|
||
2 years ago
|
import { isSystemColumn, isVirtualCol } from 'nocodb-sdk'
|
||
2 years ago
|
import type { Ref } from 'vue'
|
||
|
import Cell from '../Cell.vue'
|
||
|
import VirtualCell from '../VirtualCell.vue'
|
||
2 years ago
|
import Comments from './Comments.vue'
|
||
|
import Header from './Header.vue'
|
||
2 years ago
|
import {
|
||
2 years ago
|
FieldsInj,
|
||
|
IsFormInj,
|
||
|
MetaInj,
|
||
|
NOCO,
|
||
2 years ago
|
computedInject,
|
||
2 years ago
|
extractPkFromRow,
|
||
2 years ago
|
provide,
|
||
2 years ago
|
ref,
|
||
2 years ago
|
toRef,
|
||
|
useNuxtApp,
|
||
2 years ago
|
useProject,
|
||
2 years ago
|
useProvideExpandedFormStore,
|
||
|
useProvideSmartsheetStore,
|
||
|
useVModel,
|
||
|
watch,
|
||
|
} from '#imports'
|
||
2 years ago
|
import type { Row } from '~/composables'
|
||
|
|
||
|
interface Props {
|
||
2 years ago
|
modelValue?: boolean
|
||
2 years ago
|
row: Row
|
||
2 years ago
|
state?: Record<string, any> | null
|
||
2 years ago
|
meta: TableType
|
||
|
loadRow?: boolean
|
||
2 years ago
|
useMetaFields?: boolean
|
||
2 years ago
|
}
|
||
|
|
||
|
const props = defineProps<Props>()
|
||
2 years ago
|
|
||
2 years ago
|
const emits = defineEmits(['update:modelValue', 'cancel'])
|
||
2 years ago
|
|
||
2 years ago
|
const row = toRef(props, 'row')
|
||
2 years ago
|
|
||
2 years ago
|
const state = toRef(props, 'state')
|
||
2 years ago
|
|
||
2 years ago
|
const meta = toRef(props, 'meta')
|
||
|
|
||
2 years ago
|
const fields = computedInject(FieldsInj, (_fields) => {
|
||
2 years ago
|
if (props.useMetaFields) {
|
||
2 years ago
|
return (meta.value.columns ?? []).filter((col) => !isSystemColumn(col))
|
||
2 years ago
|
}
|
||
2 years ago
|
return _fields?.value ?? []
|
||
2 years ago
|
})
|
||
|
|
||
|
provide(MetaInj, meta)
|
||
|
|
||
2 years ago
|
const { commentsDrawer, changedColumns, state: rowState, isNew } = useProvideExpandedFormStore(meta, row)
|
||
2 years ago
|
|
||
2 years ago
|
const { $api } = useNuxtApp()
|
||
2 years ago
|
|
||
2 years ago
|
if (props.loadRow) {
|
||
|
const { project } = useProject()
|
||
2 years ago
|
|
||
2 years ago
|
const { sharedView } = useSharedView() as Record<string, any>
|
||
|
|
||
2 years ago
|
row.value.row = await $api.dbTableRow.read(
|
||
|
NOCO,
|
||
2 years ago
|
(project?.value?.id || sharedView.value.view.project_id) as string,
|
||
2 years ago
|
meta.value.title,
|
||
|
extractPkFromRow(row.value.row, meta.value.columns as ColumnType[]),
|
||
|
)
|
||
2 years ago
|
|
||
2 years ago
|
row.value.oldRow = { ...row.value.row }
|
||
2 years ago
|
|
||
2 years ago
|
row.value.rowMeta = {}
|
||
|
}
|
||
2 years ago
|
|
||
2 years ago
|
useProvideSmartsheetStore(ref({}) as Ref<ViewType>, meta)
|
||
2 years ago
|
|
||
2 years ago
|
provide(IsFormInj, ref(true))
|
||
2 years ago
|
|
||
2 years ago
|
watch(
|
||
|
state,
|
||
|
() => {
|
||
|
if (state.value) {
|
||
|
rowState.value = state.value
|
||
|
} else {
|
||
|
rowState.value = {}
|
||
|
}
|
||
|
},
|
||
|
{ immediate: true },
|
||
|
)
|
||
2 years ago
|
|
||
2 years ago
|
const isExpanded = useVModel(props, 'modelValue', emits, {
|
||
|
defaultValue: false,
|
||
|
})
|
||
2 years ago
|
|
||
|
const onClose = () => {
|
||
2 years ago
|
if (row.value?.rowMeta?.new) emits('cancel')
|
||
2 years ago
|
isExpanded.value = false
|
||
|
}
|
||
2 years ago
|
</script>
|
||
|
|
||
|
<script lang="ts">
|
||
|
export default {
|
||
|
name: 'ExpandedForm',
|
||
|
}
|
||
2 years ago
|
</script>
|
||
|
|
||
|
<template>
|
||
2 years ago
|
<a-drawer
|
||
|
v-model:visible="isExpanded"
|
||
|
:footer="null"
|
||
|
width="min(90vw,1000px)"
|
||
|
:body-style="{ 'padding': 0, 'display': 'flex', 'flex-direction': 'column' }"
|
||
|
:closable="false"
|
||
|
>
|
||
2 years ago
|
<Header @cancel="onClose" />
|
||
2 years ago
|
<div class="!bg-gray-100 rounded flex-1">
|
||
|
<div class="flex h-full nc-form-wrapper items-stretch min-h-[max(70vh,100%)]">
|
||
2 years ago
|
<div class="flex-1 overflow-auto scrollbar-thin-dull">
|
||
2 years ago
|
<div class="w-[500px] mx-auto">
|
||
2 years ago
|
<div v-for="col of fields" :key="col.title" class="mt-2 py-2" :class="`nc-expand-col-${col.title}`">
|
||
2 years ago
|
<SmartsheetHeaderVirtualCell v-if="isVirtualCol(col)" :column="col" />
|
||
2 years ago
|
|
||
2 years ago
|
<SmartsheetHeaderCell v-else :column="col" />
|
||
|
|
||
2 years ago
|
<div class="!bg-white rounded px-1 min-h-[35px] flex items-center mt-2">
|
||
2 years ago
|
<VirtualCell v-if="isVirtualCol(col)" v-model="row.row[col.title]" :row="row" :column="col" />
|
||
|
|
||
|
<Cell
|
||
2 years ago
|
v-else
|
||
|
v-model="row.row[col.title]"
|
||
|
:column="col"
|
||
|
:edit-enabled="true"
|
||
2 years ago
|
@update:model-value="changedColumns.add(col.title)"
|
||
2 years ago
|
/>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
2 years ago
|
<div v-if="!isNew" class="nc-comments-drawer min-w-0 min-h-full max-h-full" :class="{ active: commentsDrawer }">
|
||
2 years ago
|
<div class="h-full">
|
||
2 years ago
|
<Comments v-if="commentsDrawer" />
|
||
2 years ago
|
</div>
|
||
2 years ago
|
</div>
|
||
|
</div>
|
||
2 years ago
|
</div>
|
||
2 years ago
|
</a-drawer>
|
||
2 years ago
|
</template>
|
||
|
|
||
|
<style scoped lang="scss">
|
||
|
:deep(input, select, textarea) {
|
||
|
@apply !bg-white;
|
||
|
}
|
||
|
|
||
|
:deep(.ant-modal-body) {
|
||
2 years ago
|
@apply !bg-gray-100;
|
||
2 years ago
|
}
|
||
|
|
||
|
.nc-comments-drawer {
|
||
|
@apply w-0 transition-width ease-in-out duration-200;
|
||
|
overflow: hidden;
|
||
|
|
||
|
&.active {
|
||
|
@apply w-[250px] border-left-1;
|
||
|
}
|
||
|
}
|
||
2 years ago
|
|
||
|
.nc-form-wrapper {
|
||
2 years ago
|
max-height: max(calc(100vh - 65px), 600px);
|
||
2 years ago
|
height: max-content !important;
|
||
|
}
|
||
2 years ago
|
</style>
|