Navigation updates
This commit is contained in:
parent
a1f35be908
commit
ea458639b3
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
export let query = {}
|
export let query = {}
|
||||||
export let data = []
|
export let data = []
|
||||||
|
export let editRows = false
|
||||||
|
|
||||||
let loading = false
|
let loading = false
|
||||||
let error = false
|
let error = false
|
||||||
|
@ -12,7 +13,14 @@
|
||||||
{#if error}
|
{#if error}
|
||||||
<div class="errors">{error}</div>
|
<div class="errors">{error}</div>
|
||||||
{/if}
|
{/if}
|
||||||
<Table schema={query.schema} {data} {loading} {type} rowCount={5} />
|
<Table
|
||||||
|
schema={query.schema}
|
||||||
|
{data}
|
||||||
|
{loading}
|
||||||
|
{type}
|
||||||
|
rowCount={5}
|
||||||
|
allowEditing={editRows}
|
||||||
|
/>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.errors {
|
.errors {
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
export let rowCount
|
export let rowCount
|
||||||
export let disableSorting = false
|
export let disableSorting = false
|
||||||
export let customPlaceholder = false
|
export let customPlaceholder = false
|
||||||
|
export let allowEditing = true
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
|
|
||||||
|
@ -109,6 +110,7 @@
|
||||||
{rowCount}
|
{rowCount}
|
||||||
{disableSorting}
|
{disableSorting}
|
||||||
{customPlaceholder}
|
{customPlaceholder}
|
||||||
|
{allowEditing}
|
||||||
showAutoColumns={!hideAutocolumns}
|
showAutoColumns={!hideAutocolumns}
|
||||||
on:clickrelationship={e => selectRelationship(e.detail)}
|
on:clickrelationship={e => selectRelationship(e.detail)}
|
||||||
on:sort
|
on:sort
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
import { store } from "builderStore"
|
import { store } from "builderStore"
|
||||||
import { API } from "api"
|
import { API } from "api"
|
||||||
|
|
||||||
|
export let disabled = false
|
||||||
|
|
||||||
let revertModal
|
let revertModal
|
||||||
let appName
|
let appName
|
||||||
|
|
||||||
|
@ -34,6 +36,7 @@
|
||||||
size="M"
|
size="M"
|
||||||
tooltip="Revert changes"
|
tooltip="Revert changes"
|
||||||
on:click={revertModal.show}
|
on:click={revertModal.show}
|
||||||
|
{disabled}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Modal bind:this={revertModal}>
|
<Modal bind:this={revertModal}>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script>
|
<script>
|
||||||
import { goto, beforeUrlChange, route, getDirection } from "@roxi/routify"
|
import { goto, beforeUrlChange, route } from "@roxi/routify"
|
||||||
import {
|
import {
|
||||||
Icon,
|
Icon,
|
||||||
Select,
|
Select,
|
||||||
|
@ -29,13 +29,14 @@
|
||||||
import { fieldsToSchema, schemaToFields } from "helpers/data/utils"
|
import { fieldsToSchema, schemaToFields } from "helpers/data/utils"
|
||||||
import AccessLevelSelect from "./AccessLevelSelect.svelte"
|
import AccessLevelSelect from "./AccessLevelSelect.svelte"
|
||||||
|
|
||||||
// $: lastRoute = $route.last
|
|
||||||
// $: console.log("lastRoute", lastRoute)
|
|
||||||
// $: direction = getDirection($route, lastRoute)
|
|
||||||
// $: console.log("directioon ", direction)
|
|
||||||
|
|
||||||
export let query
|
export let query
|
||||||
|
|
||||||
|
const resumeNavigation = () => {
|
||||||
|
if (typeof navigateTo == "string") {
|
||||||
|
$goto(typeof navigateTo == "string" ? `${navigateTo}` : navigateTo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const transformerDocs = "https://docs.budibase.com/docs/transformers"
|
const transformerDocs = "https://docs.budibase.com/docs/transformers"
|
||||||
|
|
||||||
let fields = query?.schema ? schemaToFields(query.schema) : []
|
let fields = query?.schema ? schemaToFields(query.schema) : []
|
||||||
|
@ -45,21 +46,19 @@
|
||||||
let currentTab = "JSON"
|
let currentTab = "JSON"
|
||||||
let saveModal
|
let saveModal
|
||||||
let queryStr = JSON.stringify(query)
|
let queryStr = JSON.stringify(query)
|
||||||
let discard = false
|
let override = false
|
||||||
|
|
||||||
let navigateTo = null
|
let navigateTo = null
|
||||||
$: console.log("GO ", navigateTo)
|
|
||||||
$: console.log("DISCARD ", discard)
|
|
||||||
|
|
||||||
$beforeUrlChange((event, route) => {
|
$beforeUrlChange((event, targetRoute) => {
|
||||||
const updated = JSON.stringify(query)
|
const updated = JSON.stringify(query)
|
||||||
console.log("route ", route)
|
|
||||||
console.log("event ", event)
|
if (updated !== queryStr && !override) {
|
||||||
// if (updated !== queryStr && !discard) {
|
navigateTo = event.type == "pushstate" ? event.url : null
|
||||||
// navigateTo = event.url
|
saveModal.show()
|
||||||
// saveModal.show()
|
return false
|
||||||
// return false
|
} else return true
|
||||||
// } else return true
|
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -130,16 +129,13 @@
|
||||||
// return the query.
|
// return the query.
|
||||||
async function saveQuery() {
|
async function saveQuery() {
|
||||||
try {
|
try {
|
||||||
// const { _id } = await queries.save(query.datasourceId, query)
|
|
||||||
const response = await queries.save(query.datasourceId, query)
|
const response = await queries.save(query.datasourceId, query)
|
||||||
saveId = response._id
|
saveId = response._id
|
||||||
|
|
||||||
// notifications.success(`Query saved successfully`)
|
if (response?._rev) {
|
||||||
|
queryStr = JSON.stringify(query)
|
||||||
|
}
|
||||||
|
|
||||||
// // Go to the correct URL if we just created a new query
|
|
||||||
// if (!query._rev) {
|
|
||||||
// $goto(`../../${_id}`)
|
|
||||||
// }
|
|
||||||
return response
|
return response
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
notifications.error("Error saving query")
|
notifications.error("Error saving query")
|
||||||
|
@ -150,8 +146,7 @@
|
||||||
<Modal
|
<Modal
|
||||||
bind:this={saveModal}
|
bind:this={saveModal}
|
||||||
on:hide={() => {
|
on:hide={() => {
|
||||||
console.log("running")
|
navigateTo = null
|
||||||
//navigateTo = null
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<ModalContent
|
<ModalContent
|
||||||
|
@ -160,15 +155,13 @@
|
||||||
cancelText="Discard Changes"
|
cancelText="Discard Changes"
|
||||||
size="L"
|
size="L"
|
||||||
onConfirm={async () => {
|
onConfirm={async () => {
|
||||||
console.log("CONFIRM")
|
const saveResponse = await saveQuery()
|
||||||
saveQuery() //needs ascertain success?
|
override = true
|
||||||
discard = true
|
resumeNavigation()
|
||||||
$goto(`${navigateTo}`)
|
|
||||||
}}
|
}}
|
||||||
onCancel={() => {
|
onCancel={async () => {
|
||||||
console.log("CANCEL")
|
override = true
|
||||||
discard = true
|
resumeNavigation()
|
||||||
$goto(`${navigateTo}`)
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Body>Leaving this section will mean losing and changes to your query</Body>
|
<Body>Leaving this section will mean losing and changes to your query</Body>
|
||||||
|
@ -183,7 +176,13 @@
|
||||||
<div class="config">
|
<div class="config">
|
||||||
<div class="config-field">
|
<div class="config-field">
|
||||||
<Label>Query Name</Label>
|
<Label>Query Name</Label>
|
||||||
<Input bind:value={query.name} />
|
<Input
|
||||||
|
value={query.name}
|
||||||
|
on:input={e => {
|
||||||
|
let newValue = e.target.value || ""
|
||||||
|
query.name = newValue.trim()
|
||||||
|
}}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
{#if queryConfig}
|
{#if queryConfig}
|
||||||
<div class="config-field">
|
<div class="config-field">
|
||||||
|
@ -268,9 +267,10 @@
|
||||||
disabled={queryInvalid}
|
disabled={queryInvalid}
|
||||||
on:click={async () => {
|
on:click={async () => {
|
||||||
const saveResponse = await saveQuery()
|
const saveResponse = await saveQuery()
|
||||||
|
notifications.success(`Query saved successfully`)
|
||||||
// Go to the correct URL if we just created a new query
|
// Go to the correct URL if we just created a new query
|
||||||
if (saveResponse && !saveResponse._rev) {
|
if (!query._rev) {
|
||||||
$goto(`../../${saveResponse._id}`)
|
$goto(`../../${query._id}`)
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|
Loading…
Reference in New Issue