1
0
Fork 0
mirror of synced 2024-09-08 13:41:09 +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 { goto } from "@roxi/routify"
import { viewsV2 } from "stores/backend"
import { tables } from "stores/backend"
import { LuceneUtils } from "@budibase/frontend-core"
const { filter, sort, table } = getContext("grid")
$: query = LuceneUtils.buildLuceneQuery($filter)
$: console.log($table.schema)
let name
$: views = Object.keys($tables.selected?.views || {})
$: console.log($table)
$: views = Object.keys($table?.views || {})
$: nameExists = views.includes(name?.trim())
const saveView = async () => {
@ -21,17 +20,19 @@
try {
const newView = await viewsV2.create({
name,
tableId: $tables.selected._id,
tableId: $table._id,
query,
sort: {
field: $sort.column,
order: $sort.order,
},
columns: $table.schema,
schema: $table.schema,
primaryDisplay: $table.primaryDisplay,
})
notifications.success(`View ${name} created`)
$goto(`../../view/v2/${newView.id}`)
} catch (error) {
console.log(error)
notifications.error("Error creating view")
}
}