Fix creating views

This commit is contained in:
Andrew Kingston 2023-08-04 15:20:30 +01:00
parent ef4ff87d8a
commit dd4b304736
2 changed files with 7 additions and 8 deletions

View File

@ -1,7 +1,7 @@
<script>
import { getContext } from "svelte"
import { Modal, ActionButton } from "@budibase/bbui"
import CreateViewModal from "../../modals/CreateViewModal.svelte"
import GridCreateViewModal from "../../modals/grid/GridCreateViewModal.svelte"
const { rows, columns } = getContext("grid")
@ -14,5 +14,5 @@
Add view
</ActionButton>
<Modal bind:this={modal}>
<CreateViewModal />
<GridCreateViewModal />
</Modal>

View File

@ -5,14 +5,13 @@
import { viewsV2 } from "stores/backend"
import { LuceneUtils } from "@budibase/frontend-core"
const { filter, sort, table } = getContext("grid")
const { filter, sort, definition } = getContext("grid")
$: query = LuceneUtils.buildLuceneQuery($filter)
let name
$: console.log($table)
$: views = Object.keys($table?.views || {})
$: views = Object.keys($definition?.views || {})
$: nameExists = views.includes(name?.trim())
const saveView = async () => {
@ -20,14 +19,14 @@
try {
const newView = await viewsV2.create({
name,
tableId: $table._id,
tableId: $definition._id,
query,
sort: {
field: $sort.column,
order: $sort.order,
},
schema: $table.schema,
primaryDisplay: $table.primaryDisplay,
schema: $definition.schema,
primaryDisplay: $definition.primaryDisplay,
})
notifications.success(`View ${name} created`)
$goto(`../../view/v2/${newView.id}`)