Fix data source fetching for relationships in all other files

This commit is contained in:
Andrew Kingston 2020-11-19 13:52:11 +00:00
parent c1c7c8ede4
commit 3ffe1cb3fc
4 changed files with 8 additions and 4 deletions

View File

@ -5,6 +5,7 @@
import { isEmpty } from "lodash/fp"
const { API } = getContext("app")
const dataContext = getContext("data")
export let title
export let datasource
@ -35,7 +36,7 @@
// Fetch, filter and sort data
const schema = (await API.fetchTableDefinition(datasource.tableId)).schema
const result = await API.fetchDatasource(datasource)
const result = await API.fetchDatasource(datasource, $dataContext)
const reducer = row => (valid, column) => valid && row[column] != null
const hasAllColumns = row => allCols.reduce(reducer(row), true)
const data = result

View File

@ -5,6 +5,7 @@
import { isEmpty } from "lodash/fp"
const { API } = getContext("app")
const dataContext = getContext("data")
export let title
export let datasource
@ -33,7 +34,7 @@
// Fetch, filter and sort data
const schema = (await API.fetchTableDefinition(datasource.tableId)).schema
const result = await API.fetchDatasource(datasource)
const result = await API.fetchDatasource(datasource, $dataContext)
const reducer = row => (valid, column) => valid && row[column] != null
const hasAllColumns = row => allCols.reduce(reducer(row), true)
const data = result

View File

@ -5,6 +5,7 @@
import { isEmpty } from "lodash/fp"
const { API } = getContext("app")
const dataContext = getContext("data")
export let title
export let datasource
@ -31,7 +32,7 @@
// Fetch, filter and sort data
const schema = (await API.fetchTableDefinition(datasource.tableId)).schema
const result = await API.fetchDatasource(datasource)
const result = await API.fetchDatasource(datasource, $dataContext)
const data = result
.filter(row => row[labelColumn] != null && row[valueColumn] != null)
.slice(0, 20)

View File

@ -15,6 +15,7 @@
// These maps need to be set up to handle whatever types that are used in the tables.
const setters = new Map([["number", number]])
const SDK = getContext("app")
const dataContext = getContext("data")
const { API, styleable } = SDK
export let datasource = {}
@ -52,7 +53,7 @@
onMount(async () => {
if (!isEmpty(datasource)) {
data = await API.fetchDatasource(datasource)
data = await API.fetchDatasource(datasource, $dataContext)
let schema
// Get schema for datasource