Browse Source

fix: handle paste and specific row

nc-expand-rows
DarkPhoenix2704 2 months ago
parent
commit
ad59db19f8
  1. 5
      packages/nc-gui/composables/useData.ts
  2. 6
      packages/nc-gui/composables/useMultiSelect/index.ts

5
packages/nc-gui/composables/useData.ts

@ -167,7 +167,6 @@ export function useData(args: {
try {
// Identify the rows that need to be fetched from the server
const rowsToFetch = updateRows.filter((row) => row.rowMeta?.isExistingRow)
const pagesToFetch = Array.from(new Set(rowsToFetch.map((row) => row.rowMeta.page))).filter(
(page): page is number => page !== undefined && page !== paginationData.value.page,
@ -187,8 +186,8 @@ export function useData(args: {
const getPk = (row: Row) => extractPkFromRow(row.row, metaValue?.columns as ColumnType[])
const ogUpdateRows = updateRows.map((row) => {
if (row.rowMeta?.page && row.rowMeta.page !== paginationData.value.page) {
const fetchedRow = fetchedData[row.rowMeta.page]?.[row.rowMeta.rowInPage!]
if (row.rowMeta?.isExistingRow) {
const fetchedRow = fetchedData[row.rowMeta.page!]?.[row.rowMeta.rowInPage!]
return fetchedRow ? clone(fetchedRow) : row
}
const currentPageRow = formattedData.value.find((formattedRow) => getPk(formattedRow) === getPk(row))

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

@ -857,6 +857,8 @@ export function useMultiSelect(
const availableRowsToUpdate = Math.max(0, totalRows - totalRowsBeforeActiveCell)
const rowsToAdd = Math.max(0, selectionRowCount - availableRowsToUpdate)
const unreffedData = unref(data).slice(activeCell.row, activeCell.row + selectionRowCount)
const rowsInCurrentPage = unref(data).length
const rowsAffectedInCurrentPage = Math.min(selectionRowCount, rowsInCurrentPage - activeCell.row)
const rowsAffectedInOtherPages = Math.max(0, selectionRowCount - rowsAffectedInCurrentPage)
@ -882,8 +884,8 @@ export function useMultiSelect(
if (i < availableRowsToUpdate) {
const absoluteRowIndex = totalRowsBeforeActiveCell + i
targetRow =
i < unref(data).length
? unref(data)[i]
i < unreffedData.length
? unreffedData[i]
: {
row: {},
oldRow: {},

Loading…
Cancel
Save