code review

This commit is contained in:
Martin McKeaveney 2021-02-10 14:24:42 +00:00
parent 1a945da513
commit 933969ce55
4 changed files with 29 additions and 17 deletions

View File

@ -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) { exports.fetchTableRows = async function(ctx) {

View File

@ -41,6 +41,7 @@ router
) )
.post( .post(
"/api/:tableId/rows/search", "/api/:tableId/rows/search",
paramResource("tableId"),
authorized(PermissionTypes.TABLE, PermissionLevels.READ), authorized(PermissionTypes.TABLE, PermissionLevels.READ),
rowController.search rowController.search
) )

View File

@ -146,7 +146,8 @@
{ {
"type": "text", "type": "text",
"label": "No Rows Message", "label": "No Rows Message",
"key": "noRowsMessage" "key": "noRowsMessage",
"defaultValue": "No Rows"
} }
] ]
}, },

View File

@ -16,7 +16,7 @@
export let table = [] export let table = []
export let columns = [] export let columns = []
export let pageSize = 50 export let pageSize = 50
export let noRowsMessage = "No Rows" export let noRowsMessage
let rows = [] let rows = []
let loaded = false let loaded = false
@ -94,9 +94,17 @@
}}> }}>
Reset Reset
</Button> </Button>
<Button primary on:click={() => fetchData(table)}>Search</Button> <Button
primary
on:click={() => {
page = 0
fetchData(table, page)
}}>
Search
</Button>
</div> </div>
</div> </div>
{#if loaded}
{#if rows.length > 0} {#if rows.length > 0}
{#if $component.children === 0 && $builderStore.inBuilder} {#if $component.children === 0 && $builderStore.inBuilder}
<p>Add some components too</p> <p>Add some components too</p>
@ -107,11 +115,12 @@
</DataProvider> </DataProvider>
{/each} {/each}
{/if} {/if}
{:else if loaded && $builderStore.inBuilder} {:else if $builderStore.inBuilder}
<p>Feed me some data</p> <p>Feed me some data</p>
{:else} {:else}
<p>{noRowsMessage}</p> <p>{noRowsMessage}</p>
{/if} {/if}
{/if}
<div class="pagination"> <div class="pagination">
{#if page > 0} {#if page > 0}
<Button primary on:click={previousPage}>Back</Button> <Button primary on:click={previousPage}>Back</Button>
@ -133,7 +142,6 @@
.query-builder { .query-builder {
padding: var(--spacing-m); padding: var(--spacing-m);
background: var(--background);
border-radius: var(--border-radius-s); border-radius: var(--border-radius-s);
} }