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 { try {
// Identify the rows that need to be fetched from the server // Identify the rows that need to be fetched from the server
const rowsToFetch = updateRows.filter((row) => row.rowMeta?.isExistingRow) const rowsToFetch = updateRows.filter((row) => row.rowMeta?.isExistingRow)
const pagesToFetch = Array.from(new Set(rowsToFetch.map((row) => row.rowMeta.page))).filter( const pagesToFetch = Array.from(new Set(rowsToFetch.map((row) => row.rowMeta.page))).filter(
(page): page is number => page !== undefined && page !== paginationData.value.page, (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 getPk = (row: Row) => extractPkFromRow(row.row, metaValue?.columns as ColumnType[])
const ogUpdateRows = updateRows.map((row) => { const ogUpdateRows = updateRows.map((row) => {
if (row.rowMeta?.page && row.rowMeta.page !== paginationData.value.page) { if (row.rowMeta?.isExistingRow) {
const fetchedRow = fetchedData[row.rowMeta.page]?.[row.rowMeta.rowInPage!] const fetchedRow = fetchedData[row.rowMeta.page!]?.[row.rowMeta.rowInPage!]
return fetchedRow ? clone(fetchedRow) : row return fetchedRow ? clone(fetchedRow) : row
} }
const currentPageRow = formattedData.value.find((formattedRow) => getPk(formattedRow) === getPk(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 availableRowsToUpdate = Math.max(0, totalRows - totalRowsBeforeActiveCell)
const rowsToAdd = Math.max(0, selectionRowCount - availableRowsToUpdate) const rowsToAdd = Math.max(0, selectionRowCount - availableRowsToUpdate)
const unreffedData = unref(data).slice(activeCell.row, activeCell.row + selectionRowCount)
const rowsInCurrentPage = unref(data).length const rowsInCurrentPage = unref(data).length
const rowsAffectedInCurrentPage = Math.min(selectionRowCount, rowsInCurrentPage - activeCell.row) const rowsAffectedInCurrentPage = Math.min(selectionRowCount, rowsInCurrentPage - activeCell.row)
const rowsAffectedInOtherPages = Math.max(0, selectionRowCount - rowsAffectedInCurrentPage) const rowsAffectedInOtherPages = Math.max(0, selectionRowCount - rowsAffectedInCurrentPage)
@ -882,8 +884,8 @@ export function useMultiSelect(
if (i < availableRowsToUpdate) { if (i < availableRowsToUpdate) {
const absoluteRowIndex = totalRowsBeforeActiveCell + i const absoluteRowIndex = totalRowsBeforeActiveCell + i
targetRow = targetRow =
i < unref(data).length i < unreffedData.length
? unref(data)[i] ? unreffedData[i]
: { : {
row: {}, row: {},
oldRow: {}, oldRow: {},

Loading…
Cancel
Save