Browse Source

fix: sync data after copying

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/4514/head
Pranav C 2 years ago
parent
commit
db10f98fad
  1. 42
      packages/nc-gui/components/smartsheet/Grid.vue
  2. 2
      packages/nc-gui/composables/useMultiSelect/index.ts

42
packages/nc-gui/components/smartsheet/Grid.vue

@ -169,16 +169,24 @@ const getContainerScrollForElement = (
}
const { selectCell, startSelectRange, endSelectRange, clearSelectedRange, copyValue, isCellSelected, selectedCell } =
useMultiSelect(fields, data, $$(editEnabled), isPkAvail, clearCell, makeEditable, scrollToCell, (e: KeyboardEvent) => {
// ignore navigating if picker(Date, Time, DateTime, Year)
// or single/multi select options is open
const activePickerOrDropdownEl = document.querySelector(
'.nc-picker-datetime.active,.nc-dropdown-single-select-cell.active,.nc-dropdown-multi-select-cell.active,.nc-picker-date.active,.nc-picker-year.active,.nc-picker-time.active',
)
if (activePickerOrDropdownEl) {
e.preventDefault()
return true
}
useMultiSelect(
fields,
data,
$$(editEnabled),
isPkAvail,
clearCell,
makeEditable,
scrollToCell,
(e: KeyboardEvent) => {
// ignore navigating if picker(Date, Time, DateTime, Year)
// or single/multi select options is open
const activePickerOrDropdownEl = document.querySelector(
'.nc-picker-datetime.active,.nc-dropdown-single-select-cell.active,.nc-dropdown-multi-select-cell.active,.nc-picker-date.active,.nc-picker-year.active,.nc-picker-time.active',
)
if (activePickerOrDropdownEl) {
e.preventDefault()
return true
}
// skip keyboard event handling if there is a drawer / modal
if (isDrawerOrModalExist()) {
@ -261,7 +269,19 @@ const { selectCell, startSelectRange, endSelectRange, clearSelectedRange, copyVa
}
}
}
})
},
async (ctx: { row: number; col: number }) => {
const rowObj = data.value[ctx.row]
const columnObj = fields.value[ctx.col]
if (isVirtualCol(columnObj)) {
return
}
// update/save cell value
await updateOrSaveRow(rowObj, columnObj.title)
},
)
function scrollToCell(row?: number | null, col?: number | null) {
row = row ?? selectedCell.row

2
packages/nc-gui/composables/useMultiSelect/index.ts

@ -47,6 +47,7 @@ export function useMultiSelect(
makeEditable: Function,
scrollToActiveCell?: (row?: number | null, col?: number | null) => void,
keyEventHandler?: Function,
syncCellData?: Function,
) {
const { t } = useI18n()
@ -273,6 +274,7 @@ export function useMultiSelect(
})
e.preventDefault()
makeEditable(rowObj, columnObj)
syncCellData?.(selectedCell)
} else {
clearCell(selectedCell as { row: number; col: number }, true)
makeEditable(rowObj, columnObj)

Loading…
Cancel
Save