|
|
@ -22,6 +22,7 @@ import { |
|
|
|
extractPkFromRow, |
|
|
|
extractPkFromRow, |
|
|
|
inject, |
|
|
|
inject, |
|
|
|
isColumnRequiredAndNull, |
|
|
|
isColumnRequiredAndNull, |
|
|
|
|
|
|
|
isMac, |
|
|
|
message, |
|
|
|
message, |
|
|
|
onBeforeUnmount, |
|
|
|
onBeforeUnmount, |
|
|
|
onClickOutside, |
|
|
|
onClickOutside, |
|
|
@ -39,9 +40,7 @@ import { |
|
|
|
useUIPermission, |
|
|
|
useUIPermission, |
|
|
|
useViewData, |
|
|
|
useViewData, |
|
|
|
watch, |
|
|
|
watch, |
|
|
|
isMac, |
|
|
|
|
|
|
|
} from '#imports' |
|
|
|
} from '#imports' |
|
|
|
import { switchAll } from 'rxjs' |
|
|
|
|
|
|
|
import type { Row } from '~/lib' |
|
|
|
import type { Row } from '~/lib' |
|
|
|
import { NavigateDir } from '~/lib' |
|
|
|
import { NavigateDir } from '~/lib' |
|
|
|
|
|
|
|
|
|
|
@ -146,8 +145,8 @@ const getContainerScrollForElement = ( |
|
|
|
relativePos.right + (offset?.right || 0) > 0 |
|
|
|
relativePos.right + (offset?.right || 0) > 0 |
|
|
|
? container.scrollLeft + relativePos.right + (offset?.right || 0) |
|
|
|
? container.scrollLeft + relativePos.right + (offset?.right || 0) |
|
|
|
: relativePos.left - (offset?.left || 0) < 0 |
|
|
|
: relativePos.left - (offset?.left || 0) < 0 |
|
|
|
? container.scrollLeft + relativePos.left - (offset?.left || 0) |
|
|
|
? container.scrollLeft + relativePos.left - (offset?.left || 0) |
|
|
|
: container.scrollLeft |
|
|
|
: container.scrollLeft |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
/* |
|
|
|
* If the element is below the container, scroll down (positive) |
|
|
|
* If the element is below the container, scroll down (positive) |
|
|
@ -163,6 +162,7 @@ const getContainerScrollForElement = ( |
|
|
|
return scroll |
|
|
|
return scroll |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { selectCell, selectBlock, selectedRange, clearRangeRows, startSelectRange, selected } = useMultiSelect( |
|
|
|
const { selectCell, selectBlock, selectedRange, clearRangeRows, startSelectRange, selected } = useMultiSelect( |
|
|
|
fields, |
|
|
|
fields, |
|
|
|
data, |
|
|
|
data, |
|
|
@ -208,50 +208,50 @@ const { selectCell, selectBlock, selectedRange, clearRangeRows, startSelectRange |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
function scrollToCell(row?: number | null, col?: number | null) { |
|
|
|
function scrollToCell(row?: number | null, col?: number | null) { |
|
|
|
row = row ?? selected.row |
|
|
|
row = row ?? selected.row |
|
|
|
col = col ?? selected.col |
|
|
|
col = col ?? selected.col |
|
|
|
if (row !== undefined && col !== undefined && row !== null && col !== null) { |
|
|
|
if (row !== undefined && col !== undefined && row !== null && col !== null) { |
|
|
|
// get active cell |
|
|
|
// get active cell |
|
|
|
const rows = tbodyEl.value?.querySelectorAll('tr') |
|
|
|
const rows = tbodyEl.value?.querySelectorAll('tr') |
|
|
|
const cols = rows?.[row].querySelectorAll('td') |
|
|
|
const cols = rows?.[row].querySelectorAll('td') |
|
|
|
const td = cols?.[col === 0 ? 0 : col + 1] |
|
|
|
const td = cols?.[col === 0 ? 0 : col + 1] |
|
|
|
|
|
|
|
|
|
|
|
if (!td || !gridWrapper.value) return |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { height: headerHeight } = tableHead.value!.getBoundingClientRect() |
|
|
|
|
|
|
|
const tdScroll = getContainerScrollForElement(td, gridWrapper.value, { top: headerHeight, bottom: 9, right: 9 }) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (rows && row === rows.length - 2) { |
|
|
|
|
|
|
|
// if last row make 'Add New Row' visible |
|
|
|
|
|
|
|
gridWrapper.value.scrollTo({ |
|
|
|
|
|
|
|
top: gridWrapper.value.scrollHeight, |
|
|
|
|
|
|
|
left: |
|
|
|
|
|
|
|
cols && col === cols.length - 2 // if corner cell |
|
|
|
|
|
|
|
? gridWrapper.value.scrollWidth |
|
|
|
|
|
|
|
: tdScroll.left, |
|
|
|
|
|
|
|
behavior: 'smooth', |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (cols && col === cols.length - 2) { |
|
|
|
if (!td || !gridWrapper.value) return |
|
|
|
// if last column make 'Add New Column' visible |
|
|
|
|
|
|
|
gridWrapper.value.scrollTo({ |
|
|
|
const { height: headerHeight } = tableHead.value!.getBoundingClientRect() |
|
|
|
top: tdScroll.top, |
|
|
|
const tdScroll = getContainerScrollForElement(td, gridWrapper.value, { top: headerHeight, bottom: 9, right: 9 }) |
|
|
|
left: gridWrapper.value.scrollWidth, |
|
|
|
|
|
|
|
behavior: 'smooth', |
|
|
|
if (rows && row === rows.length - 2) { |
|
|
|
}) |
|
|
|
// if last row make 'Add New Row' visible |
|
|
|
return |
|
|
|
gridWrapper.value.scrollTo({ |
|
|
|
} |
|
|
|
top: gridWrapper.value.scrollHeight, |
|
|
|
|
|
|
|
left: |
|
|
|
|
|
|
|
cols && col === cols.length - 2 // if corner cell |
|
|
|
|
|
|
|
? gridWrapper.value.scrollWidth |
|
|
|
|
|
|
|
: tdScroll.left, |
|
|
|
|
|
|
|
behavior: 'smooth', |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// scroll into the active cell |
|
|
|
if (cols && col === cols.length - 2) { |
|
|
|
|
|
|
|
// if last column make 'Add New Column' visible |
|
|
|
gridWrapper.value.scrollTo({ |
|
|
|
gridWrapper.value.scrollTo({ |
|
|
|
top: tdScroll.top, |
|
|
|
top: tdScroll.top, |
|
|
|
left: tdScroll.left, |
|
|
|
left: gridWrapper.value.scrollWidth, |
|
|
|
behavior: 'smooth', |
|
|
|
behavior: 'smooth', |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// scroll into the active cell |
|
|
|
|
|
|
|
gridWrapper.value.scrollTo({ |
|
|
|
|
|
|
|
top: tdScroll.top, |
|
|
|
|
|
|
|
left: tdScroll.left, |
|
|
|
|
|
|
|
behavior: 'smooth', |
|
|
|
|
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
onMounted(loadGridViewColumns) |
|
|
|
onMounted(loadGridViewColumns) |
|
|
|
|
|
|
|
|
|
|
|