Skip to content

Commit 7d3ead6

Browse files
author
Jicheng Lu
committed
fix dictionary display
1 parent b740033 commit 7d3ead6

2 files changed

Lines changed: 15 additions & 22 deletions

File tree

src/routes/page/knowledge-base/common/table/table-item.svelte

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@
88
* @type {{
99
* item: any,
1010
* columns: import('$commonTypes').TableItemConfig[],
11-
* detailKey?: string | null,
1211
* useJsonDisplay?: boolean,
1312
* open?: boolean
1413
* }}
1514
*/
1615
let {
1716
item,
1817
columns,
19-
detailKey = null,
2018
useJsonDisplay = false,
2119
open = $bindable(false)
2220
} = $props();
@@ -49,7 +47,6 @@
4947
{/if}
5048
<td class="knowledge-op">
5149
<ul class="list-unstyled hstack gap-1 mb-0 knowledge-op-list">
52-
{#if detailKey}
5350
<li data-bs-toggle="tooltip" data-bs-placement="top" title="View Detail">
5451
<button
5552
class="btn btn-sm btn-soft-primary"
@@ -62,7 +59,6 @@
6259
{/if}
6360
</button>
6461
</li>
65-
{/if}
6662
</ul>
6763
</td>
6864
</tr>
@@ -94,23 +90,21 @@
9490
in:fly={{ y: -5, duration: 300 }}
9591
out:fly={{ y: -5, duration: 200 }}
9692
>
97-
{#if detailKey && item[detailKey]}
98-
{#if useJsonDisplay}
99-
<JSONTree
100-
value={formatObject(item[detailKey])}
101-
defaultExpandedLevel={1}
102-
--json-tree-number-color="var(--bs-info)"
103-
--json-tree-boolean-color="var(--bs-info)"
104-
--json-tree-string-color="var(--bs-info)"
105-
/>
106-
{:else}
107-
{#each Object.keys(item[detailKey]) as key, idx (idx)}
108-
<li class="more-detail-item wrappable">
109-
<span>{splitTextByCase(key)}: </span>
110-
<span>{item[detailKey][key]}</span>
111-
</li>
112-
{/each}
113-
{/if}
93+
{#if useJsonDisplay}
94+
<JSONTree
95+
value={formatObject(item)}
96+
defaultExpandedLevel={1}
97+
--json-tree-number-color="var(--bs-info)"
98+
--json-tree-boolean-color="var(--bs-info)"
99+
--json-tree-string-color="var(--bs-info)"
100+
/>
101+
{:else}
102+
{#each Object.keys(item).filter(key => !columns.some(col => col.dataName === key)) as key, idx (idx)}
103+
<li class="more-detail-item wrappable">
104+
<span>{splitTextByCase(key)}: </span>
105+
<span>{item[key]}</span>
106+
</li>
107+
{/each}
114108
{/if}
115109
</ul>
116110
{/if}

src/routes/page/knowledge-base/dictionary/+page.svelte

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,6 @@
347347
<TableItem
348348
item={item.data}
349349
columns={columns}
350-
detailKey={'data'}
351350
open={idx === 0}
352351
/>
353352
{/each}

0 commit comments

Comments
 (0)