From c883db310195a37c61937c4e2808c45dd7798afd Mon Sep 17 00:00:00 2001 From: HugoCasa Date: Mon, 13 May 2024 18:08:37 +0200 Subject: [PATCH] feat(frontend): allows to specify column order for rich display (#3709) * feat(frontend): allows to specify column order for rich display * patch: rename table-cell to table-row-object * fix: nested table row object --- .../src/lib/components/DisplayResult.svelte | 187 +++++++++++------- 1 file changed, 116 insertions(+), 71 deletions(-) diff --git a/frontend/src/lib/components/DisplayResult.svelte b/frontend/src/lib/components/DisplayResult.svelte index c1811a1802..b3c54c7680 100644 --- a/frontend/src/lib/components/DisplayResult.svelte +++ b/frontend/src/lib/components/DisplayResult.svelte @@ -1,8 +1,7 @@ {#if is_render_all}
{#if !noControls} -
- as JSON  +
+ { + globalForceJson = ev.detail === 'json' + }} + > + + + +
{/if} {#each result['render_all'] as res} @@ -275,29 +341,19 @@ > {#if result != undefined && length != undefined && largeObject != undefined}
-
- {#if (resultKind && typeof result == 'object' && !['json', 's3object', 's3object-list', 'table-col', 'table-row'].includes(resultKind) && !hideAsJson) || isTableDisplay} +
+ {#if !hideAsJson && !['json', 's3object'].includes(resultKind ?? '') && typeof result === 'object'} { - if (isTableDisplay) { - richRender = ev.detail === 'table' - } forceJson = ev.detail === 'json' }} > - {#if resultKind && !['json', 's3object', 's3object-list', 'table-col', 'table-row'].includes(resultKind) && !hideAsJson} - - {/if} - {#if isTableDisplay} + {#if ['table-col', 'table-row', 'table-row-object'].includes(resultKind ?? '')} + {:else} + {/if} @@ -327,22 +383,13 @@
{#if !forceJson && resultKind == 'table-col'} {@const data = 'table-col' in result ? result['table-col'] : result} - + {:else if !forceJson && resultKind == 'table-row'} {@const data = 'table-row' in result ? result['table-row'] : result} -
- - - {#each Array.isArray(asListOfList(data)) ? asListOfList(data) : [] as row} - - {#each row as v} - {truncate(JSON.stringify(v), 200) ?? ''} - {/each} - - {/each} - - -
+ + {:else if !forceJson && resultKind == 'table-row-object'} + {@const data = 'table-row-object' in result ? result['table-row-object'] : result} + {:else if !forceJson && resultKind == 'html'}
{#if !requireHtmlApproval || enableHtml} @@ -537,8 +584,6 @@
- {:else if !forceJson && isTableDisplay && richRender} - {:else if largeObject} {#if result && typeof result == 'object' && 'file' in result}