diff --git a/packages/datalib/src/ChangeSet.ts b/packages/datalib/src/ChangeSet.ts
index 707db5db..4e564af3 100644
--- a/packages/datalib/src/ChangeSet.ts
+++ b/packages/datalib/src/ChangeSet.ts
@@ -9,7 +9,7 @@ import {
AllowIdentityInsert,
Expression,
} from 'dbgate-sqltree';
-import type { NamedObjectInfo, DatabaseInfo } from 'dbgate-types';
+import type { NamedObjectInfo, DatabaseInfo, TableInfo } from 'dbgate-types';
export interface ChangeSetItem {
pureName: string;
@@ -21,7 +21,16 @@ export interface ChangeSetItem {
fields?: { [column: string]: string };
}
+export interface ChangeSetDataUpdateCommand {
+ type: 'renameField' | 'deleteField' | 'setField';
+ field: string;
+ value?: any;
+}
+
export interface ChangeSet {
+ structure?: TableInfo;
+ dataUpdateCommands?: ChangeSetDataUpdateCommand[];
+ setColumnMode?: 'fixed' | 'variable';
inserts: ChangeSetItem[];
updates: ChangeSetItem[];
deletes: ChangeSetItem[];
@@ -456,5 +465,12 @@ export function changeSetInsertDocuments(changeSet: ChangeSet, documents: any[],
export function changeSetContainsChanges(changeSet: ChangeSet) {
if (!changeSet) return false;
- return changeSet.deletes.length > 0 || changeSet.updates.length > 0 || changeSet.inserts.length > 0;
+ return (
+ changeSet.deletes.length > 0 ||
+ changeSet.updates.length > 0 ||
+ changeSet.inserts.length > 0 ||
+ !!changeSet.structure ||
+ !!changeSet.setColumnMode ||
+ changeSet.dataUpdateCommands?.length > 0
+ );
}
diff --git a/packages/datalib/src/GridDisplay.ts b/packages/datalib/src/GridDisplay.ts
index 4f505ebc..9a7fc770 100644
--- a/packages/datalib/src/GridDisplay.ts
+++ b/packages/datalib/src/GridDisplay.ts
@@ -84,6 +84,7 @@ export abstract class GridDisplay {
return this.baseTable || this.baseView;
}
changeSetKeyFields: string[] = null;
+ editableStructure: TableInfo = null;
sortable = false;
groupable = false;
filterable = false;
diff --git a/packages/datalib/src/JslGridDisplay.ts b/packages/datalib/src/JslGridDisplay.ts
index 9a34f490..030471be 100644
--- a/packages/datalib/src/JslGridDisplay.ts
+++ b/packages/datalib/src/JslGridDisplay.ts
@@ -24,6 +24,7 @@ export class JslGridDisplay extends GridDisplay {
this.isDynamicStructure = isDynamicStructure;
this.filterTypeOverride = 'eval';
this.editable = editable;
+ this.editableStructure = editable ? structure : null;
if (structure?.columns) {
this.columns = _.uniqBy(
diff --git a/packages/web/src/datagrid/ColumnManager.svelte b/packages/web/src/datagrid/ColumnManager.svelte
index 896295da..1957f6e9 100644
--- a/packages/web/src/datagrid/ColumnManager.svelte
+++ b/packages/web/src/datagrid/ColumnManager.svelte
@@ -1,6 +1,6 @@
+{#if allowChangeChangeSetStructure}
+
+
+
+{/if}
@@ -122,6 +164,9 @@
}}>Add
{/if}
+ {#if allowChangeChangeSetStructure}
+ Add
+ {/if}
display.hideAllColumns()}>Hide
display.showAllColumns()}>Show
@@ -139,12 +184,18 @@
/>
{#each items as column (column.uniqueName)}
+ {@const columnIndex = items.indexOf(column)}
{
if (domFocusField) domFocusField.focus();
@@ -198,4 +249,14 @@
left: -1000px;
top: -1000px;
}
+
+ .selectwrap :global(select) {
+ flex: 1;
+ padding: 3px 0px;
+ border: none;
+ }
+
+ .selectwrap {
+ border-bottom: 1px solid var(--theme-border);
+ }
diff --git a/packages/web/src/datagrid/ColumnManagerRow.svelte b/packages/web/src/datagrid/ColumnManagerRow.svelte
index 06ee30bc..ded11ca4 100644
--- a/packages/web/src/datagrid/ColumnManagerRow.svelte
+++ b/packages/web/src/datagrid/ColumnManagerRow.svelte
@@ -4,6 +4,8 @@
import FontIcon from '../icons/FontIcon.svelte';
import ColumnLabel from '../elements/ColumnLabel.svelte';
import { createEventDispatcher } from 'svelte';
+ import { showModal } from '../modals/modalTools';
+ import ColumnEditorModal from '../tableeditor/ColumnEditorModal.svelte';
export let column;
export let display;
@@ -12,6 +14,26 @@
export let conid;
export let database;
+ export let tableInfo;
+ export let setTableInfo;
+
+ export let columnInfo = null;
+ export let columnIndex = -1;
+
+ export let allowChangeChangeSetStructure = false;
+
+ function handleEditColumn() {
+ showModal(ColumnEditorModal, { columnInfo, tableInfo, setTableInfo });
+ }
+
+ function exchange(array, i1, i2) {
+ const i1r = (i1 + array.length) % array.length;
+ const i2r = (i2 + array.length) % array.length;
+ const res = [...array];
+ [res[i1r], res[i2r]] = [res[i2r], res[i1r]];
+ return res;
+ }
+
const dispatch = createEventDispatcher();
@@ -29,32 +51,63 @@
on:mousemove
on:mouseup
>
-
- display.toggleExpandedColumn(column.uniqueName)}
- />
-
- {#if isJsonView}
-
- {:else}
- {
- e.stopPropagation();
- }}
- on:mousedown={e => {
- e.stopPropagation();
- }}
- on:change={() => {
- const newValue = !column.isChecked;
- display.setColumnVisibility(column.uniquePath, newValue);
- dispatch('setvisibility', newValue);
- }}
- />
+
+
+ display.toggleExpandedColumn(column.uniqueName)}
+ />
+
+ {#if isJsonView}
+
+ {:else}
+ {
+ e.stopPropagation();
+ }}
+ on:mousedown={e => {
+ e.stopPropagation();
+ }}
+ on:change={() => {
+ const newValue = !column.isChecked;
+ display.setColumnVisibility(column.uniquePath, newValue);
+ dispatch('setvisibility', newValue);
+ }}
+ />
+ {/if}
+
+
+
+ {#if allowChangeChangeSetStructure}
+
+
+
+
+
+ setTableInfo(info => ({ ...info, columns: info.columns.filter(x => x.pairingId != columnInfo?.pairingId) }))}
+ >
+
+
+
+ setTableInfo(info => ({ ...info, columns: exchange(info.columns, columnIndex, columnIndex - 1) }))}
+ >
+
+
+
+ setTableInfo(info => ({ ...info, columns: exchange(info.columns, columnIndex, columnIndex + 1) }))}
+ >
+
+
+
{/if}
-
diff --git a/packages/web/src/datagrid/JslDataGrid.svelte b/packages/web/src/datagrid/JslDataGrid.svelte
index 6ae1a2a3..1a52767e 100644
--- a/packages/web/src/datagrid/JslDataGrid.svelte
+++ b/packages/web/src/datagrid/JslDataGrid.svelte
@@ -1,5 +1,6 @@
@@ -31,7 +31,10 @@
-
+
{#if driver?.dialect?.columnProperties?.isUnsigned}
diff --git a/packages/web/src/tabs/ArchiveFileTab.svelte b/packages/web/src/tabs/ArchiveFileTab.svelte
index 868404c2..0f644191 100644
--- a/packages/web/src/tabs/ArchiveFileTab.svelte
+++ b/packages/web/src/tabs/ArchiveFileTab.svelte
@@ -87,6 +87,7 @@