|
|
|
@ -1,8 +1,7 @@
|
|
|
|
|
<script lang="ts" setup> |
|
|
|
|
import dayjs from 'dayjs' |
|
|
|
|
|
|
|
|
|
import { UITypes, isVirtualCol } from 'nocodb-sdk' |
|
|
|
|
import type { Row } from '#imports' |
|
|
|
|
import type { ColumnType } from 'nocodb-sdk' |
|
|
|
|
import { type Row, computed, isPrimary, ref, useViewColumnsOrThrow } from '#imports' |
|
|
|
|
import { generateRandomNumber, isRowEmpty } from '~/utils' |
|
|
|
|
|
|
|
|
|
const emit = defineEmits(['new-record', 'expandRecord']) |
|
|
|
@ -61,6 +60,22 @@ const resizeDirection = ref<'right' | 'left'>()
|
|
|
|
|
|
|
|
|
|
const resizeRecord = ref<Row>() |
|
|
|
|
|
|
|
|
|
const fields = inject(FieldsInj, ref()) |
|
|
|
|
|
|
|
|
|
const { fields: _fields } = useViewColumnsOrThrow() |
|
|
|
|
|
|
|
|
|
const getFieldStyle = (field: ColumnType) => { |
|
|
|
|
const fi = _fields.value.find((f) => f.title === field.title) |
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
underline: fi.underline, |
|
|
|
|
bold: fi.bold, |
|
|
|
|
italic: fi.italic, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const fieldsWithoutDisplay = computed(() => fields.value.filter((f) => !isPrimary(f))) |
|
|
|
|
|
|
|
|
|
const dates = computed(() => { |
|
|
|
|
const startOfMonth = selectedMonth.value.startOf('month') |
|
|
|
|
const endOfMonth = selectedMonth.value.endOf('month') |
|
|
|
@ -366,7 +381,6 @@ const calculateNewRow = (event: MouseEvent, updateSideBar?: boolean) => {
|
|
|
|
|
endDate = newStartDate.clone() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
dragRecord.value = undefined |
|
|
|
|
newRow.row[toCol!.title!] = dayjs(endDate).format('YYYY-MM-DD HH:mm:ssZ') |
|
|
|
|
updateProperty.push(toCol!.title!) |
|
|
|
|
} |
|
|
|
@ -490,11 +504,14 @@ const onResizeStart = (direction: 'right' | 'left', event: MouseEvent, record: R
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const stopDrag = (event: MouseEvent) => { |
|
|
|
|
clearTimeout(dragTimeout.value) |
|
|
|
|
|
|
|
|
|
console.log('stopDrag') |
|
|
|
|
console.log('stopDrag', dragRecord.value, isDragging.value) |
|
|
|
|
if (!isUIAllowed('dataEdit') || !dragRecord.value || !isDragging.value) return |
|
|
|
|
|
|
|
|
|
console.log('stopDrag') |
|
|
|
|
event.preventDefault() |
|
|
|
|
clearTimeout(dragTimeout.value) |
|
|
|
|
|
|
|
|
|
dragElement.value!.style.boxShadow = 'none' |
|
|
|
|
|
|
|
|
|
const { newRow, updateProperty } = calculateNewRow(event, false) |
|
|
|
@ -772,27 +789,25 @@ const isDateSelected = (date: dayjs.Dayjs) => {
|
|
|
|
|
@dblclick.stop="emit('expand-record', record)" |
|
|
|
|
> |
|
|
|
|
<template v-if="!isRowEmpty(record, displayField)"> |
|
|
|
|
<div |
|
|
|
|
:class="{ |
|
|
|
|
'mt-1.4': displayField!.uidt === UITypes.SingleLineText, |
|
|
|
|
'mt-1': displayField!.uidt === UITypes.MultiSelect || displayField!.uidt === UITypes.SingleSelect, |
|
|
|
|
}" |
|
|
|
|
> |
|
|
|
|
<LazySmartsheetVirtualCell |
|
|
|
|
v-if="isVirtualCol(displayField!)" |
|
|
|
|
<LazySmartsheetCalendarCell |
|
|
|
|
v-if="!isRowEmpty(record, displayField!)" |
|
|
|
|
v-model="record.row[displayField!.title!]" |
|
|
|
|
:bold="getFieldStyle(displayField).bold" |
|
|
|
|
:column="displayField" |
|
|
|
|
:row="record" |
|
|
|
|
:italic="getFieldStyle(displayField).italic" |
|
|
|
|
:underline="getFieldStyle(displayField).underline" |
|
|
|
|
/> |
|
|
|
|
|
|
|
|
|
<LazySmartsheetCell |
|
|
|
|
v-else |
|
|
|
|
v-model="record.row[displayField!.title!]" |
|
|
|
|
:column="displayField" |
|
|
|
|
:edit-enabled="false" |
|
|
|
|
:read-only="true" |
|
|
|
|
</template> |
|
|
|
|
<template v-for="(field, id) in fieldsWithoutDisplay"> |
|
|
|
|
<LazySmartsheetCalendarCell |
|
|
|
|
v-if="!isRowEmpty(record, field)" |
|
|
|
|
:key="id" |
|
|
|
|
v-model="record.row[field!.title!]" |
|
|
|
|
:bold="getFieldStyle(field).bold" |
|
|
|
|
:column="field" |
|
|
|
|
:italic="getFieldStyle(field).italic" |
|
|
|
|
:underline="getFieldStyle(field).underline" |
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
</template> |
|
|
|
|
</LazySmartsheetCalendarRecordCard> |
|
|
|
|
</LazySmartsheetRow> |
|
|
|
@ -802,11 +817,6 @@ const isDateSelected = (date: dayjs.Dayjs) => {
|
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped> |
|
|
|
|
.hide { |
|
|
|
|
transition: 0.01s; |
|
|
|
|
transform: translateX(-9999px); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
.prevent-select { |
|
|
|
|
-webkit-user-select: none; /* Safari */ |
|
|
|
|
-ms-user-select: none; /* IE 10 and IE 11 */ |
|
|
|
|