Browse Source

fix: column dragoffset

pull/9901/head
DarkPhoenix2704 4 days ago
parent
commit
2318d9399e
  1. 2
      packages/nc-gui/components/smartsheet/PlainCell.vue
  2. 9
      packages/nc-gui/components/smartsheet/calendar/DayView/DateField.vue
  3. 4
      packages/nc-gui/components/smartsheet/calendar/RecordCard.vue
  4. 28
      packages/nc-gui/components/smartsheet/calendar/WeekView/DateField.vue

2
packages/nc-gui/components/smartsheet/PlainCell.vue

@ -376,6 +376,8 @@ const parseValue = (value: any, col: ColumnType): string => {
&::before { &::before {
content: '•'; content: '•';
padding: 0 4px; padding: 0 4px;
display: inline-block;
text-decoration: none !important;
} }
&:first-child::before { &:first-child::before {
content: ''; content: '';

9
packages/nc-gui/components/smartsheet/calendar/DayView/DateField.vue

@ -45,7 +45,14 @@ const recordsAcrossAllRange = computed<Row[]>(() => {
const fromCol = range.fk_from_col const fromCol = range.fk_from_col
const endCol = range.fk_to_col const endCol = range.fk_to_col
if (fromCol && endCol) { if (fromCol && endCol) {
for (const record of formattedData.value) { const filteredData = formattedData.value.filter((record) => {
const startDate = dayjs(record.row[fromCol.title!])
const endDate = dayjs(record.row[endCol.title!])
return startDate.isSameOrBefore(endDate, 'day')
})
for (const record of filteredData) {
const startDate = dayjs(record.row[fromCol.title!]) const startDate = dayjs(record.row[fromCol.title!])
const endDate = dayjs(record.row[endCol.title!]) const endDate = dayjs(record.row[endCol.title!])

4
packages/nc-gui/components/smartsheet/calendar/RecordCard.vue

@ -71,7 +71,7 @@ const emit = defineEmits(['resize-start'])
></div> ></div>
<div class="overflow-hidden items-center justify-center gap-2 flex w-full"> <div class="overflow-hidden items-center justify-center gap-2 flex w-full">
<span v-if="position === 'rightRounded' || position === 'none'" class="ml-2"> .... </span> <span v-if="position === 'rightRounded' || position === 'none'" class="ml-2 mb-0.6"> .... </span>
<slot name="time" /> <slot name="time" />
<div <div
:class="{ :class="{
@ -91,7 +91,7 @@ const emit = defineEmits(['resize-start'])
</template> </template>
</NcTooltip> </NcTooltip>
</div> </div>
<span v-if="position === 'leftRounded' || position === 'none'" class="absolute my-0 z-10 right-5"> .... </span> <span v-if="position === 'leftRounded' || position === 'none'" class="absolute mb-0.6 z-10 right-5"> .... </span>
</div> </div>
<div <div

28
packages/nc-gui/components/smartsheet/calendar/WeekView/DateField.vue

@ -169,7 +169,12 @@ const calendarData = computed(() => {
.filter((r) => { .filter((r) => {
const startDate = dayjs(r.row[fk_from_col.title!]) const startDate = dayjs(r.row[fk_from_col.title!])
const endDate = dayjs(r.row[fk_to_col.title!]) const endDate = dayjs(r.row[fk_to_col.title!])
return startDate.isValid() && endDate.isValid() && !endDate.isBefore(startDate) return (
startDate.isValid() &&
endDate.isValid() &&
!endDate.isBefore(startDate) &&
!endDate.isBefore(selectedDateRange.value.start, 'day')
)
}) })
.forEach(processRecord) .forEach(processRecord)
} else { } else {
@ -294,16 +299,16 @@ const dragOffset = ref<{
// This method is used to calculate the new start and end date of a record when dragging and dropping // This method is used to calculate the new start and end date of a record when dragging and dropping
const calculateNewRow = (event: MouseEvent, updateSideBarData?: boolean) => { const calculateNewRow = (event: MouseEvent, updateSideBarData?: boolean) => {
const { width, left } = container.value.getBoundingClientRect() const { width, left } = container.value?.getBoundingClientRect()
// Calculate the percentage of the width based on the mouse position // Calculate the percentage of the width based on the mouse position
// This is used to calculate the day index // This is used to calculate the day index
let relativeX = event.clientX - left const relativeX = event.clientX - left
if (dragOffset.value.x) { /* if (dragOffset.value.x && dragRecord.value?.rowMeta.spanningDays === 1) {
relativeX -= dragOffset.value.x relativeX -= dragOffset.value.x
} } */
const percentX = relativeX / width const percentX = relativeX / width
@ -377,6 +382,8 @@ const calculateNewRow = (event: MouseEvent, updateSideBarData?: boolean) => {
const onDrag = (event: MouseEvent) => { const onDrag = (event: MouseEvent) => {
if (!isUIAllowed('dataEdit')) return if (!isUIAllowed('dataEdit')) return
if (!container.value || !dragRecord.value) return if (!container.value || !dragRecord.value) return
event.preventDefault()
calculateNewRow(event, false) calculateNewRow(event, false)
} }
@ -402,10 +409,16 @@ const stopDrag = (event: MouseEvent) => {
dragElement.value.style.boxShadow = 'none' dragElement.value.style.boxShadow = 'none'
dragElement.value = null dragElement.value = null
} }
dragRecord.value = undefined dragRecord.value = undefined
updateRowProperty(newRow, updateProperty, false) updateRowProperty(newRow, updateProperty, false)
dragOffset.value = {
x: null,
y: null,
}
document.removeEventListener('mousemove', onDrag) document.removeEventListener('mousemove', onDrag)
document.removeEventListener('mouseup', stopDrag) document.removeEventListener('mouseup', stopDrag)
} }
@ -482,11 +495,6 @@ const dropEvent = (event: DragEvent) => {
} }
updateRowProperty(newRow, updateProperty, false) updateRowProperty(newRow, updateProperty, false)
dragOffset.value = {
x: null,
y: null,
}
$e('c:calendar:day:drag-record') $e('c:calendar:day:drag-record')
} }
} }

Loading…
Cancel
Save