mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-22 21:36:00 +00:00
table edit fixes
This commit is contained in:
@@ -133,14 +133,14 @@ export default function useEditorData({ tabid, reloadToken = 0, loadFromArgs = n
|
|||||||
};
|
};
|
||||||
|
|
||||||
const clearEditorData = async () => {
|
const clearEditorData = async () => {
|
||||||
|
await localforage.removeItem(localStorageKey);
|
||||||
|
localStorage.removeItem(localStorageKey);
|
||||||
editorState.update(x => ({
|
editorState.update(x => ({
|
||||||
...x,
|
...x,
|
||||||
value: null,
|
value: null,
|
||||||
errorMessage: null,
|
errorMessage: null,
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
}));
|
}));
|
||||||
await localforage.removeItem(localStorageKey);
|
|
||||||
localStorage.removeItem(localStorageKey);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
|
|||||||
@@ -37,9 +37,9 @@
|
|||||||
constraintType,
|
constraintType,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<FormProvider>
|
||||||
<ModalBase {...$$restProps}>
|
<ModalBase {...$$restProps}>
|
||||||
<svelte:fragment slot="header"
|
<svelte:fragment slot="header"
|
||||||
>{constraintInfo ? `Edit ${constraintLabel}` : `Add ${constraintLabel}`}</svelte:fragment
|
>{constraintInfo ? `Edit ${constraintLabel}` : `Add ${constraintLabel}`}</svelte:fragment
|
||||||
@@ -120,7 +120,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<svelte:fragment slot="footer">
|
<svelte:fragment slot="footer">
|
||||||
<FormStyledButton
|
<FormSubmit
|
||||||
value={'Save'}
|
value={'Save'}
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
closeCurrentModal();
|
closeCurrentModal();
|
||||||
@@ -145,6 +145,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</svelte:fragment>
|
</svelte:fragment>
|
||||||
</ModalBase>
|
</ModalBase>
|
||||||
|
</FormProvider>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.row {
|
.row {
|
||||||
@@ -161,5 +162,4 @@
|
|||||||
align-self: center;
|
align-self: center;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -62,6 +62,7 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<FormProvider>
|
||||||
<ModalBase {...$$restProps}>
|
<ModalBase {...$$restProps}>
|
||||||
<svelte:fragment slot="header">{constraintInfo ? `Edit foreign key` : `Add foreign key`}</svelte:fragment>
|
<svelte:fragment slot="header">{constraintInfo ? `Edit foreign key` : `Add foreign key`}</svelte:fragment>
|
||||||
|
|
||||||
@@ -195,7 +196,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<svelte:fragment slot="footer">
|
<svelte:fragment slot="footer">
|
||||||
<FormStyledButton
|
<FormSubmit
|
||||||
value={'Save'}
|
value={'Save'}
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
closeCurrentModal();
|
closeCurrentModal();
|
||||||
@@ -220,6 +221,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</svelte:fragment>
|
</svelte:fragment>
|
||||||
</ModalBase>
|
</ModalBase>
|
||||||
|
</FormProvider>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.row {
|
.row {
|
||||||
|
|||||||
@@ -66,7 +66,7 @@
|
|||||||
|
|
||||||
const { editorState, editorValue, setEditorData, clearEditorData } = useEditorData({ tabid });
|
const { editorState, editorValue, setEditorData, clearEditorData } = useEditorData({ tabid });
|
||||||
|
|
||||||
$: showTable = $editorValue || tableInfoWithPairingId;
|
$: showTable = $editorValue ? $editorValue.current : tableInfoWithPairingId;
|
||||||
|
|
||||||
export function canSave() {
|
export function canSave() {
|
||||||
return objectTypeField == 'tables' && !!$editorValue;
|
return objectTypeField == 'tables' && !!$editorValue;
|
||||||
@@ -74,7 +74,7 @@
|
|||||||
|
|
||||||
export function save() {
|
export function save() {
|
||||||
const driver = findEngineDriver($connection, $extensions);
|
const driver = findEngineDriver($connection, $extensions);
|
||||||
const sql = getAlterTableScript(tableInfoWithPairingId, $editorValue, {}, $dbInfo, driver);
|
const sql = getAlterTableScript($editorValue.base, $editorValue.current, {}, $dbInfo, driver);
|
||||||
|
|
||||||
showModal(ConfirmSqlModal, {
|
showModal(ConfirmSqlModal, {
|
||||||
sql,
|
sql,
|
||||||
@@ -114,9 +114,16 @@
|
|||||||
dbInfo={$dbInfo}
|
dbInfo={$dbInfo}
|
||||||
setTableInfo={objectTypeField == 'tables'
|
setTableInfo={objectTypeField == 'tables'
|
||||||
? tableInfoUpdater =>
|
? tableInfoUpdater =>
|
||||||
setEditorData(tbl => {
|
setEditorData(tbl =>
|
||||||
if (tbl) return tableInfoUpdater(tbl);
|
tbl
|
||||||
return tableInfoUpdater(tableInfoWithPairingId);
|
? {
|
||||||
})
|
base: tbl.base,
|
||||||
|
current: tableInfoUpdater(tbl.current),
|
||||||
|
}
|
||||||
|
: {
|
||||||
|
base: tableInfoWithPairingId,
|
||||||
|
current: tableInfoUpdater(tableInfoWithPairingId),
|
||||||
|
}
|
||||||
|
)
|
||||||
: null}
|
: null}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user