From 933969ce55928e49eaf4c96e399d4dc665af876a Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Wed, 10 Feb 2021 14:24:42 +0000 Subject: [PATCH] code review --- packages/server/src/api/controllers/row.js | 4 +- packages/server/src/api/routes/row.js | 1 + packages/standard-components/manifest.json | 3 +- .../standard-components/src/Search.svelte | 38 +++++++++++-------- 4 files changed, 29 insertions(+), 17 deletions(-) diff --git a/packages/server/src/api/controllers/row.js b/packages/server/src/api/controllers/row.js index d7dad88628..b1aad6d2ca 100644 --- a/packages/server/src/api/controllers/row.js +++ b/packages/server/src/api/controllers/row.js @@ -256,7 +256,9 @@ exports.search = async function(ctx) { } } - ctx.body = await linkRows.attachLinkInfo(appId, rows) + const table = await db.get(ctx.params.tableId) + + ctx.body = await enrichRows(appId, table, rows) } exports.fetchTableRows = async function(ctx) { diff --git a/packages/server/src/api/routes/row.js b/packages/server/src/api/routes/row.js index 3c36fe579b..be14910f3e 100644 --- a/packages/server/src/api/routes/row.js +++ b/packages/server/src/api/routes/row.js @@ -41,6 +41,7 @@ router ) .post( "/api/:tableId/rows/search", + paramResource("tableId"), authorized(PermissionTypes.TABLE, PermissionLevels.READ), rowController.search ) diff --git a/packages/standard-components/manifest.json b/packages/standard-components/manifest.json index 7f30f10886..9d9d603f54 100644 --- a/packages/standard-components/manifest.json +++ b/packages/standard-components/manifest.json @@ -146,7 +146,8 @@ { "type": "text", "label": "No Rows Message", - "key": "noRowsMessage" + "key": "noRowsMessage", + "defaultValue": "No Rows" } ] }, diff --git a/packages/standard-components/src/Search.svelte b/packages/standard-components/src/Search.svelte index fc31645fc3..e3f91081de 100644 --- a/packages/standard-components/src/Search.svelte +++ b/packages/standard-components/src/Search.svelte @@ -16,7 +16,7 @@ export let table = [] export let columns = [] export let pageSize = 50 - export let noRowsMessage = "No Rows" + export let noRowsMessage let rows = [] let loaded = false @@ -94,23 +94,32 @@ }}> Reset - + - {#if rows.length > 0} - {#if $component.children === 0 && $builderStore.inBuilder} -

Add some components too

+ {#if loaded} + {#if rows.length > 0} + {#if $component.children === 0 && $builderStore.inBuilder} +

Add some components too

+ {:else} + {#each rows as row} + + + + {/each} + {/if} + {:else if $builderStore.inBuilder} +

Feed me some data

{:else} - {#each rows as row} - - - - {/each} +

{noRowsMessage}

{/if} - {:else if loaded && $builderStore.inBuilder} -

Feed me some data

- {:else} -

{noRowsMessage}

{/if}