|
|
@ -1,25 +1,32 @@ |
|
|
|
<script setup lang="ts"> |
|
|
|
<script setup lang="ts"> |
|
|
|
import type { ColumnType, TableType } from 'nocodb-sdk' |
|
|
|
import type { ColumnType, TableType, ViewType } from 'nocodb-sdk' |
|
|
|
import { isVirtualCol } from 'nocodb-sdk' |
|
|
|
import { isVirtualCol } from 'nocodb-sdk' |
|
|
|
|
|
|
|
import type { Ref } from 'vue' |
|
|
|
|
|
|
|
import Cell from '../Cell.vue' |
|
|
|
|
|
|
|
import VirtualCell from '../VirtualCell.vue' |
|
|
|
import Comments from './Comments.vue' |
|
|
|
import Comments from './Comments.vue' |
|
|
|
import Header from './Header.vue' |
|
|
|
import Header from './Header.vue' |
|
|
|
import { |
|
|
|
import { |
|
|
|
|
|
|
|
FieldsInj, |
|
|
|
|
|
|
|
IsFormInj, |
|
|
|
|
|
|
|
MetaInj, |
|
|
|
|
|
|
|
NOCO, |
|
|
|
computedInject, |
|
|
|
computedInject, |
|
|
|
|
|
|
|
extractPkFromRow, |
|
|
|
provide, |
|
|
|
provide, |
|
|
|
|
|
|
|
ref, |
|
|
|
toRef, |
|
|
|
toRef, |
|
|
|
useNuxtApp, |
|
|
|
useNuxtApp, |
|
|
|
|
|
|
|
useProject, |
|
|
|
useProvideExpandedFormStore, |
|
|
|
useProvideExpandedFormStore, |
|
|
|
useProvideSmartsheetStore, |
|
|
|
useProvideSmartsheetStore, |
|
|
|
useVModel, |
|
|
|
useVModel, |
|
|
|
watch, |
|
|
|
watch, |
|
|
|
} from '#imports' |
|
|
|
} from '#imports' |
|
|
|
import { NOCO } from '~/lib' |
|
|
|
|
|
|
|
import { extractPkFromRow } from '~/utils' |
|
|
|
|
|
|
|
import type { Row } from '~/composables' |
|
|
|
import type { Row } from '~/composables' |
|
|
|
import { FieldsInj, IsFormInj, MetaInj } from '~/context' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
interface Props { |
|
|
|
interface Props { |
|
|
|
modelValue: string | null |
|
|
|
modelValue?: boolean |
|
|
|
row: Row |
|
|
|
row: Row |
|
|
|
state?: Record<string, any> | null |
|
|
|
state?: Record<string, any> | null |
|
|
|
meta: TableType |
|
|
|
meta: TableType |
|
|
@ -28,9 +35,13 @@ interface Props { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const props = defineProps<Props>() |
|
|
|
const props = defineProps<Props>() |
|
|
|
|
|
|
|
|
|
|
|
const emits = defineEmits(['update:modelValue']) |
|
|
|
const emits = defineEmits(['update:modelValue']) |
|
|
|
|
|
|
|
|
|
|
|
const row = toRef(props, 'row') |
|
|
|
const row = toRef(props, 'row') |
|
|
|
|
|
|
|
|
|
|
|
const state = toRef(props, 'state') |
|
|
|
const state = toRef(props, 'state') |
|
|
|
|
|
|
|
|
|
|
|
const meta = toRef(props, 'meta') |
|
|
|
const meta = toRef(props, 'meta') |
|
|
|
|
|
|
|
|
|
|
|
const fields = computedInject(FieldsInj, (_fields) => { |
|
|
|
const fields = computedInject(FieldsInj, (_fields) => { |
|
|
@ -45,25 +56,26 @@ provide(MetaInj, meta) |
|
|
|
const { commentsDrawer, changedColumns, state: rowState } = useProvideExpandedFormStore(meta, row) |
|
|
|
const { commentsDrawer, changedColumns, state: rowState } = useProvideExpandedFormStore(meta, row) |
|
|
|
|
|
|
|
|
|
|
|
const { $api } = useNuxtApp() |
|
|
|
const { $api } = useNuxtApp() |
|
|
|
|
|
|
|
|
|
|
|
if (props.loadRow) { |
|
|
|
if (props.loadRow) { |
|
|
|
const { project } = useProject() |
|
|
|
const { project } = useProject() |
|
|
|
|
|
|
|
|
|
|
|
row.value.row = await $api.dbTableRow.read( |
|
|
|
row.value.row = await $api.dbTableRow.read( |
|
|
|
NOCO, |
|
|
|
NOCO, |
|
|
|
project.value.id as string, |
|
|
|
project.value.id as string, |
|
|
|
meta.value.title, |
|
|
|
meta.value.title, |
|
|
|
extractPkFromRow(row.value.row, meta.value.columns as ColumnType[]), |
|
|
|
extractPkFromRow(row.value.row, meta.value.columns as ColumnType[]), |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
row.value.oldRow = { ...row.value.row } |
|
|
|
row.value.oldRow = { ...row.value.row } |
|
|
|
|
|
|
|
|
|
|
|
row.value.rowMeta = {} |
|
|
|
row.value.rowMeta = {} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
useProvideSmartsheetStore(ref({}) as any, meta) |
|
|
|
useProvideSmartsheetStore(ref({}) as Ref<ViewType>, meta) |
|
|
|
|
|
|
|
|
|
|
|
provide(IsFormInj, ref(true)) |
|
|
|
provide(IsFormInj, ref(true)) |
|
|
|
|
|
|
|
|
|
|
|
// accept as a prop |
|
|
|
|
|
|
|
// const row: Row = { row: {}, rowMeta: {}, oldRow: {} } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
watch( |
|
|
|
watch( |
|
|
|
state, |
|
|
|
state, |
|
|
|
() => { |
|
|
|
() => { |
|
|
@ -76,7 +88,15 @@ watch( |
|
|
|
{ immediate: true }, |
|
|
|
{ immediate: true }, |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
const isExpanded = useVModel(props, 'modelValue', emits) |
|
|
|
const isExpanded = useVModel(props, 'modelValue', emits, { |
|
|
|
|
|
|
|
defaultValue: false, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<script lang="ts"> |
|
|
|
|
|
|
|
export default { |
|
|
|
|
|
|
|
name: 'ExpandedForm', |
|
|
|
|
|
|
|
} |
|
|
|
</script> |
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
|
|
<template> |
|
|
|
<template> |
|
|
@ -86,13 +106,14 @@ const isExpanded = useVModel(props, 'modelValue', emits) |
|
|
|
<div class="flex h-full nc-form-wrapper items-stretch min-h-[70vh]"> |
|
|
|
<div class="flex h-full nc-form-wrapper items-stretch min-h-[70vh]"> |
|
|
|
<div class="flex-grow overflow-auto scrollbar-thin-primary"> |
|
|
|
<div class="flex-grow overflow-auto scrollbar-thin-primary"> |
|
|
|
<div class="w-[500px] mx-auto"> |
|
|
|
<div class="w-[500px] mx-auto"> |
|
|
|
<div v-for="col in fields" :key="col.title" class="mt-2 py-2" :class="`nc-expand-col-${col.title}`"> |
|
|
|
<div v-for="col of fields" :key="col.title" class="mt-2 py-2" :class="`nc-expand-col-${col.title}`"> |
|
|
|
<SmartsheetHeaderVirtualCell v-if="isVirtualCol(col)" :column="col" /> |
|
|
|
<SmartsheetHeaderVirtualCell v-if="isVirtualCol(col)" :column="col" /> |
|
|
|
<SmartsheetHeaderCell v-else :column="col" /> |
|
|
|
<SmartsheetHeaderCell v-else :column="col" /> |
|
|
|
|
|
|
|
|
|
|
|
<div class="!bg-white rounded px-1 min-h-[35px] flex align-center mt-2"> |
|
|
|
<div class="!bg-white rounded px-1 min-h-[35px] flex align-center mt-2"> |
|
|
|
<SmartsheetVirtualCell v-if="isVirtualCol(col)" v-model="row.row[col.title]" :row="row" :column="col" /> |
|
|
|
<VirtualCell v-if="isVirtualCol(col)" v-model="row.row[col.title]" :row="row" :column="col" /> |
|
|
|
<SmartsheetCell |
|
|
|
|
|
|
|
|
|
|
|
<Cell |
|
|
|
v-else |
|
|
|
v-else |
|
|
|
v-model="row.row[col.title]" |
|
|
|
v-model="row.row[col.title]" |
|
|
|
:column="col" |
|
|
|
:column="col" |
|
|
|