feat(context-menu): copy INSERT from selected columns
This commit is contained in:
18 files changed
+551
-49
No files matched your search
@@ -3345,6 +3345,7 @@ const {
|
||||
isSelectingAll,
|
||||
selectedRange,
|
||||
selectedCells,
|
||||
selectedCellMatrix,
|
||||
selectedCellCount,
|
||||
hasCellSelection,
|
||||
clearCellSelection,
|
||||
@@ -4979,6 +4980,11 @@ const {
|
||||
copySelectionCsv,
|
||||
copySelectionJson,
|
||||
copySelectionSqlInList,
|
||||
copySelectionAsInsert,
|
||||
prefetchSelectionAsInsertStatement,
|
||||
canCopyPreparedSelectionInsert,
|
||||
canCopySelectionAsInsert,
|
||||
selectionInsertRowCount,
|
||||
copySelectedRowsTsv,
|
||||
copySelectedRowsTsvWithHeaders,
|
||||
copyColumnNames,
|
||||
@@ -5018,6 +5024,7 @@ const {
|
||||
exportBatchSize: computed(() => settingsStore.editorSettings.exportBatchSize),
|
||||
hasCellSelection,
|
||||
selectedCells,
|
||||
selectedCellMatrix,
|
||||
selectedRange,
|
||||
contextCell: exportContextCell,
|
||||
getRowItem: (rowId: number) => visibleDisplayItems.value.find((item) => item.id === rowId),
|
||||
@@ -6356,6 +6363,7 @@ function onHeaderContext(col: string, columnIndex: number) {
|
||||
}
|
||||
contextHeaderColumn.value = col;
|
||||
contextHeaderColumnIndex.value = columnIndex;
|
||||
void prefetchCopyStatements();
|
||||
}
|
||||
async function copyHeaderColumn() {
|
||||
if (!contextHeaderColumn.value) return;
|
||||
@@ -6568,6 +6576,12 @@ function onRowContext(rowId: number, rowIndex: number) {
|
||||
}
|
||||
|
||||
async function prefetchCopyStatements() {
|
||||
if (canCopySelectionAsInsert.value) {
|
||||
await prefetchSelectionAsInsertStatement();
|
||||
if (selectionInsertRowCount.value > 1 && canCopyPreparedSelectionInsert()) {
|
||||
await prefetchSelectionAsInsertStatement("row-by-row");
|
||||
}
|
||||
}
|
||||
await prefetchRowAsInsertStatement(false);
|
||||
if (isMultiRow.value) {
|
||||
await prefetchRowAsInsertStatement(false, "row-by-row");
|
||||
@@ -7262,6 +7276,13 @@ function copySubmenu(): ContextMenuItem {
|
||||
}
|
||||
|
||||
function selectionSubmenu(): ContextMenuItem {
|
||||
const insertItems: ContextMenuItem[] =
|
||||
selectedCells.value.rows.length > 1
|
||||
? [
|
||||
{ label: t("grid.copySelectionInsertMerged"), action: () => copySelectionAsInsert("merged"), disabled: () => !canCopySelectionAsInsert.value || !canCopyPreparedSelectionInsert("merged") },
|
||||
{ label: t("grid.copySelectionInsertRowByRow"), action: () => copySelectionAsInsert("row-by-row"), disabled: () => !canCopySelectionAsInsert.value || !canCopyPreparedSelectionInsert("row-by-row") },
|
||||
]
|
||||
: [{ label: t("grid.copySelectionInsert"), action: () => copySelectionAsInsert(), disabled: () => !canCopySelectionAsInsert.value || !canCopyPreparedSelectionInsert() }];
|
||||
return {
|
||||
label: t("grid.selection"),
|
||||
icon: SquareDashed,
|
||||
@@ -7271,6 +7292,7 @@ function selectionSubmenu(): ContextMenuItem {
|
||||
{ label: t("grid.copySelectionCsv"), action: copySelectionCsv },
|
||||
{ label: t("grid.copySelectionJson"), action: copySelectionJson },
|
||||
{ label: t("grid.copySelectionSql"), action: copySelectionSqlInList },
|
||||
...insertItems,
|
||||
{ label: "", separator: true },
|
||||
{ label: t("grid.clearSelection"), action: clearCellSelection },
|
||||
],
|
||||
|
||||
Reference in new issue
Block a user