Clean up data source context and remove explicit button actions for pagination
This commit is contained in:
parent
da40086c0b
commit
d9923e1e98
|
@ -1,38 +0,0 @@
|
|||
<script>
|
||||
import { Select, Label } from "@budibase/bbui"
|
||||
import { currentAsset, store } from "builderStore"
|
||||
import { getActionProviderComponents } from "builderStore/dataBinding"
|
||||
|
||||
export let parameters
|
||||
|
||||
$: actionProviders = getActionProviderComponents(
|
||||
$currentAsset,
|
||||
$store.selectedComponentId,
|
||||
"NextPage"
|
||||
)
|
||||
</script>
|
||||
|
||||
<div class="root">
|
||||
<Label small>Data Provider</Label>
|
||||
<Select
|
||||
bind:value={parameters.componentId}
|
||||
options={actionProviders}
|
||||
getOptionLabel={(x) => x._instanceName}
|
||||
getOptionValue={(x) => x._id}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.root {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.root :global(> div) {
|
||||
flex: 1;
|
||||
margin-left: var(--spacing-l);
|
||||
}
|
||||
</style>
|
|
@ -1,38 +0,0 @@
|
|||
<script>
|
||||
import { Select, Label } from "@budibase/bbui"
|
||||
import { currentAsset, store } from "builderStore"
|
||||
import { getActionProviderComponents } from "builderStore/dataBinding"
|
||||
|
||||
export let parameters
|
||||
|
||||
$: actionProviders = getActionProviderComponents(
|
||||
$currentAsset,
|
||||
$store.selectedComponentId,
|
||||
"PrevPage"
|
||||
)
|
||||
</script>
|
||||
|
||||
<div class="root">
|
||||
<Label small>Data Provider</Label>
|
||||
<Select
|
||||
bind:value={parameters.componentId}
|
||||
options={actionProviders}
|
||||
getOptionLabel={(x) => x._instanceName}
|
||||
getOptionValue={(x) => x._id}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.root {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.root :global(> div) {
|
||||
flex: 1;
|
||||
margin-left: var(--spacing-l);
|
||||
}
|
||||
</style>
|
|
@ -6,8 +6,6 @@ import TriggerAutomation from "./TriggerAutomation.svelte"
|
|||
import ValidateForm from "./ValidateForm.svelte"
|
||||
import LogIn from "./LogIn.svelte"
|
||||
import LogOut from "./LogOut.svelte"
|
||||
import NextPage from "./NextPage.svelte"
|
||||
import PrevPage from "./PrevPage.svelte"
|
||||
|
||||
// defines what actions are available, when adding a new one
|
||||
// the component is the setup panel for the action
|
||||
|
@ -47,12 +45,4 @@ export default [
|
|||
name: "Log Out",
|
||||
component: LogOut,
|
||||
},
|
||||
{
|
||||
name: "Next Page",
|
||||
component: NextPage,
|
||||
},
|
||||
{
|
||||
name: "Previous Page",
|
||||
component: PrevPage,
|
||||
},
|
||||
]
|
||||
|
|
|
@ -5,6 +5,4 @@ export const TableNames = {
|
|||
export const ActionTypes = {
|
||||
ValidateForm: "ValidateForm",
|
||||
RefreshDatasource: "RefreshDatasource",
|
||||
NextPage: "NextPage",
|
||||
PrevPage: "PrevPage",
|
||||
}
|
||||
|
|
|
@ -16,27 +16,27 @@ const saveRowHandler = async (action, context) => {
|
|||
}
|
||||
}
|
||||
|
||||
const deleteRowHandler = async (action) => {
|
||||
const deleteRowHandler = async action => {
|
||||
const { tableId, revId, rowId } = action.parameters
|
||||
if (tableId && revId && rowId) {
|
||||
await deleteRow({ tableId, rowId, revId })
|
||||
}
|
||||
}
|
||||
|
||||
const triggerAutomationHandler = async (action) => {
|
||||
const triggerAutomationHandler = async action => {
|
||||
const { fields } = action.parameters
|
||||
if (fields) {
|
||||
await triggerAutomation(action.parameters.automationId, fields)
|
||||
}
|
||||
}
|
||||
|
||||
const navigationHandler = (action) => {
|
||||
const navigationHandler = action => {
|
||||
if (action.parameters.url) {
|
||||
routeStore.actions.navigate(action.parameters.url)
|
||||
}
|
||||
}
|
||||
|
||||
const queryExecutionHandler = async (action) => {
|
||||
const queryExecutionHandler = async action => {
|
||||
const { datasourceId, queryId, queryParams } = action.parameters
|
||||
await executeQuery({
|
||||
datasourceId,
|
||||
|
@ -68,23 +68,7 @@ const refreshDatasourceHandler = async (action, context) => {
|
|||
)
|
||||
}
|
||||
|
||||
const nextPageHandler = async (action, context) => {
|
||||
return await executeActionHandler(
|
||||
context,
|
||||
action.parameters.componentId,
|
||||
ActionTypes.NextPage
|
||||
)
|
||||
}
|
||||
|
||||
const prevPageHandler = async (action, context) => {
|
||||
return await executeActionHandler(
|
||||
context,
|
||||
action.parameters.componentId,
|
||||
ActionTypes.PrevPage
|
||||
)
|
||||
}
|
||||
|
||||
const loginHandler = async (action) => {
|
||||
const loginHandler = async action => {
|
||||
const { email, password } = action.parameters
|
||||
await authStore.actions.logIn({ email, password })
|
||||
}
|
||||
|
@ -103,8 +87,6 @@ const handlerMap = {
|
|||
["Refresh Datasource"]: refreshDatasourceHandler,
|
||||
["Log In"]: loginHandler,
|
||||
["Log Out"]: logoutHandler,
|
||||
["Next Page"]: nextPageHandler,
|
||||
["Previous Page"]: prevPageHandler,
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -114,10 +96,9 @@ const handlerMap = {
|
|||
export const enrichButtonActions = (actions, context) => {
|
||||
// Prevent button actions in the builder preview
|
||||
if (get(builderStore).inBuilder) {
|
||||
// TODO uncomment
|
||||
// return () => {}
|
||||
return () => {}
|
||||
}
|
||||
const handlers = actions.map((def) => handlerMap[def["##eventHandlerType"]])
|
||||
const handlers = actions.map(def => handlerMap[def["##eventHandlerType"]])
|
||||
return async () => {
|
||||
for (let i = 0; i < handlers.length; i++) {
|
||||
try {
|
||||
|
|
|
@ -1384,7 +1384,6 @@
|
|||
"icon": "Data",
|
||||
"styleable": false,
|
||||
"hasChildren": true,
|
||||
"actions": ["NextPage", "PrevPage"],
|
||||
"settings": [
|
||||
{
|
||||
"type": "dataSource",
|
||||
|
|
|
@ -54,25 +54,8 @@
|
|||
callback: () => fetchData(dataSource),
|
||||
metadata: { dataSource },
|
||||
},
|
||||
{
|
||||
type: ActionTypes.NextPage,
|
||||
callback: () => nextPage(),
|
||||
},
|
||||
{
|
||||
type: ActionTypes.PrevPage,
|
||||
callback: () => prevPage(),
|
||||
},
|
||||
]
|
||||
$: dataContext = {
|
||||
rows,
|
||||
schema,
|
||||
rowsLength: rows.length,
|
||||
loading,
|
||||
loaded,
|
||||
pageNumber: pageNumber + 1,
|
||||
hasNextPage,
|
||||
hasPrevPage,
|
||||
}
|
||||
$: dataContext = { rows, schema, rowsLength: rows.length }
|
||||
|
||||
const getSortType = (schema, sortColumn) => {
|
||||
if (!schema || !sortColumn || !schema[sortColumn]) {
|
||||
|
|
Loading…
Reference in New Issue