Merge pull request #1181 from Budibase/bug/view-relationships
Relationship view enrichment
This commit is contained in:
commit
a0a9320379
|
@ -2,6 +2,7 @@
|
||||||
import { Button, Input, Select } from "@budibase/bbui"
|
import { Button, Input, Select } from "@budibase/bbui"
|
||||||
import { backendUiStore } from "builderStore"
|
import { backendUiStore } from "builderStore"
|
||||||
import { notifier } from "builderStore/store/notifications"
|
import { notifier } from "builderStore/store/notifications"
|
||||||
|
import { FIELDS } from "constants/backend"
|
||||||
|
|
||||||
export let view = {}
|
export let view = {}
|
||||||
export let onClosed
|
export let onClosed
|
||||||
|
@ -9,7 +10,11 @@
|
||||||
$: viewTable = $backendUiStore.tables.find(
|
$: viewTable = $backendUiStore.tables.find(
|
||||||
({ _id }) => _id === $backendUiStore.selectedView.tableId
|
({ _id }) => _id === $backendUiStore.selectedView.tableId
|
||||||
)
|
)
|
||||||
$: fields = viewTable && Object.keys(viewTable.schema)
|
$: fields =
|
||||||
|
viewTable &&
|
||||||
|
Object.entries(viewTable.schema)
|
||||||
|
.filter(entry => entry[1].type !== FIELDS.LINK.type)
|
||||||
|
.map(([key]) => key)
|
||||||
|
|
||||||
function saveView() {
|
function saveView() {
|
||||||
backendUiStore.actions.views.save(view)
|
backendUiStore.actions.views.save(view)
|
||||||
|
|
|
@ -202,6 +202,11 @@ exports.fetchView = async function(ctx) {
|
||||||
|
|
||||||
const db = new CouchDB(appId)
|
const db = new CouchDB(appId)
|
||||||
const { calculation, group, field } = ctx.query
|
const { calculation, group, field } = ctx.query
|
||||||
|
const designDoc = await db.get("_design/database")
|
||||||
|
const viewInfo = designDoc.views[viewName]
|
||||||
|
if (!viewInfo) {
|
||||||
|
ctx.throw(400, "View does not exist.")
|
||||||
|
}
|
||||||
const response = await db.query(`database/${viewName}`, {
|
const response = await db.query(`database/${viewName}`, {
|
||||||
include_docs: !calculation,
|
include_docs: !calculation,
|
||||||
group,
|
group,
|
||||||
|
@ -211,7 +216,7 @@ exports.fetchView = async function(ctx) {
|
||||||
response.rows = response.rows.map(row => row.doc)
|
response.rows = response.rows.map(row => row.doc)
|
||||||
let table
|
let table
|
||||||
try {
|
try {
|
||||||
table = await db.get(ctx.params.tableId)
|
table = await db.get(viewInfo.meta.tableId)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
table = {
|
table = {
|
||||||
schema: {},
|
schema: {},
|
||||||
|
|
Loading…
Reference in New Issue