1
0
Fork 0
mirror of synced 2024-07-02 04:50:44 +12:00

Merge branch 'master' of github.com:Budibase/budibase into bug/fixing-more-bugs

This commit is contained in:
mike12345567 2020-10-15 13:55:13 +01:00
commit 42225e4f58
6 changed files with 102 additions and 4 deletions

View file

@ -56,7 +56,7 @@
<div class="container">
<div class="header">
<Heading medium black>Welcome to the Budibase Beta</Heading>
<Button primary purple on:click={modal.show}>Create New Web App</Button>
<Button primary on:click={modal.show}>Create New Web App</Button>
</div>
<div class="banner">

View file

@ -4,6 +4,7 @@ import commonjs from "@rollup/plugin-commonjs"
import postcss from "rollup-plugin-postcss"
import { terser } from "rollup-plugin-terser"
const production = !process.env.ROLLUP_WATCH
const lodash_fp_exports = ["isEmpty"]
export default {
@ -17,7 +18,8 @@ export default {
},
],
plugins: [
terser(),
// Only run terser in production environments
production && terser(),
postcss({
plugins: [],
}),

View file

@ -68,7 +68,7 @@
field: key,
hide: shouldHideField(key),
sortable: true,
editable: canEdit,
editable: canEdit && schema[key].type !== "link",
cellRenderer: getRenderer(schema[key], canEdit),
autoHeight: true,
}

View file

@ -0,0 +1,69 @@
<script>
import { onMount } from "svelte"
import api from "../../api"
import { getTable } from "./tableCache"
export let columnName
export let row
$: count =
row && columnName && Array.isArray(row[columnName])
? row[columnName].length
: 0
let linkedRows = []
let displayColumn
onMount(async () => {
linkedRows = await fetchLinkedRowsData(row, columnName)
if (linkedRows && linkedRows.length) {
const table = await getTable(linkedRows[0].tableId)
if (table && table.primaryDisplay) {
displayColumn = table.primaryDisplay
}
}
})
async function fetchLinkedRowsData(row, columnName) {
if (!row || !row._id) {
return []
}
const QUERY_URL = `/api/${row.tableId}/${row._id}/enrich`
const response = await api.get(QUERY_URL)
const enrichedRow = await response.json()
return enrichedRow[columnName]
}
</script>
<div class="container">
{#if linkedRows && linkedRows.length && displayColumn}
{#each linkedRows as linkedRow}
{#if linkedRow[displayColumn] != null && linkedRow[displayColumn] !== ''}
<div class="linked-row">{linkedRow[displayColumn]}</div>
{/if}
{/each}
{:else}{count} related row(s){/if}
</div>
<style>
.container {
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: center;
gap: var(--spacing-xs);
width: 100%;
}
/* This styling is opinionated to ensure these always look consistent */
.linked-row {
color: white;
background-color: #616161;
border-radius: var(--border-radius-xs);
padding: var(--spacing-xs) var(--spacing-s) calc(var(--spacing-xs) + 1px)
var(--spacing-s);
line-height: 1;
font-size: 0.8em;
font-family: var(--font-sans);
font-weight: 500;
}
</style>

View file

@ -0,0 +1,20 @@
import api from "../../api"
let cache = {}
async function fetchTable(id) {
const FETCH_TABLE_URL = `/api/tables/${id}`
const response = await api.get(FETCH_TABLE_URL)
return await response.json()
}
export async function getTable(tableId) {
if (!tableId) {
return null
}
if (!cache[tableId]) {
cache[tableId] = fetchTable(tableId)
cache[tableId] = await cache[tableId]
}
return await cache[tableId]
}

View file

@ -4,6 +4,7 @@
import AttachmentCell from "./AttachmentCell/Button.svelte"
import Select from "./Select/Wrapper.svelte"
import DatePicker from "./DateTime/Wrapper.svelte"
import RelationshipDisplay from "./Relationship/RelationshipDisplay.svelte"
const renderers = new Map([
["boolean", booleanRenderer],
@ -110,7 +111,13 @@ function linkedRowRenderer(constraints, editable) {
container.style.placeItems = "center"
container.style.height = "100%"
container.innerText = params.value ? params.value.length : 0
new RelationshipDisplay({
target: container,
props: {
row: params.data,
columnName: params.column.colId,
},
})
return container
}