dynamic structure switch

This commit is contained in:
Jan Prochazka
2023-02-19 19:23:51 +01:00
parent eb098bb33a
commit 29eef5619d
4 changed files with 27 additions and 7 deletions

View File

@@ -12,7 +12,9 @@ class StringifyStream extends stream.Transform {
_transform(chunk, encoding, done) { _transform(chunk, encoding, done) {
let skip = false; let skip = false;
if (!this.wasHeader) { if (!this.wasHeader) {
skip = (chunk.__isStreamHeader && !this.header) || (chunk.__isStreamHeader && chunk.__isDynamicStructure); skip =
(chunk.__isStreamHeader && !this.header) ||
(chunk.__isStreamHeader && chunk.__isDynamicStructure && !chunk.__keepDynamicStreamHeader);
this.wasHeader = true; this.wasHeader = true;
} }
if (!skip) { if (!skip) {

View File

@@ -149,11 +149,24 @@
<SelectField <SelectField
isNative isNative
class="colmode" class="colmode"
value="fixed" value={isDynamicStructure ? 'variable' : 'fixed'}
options={[ options={[
{ label: 'Fixed columns (like SQL)', value: 'fixed' }, { label: 'Fixed columns (like SQL)', value: 'fixed' },
{ label: 'Variable columns (like MongoDB)', value: 'variable' }, { label: 'Variable columns (like MongoDB)', value: 'variable' },
]} ]}
on:change={e => {
dispatchChangeSet({
type: 'set',
value: {
...changeSetState?.value,
structure: {
...display?.editableStructure,
__isDynamicStructure: e.detail == 'variable',
// __keepDynamicStreamHeader: true,
},
},
});
}}
/> />
</div> </div>
{/if} {/if}
@@ -174,7 +187,7 @@
}}>Add</InlineButton }}>Add</InlineButton
> >
{/if} {/if}
{#if allowChangeChangeSetStructure} {#if allowChangeChangeSetStructure && !isDynamicStructure}
<InlineButton on:click={handleAddColumn}>Add</InlineButton> <InlineButton on:click={handleAddColumn}>Add</InlineButton>
{/if} {/if}
<InlineButton on:click={() => display.hideAllColumns()}>Hide</InlineButton> <InlineButton on:click={() => display.hideAllColumns()}>Hide</InlineButton>
@@ -199,6 +212,7 @@
{display} {display}
{column} {column}
{isJsonView} {isJsonView}
{isDynamicStructure}
{conid} {conid}
{database} {database}
{tableInfo} {tableInfo}

View File

@@ -14,6 +14,7 @@
export let isSelected = false; export let isSelected = false;
export let conid; export let conid;
export let database; export let database;
export let isDynamicStructure;
export let tableInfo; export let tableInfo;
export let setTableInfo; export let setTableInfo;
@@ -82,7 +83,7 @@
<ColumnLabel {...column} showDataType {conid} {database} /> <ColumnLabel {...column} showDataType {conid} {database} />
</div> </div>
{#if allowChangeChangeSetStructure} {#if allowChangeChangeSetStructure && !isDynamicStructure}
<div class="nowrap"> <div class="nowrap">
<span class="icon" on:click={handleEditColumn}> <span class="icon" on:click={handleEditColumn}>
<FontIcon icon="icon edit" /> <FontIcon icon="icon edit" />

View File

@@ -47,16 +47,19 @@
$: $effect; $: $effect;
$: infoWithPairingId = generateTablePairingId($info); $: infoWithPairingId = generateTablePairingId($info);
$: infoUsed = (allowChangeChangeSetStructure && changeSetState?.value?.structure) || infoWithPairingId;
// $: console.log('infoUsed', infoUsed);
$: display = new JslGridDisplay( $: display = new JslGridDisplay(
jslid, jslid,
(allowChangeChangeSetStructure && changeSetState?.value?.structure) || infoWithPairingId, infoUsed,
$config, $config,
config.update, config.update,
$cache, $cache,
cache.update, cache.update,
loadedRows, loadedRows,
$info?.__isDynamicStructure, infoUsed?.__isDynamicStructure,
supportsReload, supportsReload,
!!changeSetState !!changeSetState
); );
@@ -72,7 +75,7 @@
gridCoreComponent={JslDataGridCore} gridCoreComponent={JslDataGridCore}
formViewComponent={JslFormView} formViewComponent={JslFormView}
bind:loadedRows bind:loadedRows
isDynamicStructure={$info?.__isDynamicStructure} isDynamicStructure={!!infoUsed?.__isDynamicStructure}
useEvalFilters useEvalFilters
{changeSetState} {changeSetState}
{changeSetStore} {changeSetStore}