|
|
@ -2,7 +2,7 @@ import type { Ref } from 'vue' |
|
|
|
import { computed } from 'vue' |
|
|
|
import { computed } from 'vue' |
|
|
|
import dayjs from 'dayjs' |
|
|
|
import dayjs from 'dayjs' |
|
|
|
import type { MaybeRef } from '@vueuse/core' |
|
|
|
import type { MaybeRef } from '@vueuse/core' |
|
|
|
import type { ColumnType, LinkToAnotherRecordType, TableType, UserFieldRecordType, ViewType } from 'nocodb-sdk' |
|
|
|
import type { ColumnType, LinkToAnotherRecordType, PaginatedType, TableType, UserFieldRecordType, ViewType } from 'nocodb-sdk' |
|
|
|
import { UITypes, dateFormats, isDateMonthFormat, isSystemColumn, isVirtualCol, timeFormats } from 'nocodb-sdk' |
|
|
|
import { UITypes, dateFormats, isDateMonthFormat, isSystemColumn, isVirtualCol, timeFormats } from 'nocodb-sdk' |
|
|
|
import { parse } from 'papaparse' |
|
|
|
import { parse } from 'papaparse' |
|
|
|
import type { Cell } from './cellRange' |
|
|
|
import type { Cell } from './cellRange' |
|
|
@ -54,6 +54,8 @@ export function useMultiSelect( |
|
|
|
bulkUpdateRows?: Function, |
|
|
|
bulkUpdateRows?: Function, |
|
|
|
fillHandle?: MaybeRef<HTMLElement | undefined>, |
|
|
|
fillHandle?: MaybeRef<HTMLElement | undefined>, |
|
|
|
view?: MaybeRef<ViewType | undefined>, |
|
|
|
view?: MaybeRef<ViewType | undefined>, |
|
|
|
|
|
|
|
paginationData?: MaybeRef<PaginatedType | undefined>, |
|
|
|
|
|
|
|
changePage?: (page: number) => void, |
|
|
|
) { |
|
|
|
) { |
|
|
|
const meta = ref(_meta) |
|
|
|
const meta = ref(_meta) |
|
|
|
|
|
|
|
|
|
|
@ -81,6 +83,8 @@ export function useMultiSelect( |
|
|
|
|
|
|
|
|
|
|
|
const activeView = ref(view) |
|
|
|
const activeView = ref(view) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const paginationDataRef = ref(paginationData) |
|
|
|
|
|
|
|
|
|
|
|
const selectedRange = reactive(new CellRange()) |
|
|
|
const selectedRange = reactive(new CellRange()) |
|
|
|
|
|
|
|
|
|
|
|
const fillRange = reactive(new CellRange()) |
|
|
|
const fillRange = reactive(new CellRange()) |
|
|
@ -971,66 +975,121 @@ export function useMultiSelect( |
|
|
|
addUndo({ |
|
|
|
addUndo({ |
|
|
|
redo: { |
|
|
|
redo: { |
|
|
|
fn: async ( |
|
|
|
fn: async ( |
|
|
|
tableId: string, |
|
|
|
|
|
|
|
columnId: string, |
|
|
|
|
|
|
|
pasteRowPk: string, |
|
|
|
|
|
|
|
result: { link: any[]; unlink: any[] }, |
|
|
|
|
|
|
|
value: number, |
|
|
|
|
|
|
|
activeCell: Cell, |
|
|
|
activeCell: Cell, |
|
|
|
|
|
|
|
col: ColumnType, |
|
|
|
|
|
|
|
row: Row, |
|
|
|
|
|
|
|
pg: PaginatedType, |
|
|
|
|
|
|
|
value: number, |
|
|
|
|
|
|
|
result: { link: any[]; unlink: any[] }, |
|
|
|
) => { |
|
|
|
) => { |
|
|
|
const rowObj = unref(data)[activeCell.row] |
|
|
|
if (paginationDataRef.value?.pageSize === pg?.pageSize) { |
|
|
|
const columnObj = unref(fields)[activeCell.col] |
|
|
|
if (paginationDataRef.value?.page !== pg?.page) { |
|
|
|
|
|
|
|
await changePage?.(pg?.page!) |
|
|
|
await Promise.all([ |
|
|
|
} |
|
|
|
result.link.length && |
|
|
|
const pasteRowPk = extractPkFromRow(row.row, meta.value?.columns as ColumnType[]) |
|
|
|
api.dbDataTableRow.nestedLink(tableId, columnId, encodeURIComponent(pasteRowPk), result.link, { |
|
|
|
const rowObj = unref(data)[activeCell.row] |
|
|
|
viewId: activeView?.value?.id, |
|
|
|
const columnObj = unref(fields)[activeCell.col] |
|
|
|
}), |
|
|
|
if ( |
|
|
|
result.unlink.length && |
|
|
|
pasteRowPk === extractPkFromRow(rowObj.row, meta.value?.columns as ColumnType[]) && |
|
|
|
api.dbDataTableRow.nestedUnlink( |
|
|
|
columnObj.id === col.id |
|
|
|
meta.value?.id as string, |
|
|
|
) { |
|
|
|
columnObj.id as string, |
|
|
|
await Promise.all([ |
|
|
|
encodeURIComponent(pasteRowPk), |
|
|
|
result.link.length && |
|
|
|
result.unlink, |
|
|
|
api.dbDataTableRow.nestedLink( |
|
|
|
{ viewId: activeView?.value?.id }, |
|
|
|
meta.value?.id as string, |
|
|
|
), |
|
|
|
columnObj.id as string, |
|
|
|
]) |
|
|
|
encodeURIComponent(pasteRowPk), |
|
|
|
|
|
|
|
result.link, |
|
|
|
rowObj.row[columnObj.title!] = value |
|
|
|
{ |
|
|
|
|
|
|
|
viewId: activeView?.value?.id, |
|
|
|
await syncCellData?.(activeCell) |
|
|
|
}, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
result.unlink.length && |
|
|
|
|
|
|
|
api.dbDataTableRow.nestedUnlink( |
|
|
|
|
|
|
|
meta.value?.id as string, |
|
|
|
|
|
|
|
columnObj.id as string, |
|
|
|
|
|
|
|
encodeURIComponent(pasteRowPk), |
|
|
|
|
|
|
|
result.unlink, |
|
|
|
|
|
|
|
{ viewId: activeView?.value?.id }, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rowObj.row[columnObj.title!] = value |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await syncCellData?.(activeCell) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
throw new Error(t('msg.recordCouldNotBeFound')) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
throw new Error(t('msg.pageSizeChanged')) |
|
|
|
|
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
args: [meta.value?.id as string, columnObj.id as string, pasteRowPk, result, pasteVal.value, clone(activeCell)], |
|
|
|
args: [ |
|
|
|
|
|
|
|
clone(activeCell), |
|
|
|
|
|
|
|
clone(columnObj), |
|
|
|
|
|
|
|
clone(rowObj), |
|
|
|
|
|
|
|
clone(paginationDataRef.value), |
|
|
|
|
|
|
|
clone(pasteVal.value), |
|
|
|
|
|
|
|
result, |
|
|
|
|
|
|
|
], |
|
|
|
}, |
|
|
|
}, |
|
|
|
undo: { |
|
|
|
undo: { |
|
|
|
fn: async ( |
|
|
|
fn: async ( |
|
|
|
tableId: string, |
|
|
|
|
|
|
|
columnId: string, |
|
|
|
|
|
|
|
pasteRowPk: string, |
|
|
|
|
|
|
|
result: { link: any[]; unlink: any[] }, |
|
|
|
|
|
|
|
value: number, |
|
|
|
|
|
|
|
activeCell: Cell, |
|
|
|
activeCell: Cell, |
|
|
|
|
|
|
|
col: ColumnType, |
|
|
|
|
|
|
|
row: Row, |
|
|
|
|
|
|
|
pg: PaginatedType, |
|
|
|
|
|
|
|
value: number, |
|
|
|
|
|
|
|
result: { link: any[]; unlink: any[] }, |
|
|
|
) => { |
|
|
|
) => { |
|
|
|
const rowObj = unref(data)[activeCell.row] |
|
|
|
if (paginationDataRef.value?.pageSize === pg.pageSize) { |
|
|
|
const columnObj = unref(fields)[activeCell.col] |
|
|
|
if (paginationDataRef.value?.page !== pg.page) { |
|
|
|
|
|
|
|
await changePage?.(pg.page!) |
|
|
|
await Promise.all([ |
|
|
|
} |
|
|
|
result.unlink.length && |
|
|
|
|
|
|
|
api.dbDataTableRow.nestedLink(tableId, columnId, encodeURIComponent(pasteRowPk), result.unlink), |
|
|
|
const pasteRowPk = extractPkFromRow(row.row, meta.value?.columns as ColumnType[]) |
|
|
|
result.link.length && |
|
|
|
const rowObj = unref(data)[activeCell.row] |
|
|
|
api.dbDataTableRow.nestedUnlink( |
|
|
|
const columnObj = unref(fields)[activeCell.col] |
|
|
|
meta.value?.id as string, |
|
|
|
|
|
|
|
columnObj.id as string, |
|
|
|
if ( |
|
|
|
encodeURIComponent(pasteRowPk), |
|
|
|
pasteRowPk === extractPkFromRow(rowObj.row, meta.value?.columns as ColumnType[]) && |
|
|
|
result.link, |
|
|
|
columnObj.id === col.id |
|
|
|
), |
|
|
|
) { |
|
|
|
]) |
|
|
|
await Promise.all([ |
|
|
|
|
|
|
|
result.unlink.length && |
|
|
|
rowObj.row[columnObj.title!] = value |
|
|
|
api.dbDataTableRow.nestedLink( |
|
|
|
|
|
|
|
meta.value?.id as string, |
|
|
|
await syncCellData?.(activeCell) |
|
|
|
columnObj.id as string, |
|
|
|
|
|
|
|
encodeURIComponent(pasteRowPk), |
|
|
|
|
|
|
|
result.unlink, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
result.link.length && |
|
|
|
|
|
|
|
api.dbDataTableRow.nestedUnlink( |
|
|
|
|
|
|
|
meta.value?.id as string, |
|
|
|
|
|
|
|
columnObj.id as string, |
|
|
|
|
|
|
|
encodeURIComponent(pasteRowPk), |
|
|
|
|
|
|
|
result.link, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rowObj.row[columnObj.title!] = value |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await syncCellData?.(activeCell) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
throw new Error(t('msg.recordCouldNotBeFound')) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
throw new Error(t('msg.pageSizeChanged')) |
|
|
|
|
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
args: [meta.value?.id as string, columnObj.id as string, pasteRowPk, result, oldCellValue, clone(activeCell)], |
|
|
|
args: [ |
|
|
|
|
|
|
|
clone(activeCell), |
|
|
|
|
|
|
|
clone(columnObj), |
|
|
|
|
|
|
|
clone(rowObj), |
|
|
|
|
|
|
|
clone(paginationDataRef.value), |
|
|
|
|
|
|
|
clone(oldCellValue), |
|
|
|
|
|
|
|
result, |
|
|
|
|
|
|
|
], |
|
|
|
}, |
|
|
|
}, |
|
|
|
scope: defineViewScope({ view: activeView?.value }), |
|
|
|
scope: defineViewScope({ view: activeView?.value }), |
|
|
|
}) |
|
|
|
}) |
|
|
|