1
0
Fork 0
mirror of synced 2024-09-17 01:38:40 +12:00

Update create view modal to only depend on grid context

This commit is contained in:
Andrew Kingston 2023-08-02 15:27:34 +01:00
parent 858a0796bd
commit ab47e49dd9

View file

@ -3,17 +3,16 @@
import { Input, notifications, ModalContent } from "@budibase/bbui" import { Input, notifications, ModalContent } from "@budibase/bbui"
import { goto } from "@roxi/routify" import { goto } from "@roxi/routify"
import { viewsV2 } from "stores/backend" import { viewsV2 } from "stores/backend"
import { tables } from "stores/backend"
import { LuceneUtils } from "@budibase/frontend-core" import { LuceneUtils } from "@budibase/frontend-core"
const { filter, sort, table } = getContext("grid") const { filter, sort, table } = getContext("grid")
$: query = LuceneUtils.buildLuceneQuery($filter) $: query = LuceneUtils.buildLuceneQuery($filter)
$: console.log($table.schema)
let name let name
$: views = Object.keys($tables.selected?.views || {}) $: console.log($table)
$: views = Object.keys($table?.views || {})
$: nameExists = views.includes(name?.trim()) $: nameExists = views.includes(name?.trim())
const saveView = async () => { const saveView = async () => {
@ -21,17 +20,19 @@
try { try {
const newView = await viewsV2.create({ const newView = await viewsV2.create({
name, name,
tableId: $tables.selected._id, tableId: $table._id,
query, query,
sort: { sort: {
field: $sort.column, field: $sort.column,
order: $sort.order, order: $sort.order,
}, },
columns: $table.schema, schema: $table.schema,
primaryDisplay: $table.primaryDisplay,
}) })
notifications.success(`View ${name} created`) notifications.success(`View ${name} created`)
$goto(`../../view/v2/${newView.id}`) $goto(`../../view/v2/${newView.id}`)
} catch (error) { } catch (error) {
console.log(error)
notifications.error("Error creating view") notifications.error("Error creating view")
} }
} }