mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-29 05:16:00 +00:00
export preserves column settings
This commit is contained in:
@@ -570,6 +570,20 @@ export abstract class GridDisplay {
|
|||||||
return sql;
|
return sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getExportColumnMap() {
|
||||||
|
const changesDefined = this.config.hiddenColumns?.length > 0 || this.config.addedColumns?.length > 0;
|
||||||
|
if (this.isDynamicStructure && !changesDefined) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return this.getColumns(null)
|
||||||
|
.filter(col => col.isChecked)
|
||||||
|
.map(col => ({
|
||||||
|
dst: col.headerText,
|
||||||
|
src: col.uniqueName,
|
||||||
|
ignore: !changesDefined,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
resizeColumn(uniqueName: string, computedSize: number, diff: number) {
|
resizeColumn(uniqueName: string, computedSize: number, diff: number) {
|
||||||
this.setConfig(cfg => {
|
this.setConfig(cfg => {
|
||||||
const columnWidths = {
|
const columnWidths = {
|
||||||
|
|||||||
@@ -174,6 +174,7 @@
|
|||||||
initialValues.sourceDatabaseName = database;
|
initialValues.sourceDatabaseName = database;
|
||||||
initialValues.sourceSql = getExportQuery();
|
initialValues.sourceSql = getExportQuery();
|
||||||
initialValues.sourceList = [pureName];
|
initialValues.sourceList = [pureName];
|
||||||
|
initialValues[`columns_${pureName}`] = display.getExportColumnMap();
|
||||||
showModal(ImportExportModal, { initialValues });
|
showModal(ImportExportModal, { initialValues });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,6 +55,7 @@
|
|||||||
import RowsArrayGrider from './RowsArrayGrider';
|
import RowsArrayGrider from './RowsArrayGrider';
|
||||||
|
|
||||||
export let jslid;
|
export let jslid;
|
||||||
|
export let display;
|
||||||
|
|
||||||
export const activator = createActivator('JslDataGridCore', false);
|
export const activator = createActivator('JslDataGridCore', false);
|
||||||
|
|
||||||
@@ -93,10 +94,12 @@
|
|||||||
initialValues.sourceStorageType = 'archive';
|
initialValues.sourceStorageType = 'archive';
|
||||||
initialValues.sourceArchiveFolder = archiveMatch[1];
|
initialValues.sourceArchiveFolder = archiveMatch[1];
|
||||||
initialValues.sourceList = [archiveMatch[2]];
|
initialValues.sourceList = [archiveMatch[2]];
|
||||||
|
initialValues[`columns_${archiveMatch[2]}`] = display.getExportColumnMap();
|
||||||
} else {
|
} else {
|
||||||
initialValues.sourceStorageType = 'jsldata';
|
initialValues.sourceStorageType = 'jsldata';
|
||||||
initialValues.sourceJslId = jslid;
|
initialValues.sourceJslId = jslid;
|
||||||
initialValues.sourceList = ['query-data'];
|
initialValues.sourceList = ['query-data'];
|
||||||
|
initialValues[`columns_query-data`] = display.getExportColumnMap();
|
||||||
}
|
}
|
||||||
showModal(ImportExportModal, { initialValues });
|
showModal(ImportExportModal, { initialValues });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -135,6 +135,7 @@
|
|||||||
initialValues.sourceDatabaseName = database;
|
initialValues.sourceDatabaseName = database;
|
||||||
initialValues.sourceSql = display.getExportQuery();
|
initialValues.sourceSql = display.getExportQuery();
|
||||||
initialValues.sourceList = display.baseTableOrSimilar ? [display.baseTableOrSimilar.pureName] : [];
|
initialValues.sourceList = display.baseTableOrSimilar ? [display.baseTableOrSimilar.pureName] : [];
|
||||||
|
initialValues[`columns_${pureName}`] = display.getExportColumnMap();
|
||||||
showModal(ImportExportModal, { initialValues });
|
showModal(ImportExportModal, { initialValues });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -186,10 +186,16 @@ export default async function createImpExpScript(extensions, values, addEditorIn
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
script.assign(targetVar, ...getTargetExpr(extensions, sourceName, values, targetConnection, targetDriver));
|
script.assign(targetVar, ...getTargetExpr(extensions, sourceName, values, targetConnection, targetDriver));
|
||||||
|
|
||||||
const colmap = (values[`columns_${sourceName}`] || []).filter(x => !x.skip);
|
let colmap = values[`columns_${sourceName}`] || [];
|
||||||
|
if (!colmap.find(x => !x.ignore)) {
|
||||||
|
// all values are ignored, ignore column map
|
||||||
|
colmap = [];
|
||||||
|
}
|
||||||
|
colmap = colmap.filter(x => !x.skip);
|
||||||
let colmapVar = null;
|
let colmapVar = null;
|
||||||
if (colmap.length > 0) {
|
if (colmap.length > 0) {
|
||||||
colmapVar = script.allocVariable();
|
colmapVar = script.allocVariable();
|
||||||
|
colmap = colmap.map(x => _.omit(x, ['ignore']));
|
||||||
script.assignValue(colmapVar, colmap);
|
script.assignValue(colmapVar, colmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,19 +36,22 @@
|
|||||||
<svelte:fragment slot="4" let:row let:index>
|
<svelte:fragment slot="4" let:row let:index>
|
||||||
<CheckboxField
|
<CheckboxField
|
||||||
checked={!row['skip']}
|
checked={!row['skip']}
|
||||||
on:change={e => (value = (value || []).map((x, i) => (i == index ? { ...x, skip: !e.target.checked } : x)))}
|
on:change={e =>
|
||||||
|
(value = (value || []).map((x, i) => (i == index ? { ...x, skip: !e.target.checked, ignore: false } : x)))}
|
||||||
/>
|
/>
|
||||||
</svelte:fragment>
|
</svelte:fragment>
|
||||||
<svelte:fragment slot="1" let:row let:index>
|
<svelte:fragment slot="1" let:row let:index>
|
||||||
<TextField
|
<TextField
|
||||||
value={row['src']}
|
value={row['src']}
|
||||||
on:change={e => (value = (value || []).map((x, i) => (i == index ? { ...x, src: e.target.value } : x)))}
|
on:change={e =>
|
||||||
|
(value = (value || []).map((x, i) => (i == index ? { ...x, src: e.target.value, ignore: false } : x)))}
|
||||||
/>
|
/>
|
||||||
</svelte:fragment>
|
</svelte:fragment>
|
||||||
<svelte:fragment slot="2" let:row let:index>
|
<svelte:fragment slot="2" let:row let:index>
|
||||||
<TextField
|
<TextField
|
||||||
value={row['dst']}
|
value={row['dst']}
|
||||||
on:change={e => (value = (value || []).map((x, i) => (i == index ? { ...x, dst: e.target.value } : x)))}
|
on:change={e =>
|
||||||
|
(value = (value || []).map((x, i) => (i == index ? { ...x, dst: e.target.value, ignore: false } : x)))}
|
||||||
/>
|
/>
|
||||||
</svelte:fragment>
|
</svelte:fragment>
|
||||||
<svelte:fragment slot="3" let:index>
|
<svelte:fragment slot="3" let:index>
|
||||||
|
|||||||
Reference in New Issue
Block a user