sql object tab - ability to show template

This commit is contained in:
SPRINX0\prochazka
2024-11-20 14:33:05 +01:00
parent a68660f1ab
commit aeb81bd97f

View File

@@ -24,11 +24,15 @@
import registerCommand from '../commands/registerCommand'; import registerCommand from '../commands/registerCommand';
import applyScriptTemplate, { getSupportedScriptTemplates } from '../utility/applyScriptTemplate'; import applyScriptTemplate, { getSupportedScriptTemplates } from '../utility/applyScriptTemplate';
import LoadingInfo from '../elements/LoadingInfo.svelte'; import LoadingInfo from '../elements/LoadingInfo.svelte';
import ToolStripCommandButton from '../buttons/ToolStripCommandButton.svelte';
import SelectField from '../forms/SelectField.svelte';
export let tabid; export let tabid;
export let appObjectData; export let appObjectData;
export let initialScriptTemplate;
let scriptTemplate = getSupportedScriptTemplates(appObjectData.objectTypeField)?.[0]?.scriptTemplate; let scriptTemplate =
initialScriptTemplate ?? getSupportedScriptTemplates(appObjectData.objectTypeField)?.[0]?.scriptTemplate;
$: connection = useConnectionInfo({ conid: appObjectData.conid }); $: connection = useConnectionInfo({ conid: appObjectData.conid });
$: driver = findEngineDriver($connection, $extensions); $: driver = findEngineDriver($connection, $extensions);
@@ -53,18 +57,35 @@
} }
</script> </script>
{#await applyScriptTemplate(scriptTemplate, $extensions, appObjectData)} <ToolStripContainer>
<LoadingInfo message="Loading script..." /> {#await applyScriptTemplate(scriptTemplate, $extensions, appObjectData)}
{:then sql} <LoadingInfo message="Loading script..." />
<AceEditor {:then sql}
value={sql || ''} <AceEditor
menu={createMenu()} value={sql || ''}
on:focus={() => { menu={createMenu()}
activator.activate(); on:focus={() => {
domToolStrip?.activate(); activator.activate();
invalidateCommands(); domToolStrip?.activate();
}} invalidateCommands();
bind:this={domEditor} }}
mode={driver?.editorMode || 'sql'} bind:this={domEditor}
/> mode={driver?.editorMode || 'sql'}
{/await} />
{/await}
<svelte:fragment slot="toolstrip">
<ToolStripCommandButton command="sqlObject.find" />
<SelectField
isNative
value={scriptTemplate}
options={getSupportedScriptTemplates(appObjectData.objectTypeField).map(x => ({
label: x.label,
value: x.scriptTemplate,
}))}
on:change={e => {
scriptTemplate = e.detail;
}}
/>
</svelte:fragment>
</ToolStripContainer>