Fix creating views
This commit is contained in:
parent
ef4ff87d8a
commit
dd4b304736
|
@ -1,7 +1,7 @@
|
||||||
<script>
|
<script>
|
||||||
import { getContext } from "svelte"
|
import { getContext } from "svelte"
|
||||||
import { Modal, ActionButton } from "@budibase/bbui"
|
import { Modal, ActionButton } from "@budibase/bbui"
|
||||||
import CreateViewModal from "../../modals/CreateViewModal.svelte"
|
import GridCreateViewModal from "../../modals/grid/GridCreateViewModal.svelte"
|
||||||
|
|
||||||
const { rows, columns } = getContext("grid")
|
const { rows, columns } = getContext("grid")
|
||||||
|
|
||||||
|
@ -14,5 +14,5 @@
|
||||||
Add view
|
Add view
|
||||||
</ActionButton>
|
</ActionButton>
|
||||||
<Modal bind:this={modal}>
|
<Modal bind:this={modal}>
|
||||||
<CreateViewModal />
|
<GridCreateViewModal />
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
|
@ -5,14 +5,13 @@
|
||||||
import { viewsV2 } from "stores/backend"
|
import { viewsV2 } from "stores/backend"
|
||||||
import { LuceneUtils } from "@budibase/frontend-core"
|
import { LuceneUtils } from "@budibase/frontend-core"
|
||||||
|
|
||||||
const { filter, sort, table } = getContext("grid")
|
const { filter, sort, definition } = getContext("grid")
|
||||||
|
|
||||||
$: query = LuceneUtils.buildLuceneQuery($filter)
|
$: query = LuceneUtils.buildLuceneQuery($filter)
|
||||||
|
|
||||||
let name
|
let name
|
||||||
|
|
||||||
$: console.log($table)
|
$: views = Object.keys($definition?.views || {})
|
||||||
$: views = Object.keys($table?.views || {})
|
|
||||||
$: nameExists = views.includes(name?.trim())
|
$: nameExists = views.includes(name?.trim())
|
||||||
|
|
||||||
const saveView = async () => {
|
const saveView = async () => {
|
||||||
|
@ -20,14 +19,14 @@
|
||||||
try {
|
try {
|
||||||
const newView = await viewsV2.create({
|
const newView = await viewsV2.create({
|
||||||
name,
|
name,
|
||||||
tableId: $table._id,
|
tableId: $definition._id,
|
||||||
query,
|
query,
|
||||||
sort: {
|
sort: {
|
||||||
field: $sort.column,
|
field: $sort.column,
|
||||||
order: $sort.order,
|
order: $sort.order,
|
||||||
},
|
},
|
||||||
schema: $table.schema,
|
schema: $definition.schema,
|
||||||
primaryDisplay: $table.primaryDisplay,
|
primaryDisplay: $definition.primaryDisplay,
|
||||||
})
|
})
|
||||||
notifications.success(`View ${name} created`)
|
notifications.success(`View ${name} created`)
|
||||||
$goto(`../../view/v2/${newView.id}`)
|
$goto(`../../view/v2/${newView.id}`)
|
Loading…
Reference in New Issue