Type screenTemplating modal
This commit is contained in:
parent
c608243c40
commit
afa6ac211d
|
@ -2,6 +2,8 @@ import {
|
||||||
Datasource,
|
Datasource,
|
||||||
Table,
|
Table,
|
||||||
UIInternalDatasource,
|
UIInternalDatasource,
|
||||||
|
UITableResource,
|
||||||
|
UIViewResource,
|
||||||
ViewV2,
|
ViewV2,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
|
|
||||||
|
@ -31,13 +33,13 @@ export const datasourceSelect = {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const tableSelect = {
|
export const tableSelect = {
|
||||||
table: (table: Table) => ({
|
table: (table: Table): UITableResource => ({
|
||||||
type: "table",
|
type: "table",
|
||||||
label: table.name,
|
label: table.name,
|
||||||
tableId: table._id,
|
tableId: table._id!,
|
||||||
resourceId: table._id,
|
resourceId: table._id!,
|
||||||
}),
|
}),
|
||||||
viewV2: (view: ViewV2) => ({
|
viewV2: (view: ViewV2): UIViewResource => ({
|
||||||
type: "viewV2",
|
type: "viewV2",
|
||||||
id: view.id,
|
id: view.id,
|
||||||
label: view.name,
|
label: view.name,
|
||||||
|
|
|
@ -1,13 +1,23 @@
|
||||||
import { Screen } from "../Screen"
|
|
||||||
import { Component } from "../../Component"
|
|
||||||
import { generate } from "shortid"
|
|
||||||
import { makePropSafe as safe } from "@budibase/string-templates"
|
|
||||||
import { Utils } from "@budibase/frontend-core"
|
|
||||||
import { capitalise } from "@/helpers"
|
import { capitalise } from "@/helpers"
|
||||||
import getValidRoute from "../getValidRoute"
|
import { SourceOption } from "@/pages/builder/app/[application]/design/_components/NewScreen/utils"
|
||||||
import { getRowActionButtonTemplates } from "@/templates/rowActions"
|
import { getRowActionButtonTemplates } from "@/templates/rowActions"
|
||||||
|
import { Utils } from "@budibase/frontend-core"
|
||||||
|
import { makePropSafe as safe } from "@budibase/string-templates"
|
||||||
|
import { Screen as ScreenDoc, UIPermissions } from "@budibase/types"
|
||||||
|
import { generate } from "shortid"
|
||||||
|
import { Component } from "../../Component"
|
||||||
|
import getValidRoute from "../getValidRoute"
|
||||||
|
import { Screen } from "../Screen"
|
||||||
|
|
||||||
const modal = async ({ tableOrView, permissions, screens }) => {
|
const modal = async ({
|
||||||
|
tableOrView,
|
||||||
|
permissions,
|
||||||
|
screens,
|
||||||
|
}: {
|
||||||
|
tableOrView: SourceOption
|
||||||
|
permissions: UIPermissions
|
||||||
|
screens: ScreenDoc[]
|
||||||
|
}) => {
|
||||||
/*
|
/*
|
||||||
Create Row
|
Create Row
|
||||||
*/
|
*/
|
||||||
|
@ -94,7 +104,7 @@ const modal = async ({ tableOrView, permissions, screens }) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
// Generate button config including row actions
|
// Generate button config including row actions
|
||||||
let buttons = Utils.buildFormBlockButtonConfig({
|
const formButtons = Utils.buildFormBlockButtonConfig({
|
||||||
_id: editFormBlock._json._id,
|
_id: editFormBlock._json._id,
|
||||||
showDeleteButton: true,
|
showDeleteButton: true,
|
||||||
showSaveButton: true,
|
showSaveButton: true,
|
||||||
|
@ -106,7 +116,7 @@ const modal = async ({ tableOrView, permissions, screens }) => {
|
||||||
const rowActionButtons = await getRowActionButtonTemplates({
|
const rowActionButtons = await getRowActionButtonTemplates({
|
||||||
instance: editFormBlock.json(),
|
instance: editFormBlock.json(),
|
||||||
})
|
})
|
||||||
buttons = [...(buttons || []), ...rowActionButtons]
|
const buttons = [...(formButtons || []), ...rowActionButtons]
|
||||||
editFormBlock = editFormBlock.customProps({
|
editFormBlock = editFormBlock.customProps({
|
||||||
buttons,
|
buttons,
|
||||||
buttonsCollapsed: buttons.length > 5,
|
buttonsCollapsed: buttons.length > 5,
|
|
@ -1,7 +1,12 @@
|
||||||
import { makePropSafe as safe } from "@budibase/string-templates"
|
import { makePropSafe as safe } from "@budibase/string-templates"
|
||||||
import { Helpers } from "@budibase/bbui"
|
import { Helpers } from "@budibase/bbui"
|
||||||
import { cloneDeep } from "lodash"
|
import { cloneDeep } from "lodash"
|
||||||
import { SearchFilterGroup, UISearchFilter } from "@budibase/types"
|
import {
|
||||||
|
SearchFilterGroup,
|
||||||
|
UISearchFilter,
|
||||||
|
UITableResource,
|
||||||
|
UIViewResource,
|
||||||
|
} from "@budibase/types"
|
||||||
|
|
||||||
export const sleep = (ms: number) =>
|
export const sleep = (ms: number) =>
|
||||||
new Promise(resolve => setTimeout(resolve, ms))
|
new Promise(resolve => setTimeout(resolve, ms))
|
||||||
|
@ -131,7 +136,7 @@ export const domDebounce = (callback: Function) => {
|
||||||
export const buildFormBlockButtonConfig = (props?: {
|
export const buildFormBlockButtonConfig = (props?: {
|
||||||
_id?: string
|
_id?: string
|
||||||
actionType?: string
|
actionType?: string
|
||||||
dataSource?: { resourceId: string }
|
dataSource?: UITableResource | UIViewResource
|
||||||
notificationOverride?: boolean
|
notificationOverride?: boolean
|
||||||
actionUrl?: string
|
actionUrl?: string
|
||||||
showDeleteButton?: boolean
|
showDeleteButton?: boolean
|
||||||
|
|
|
@ -3,3 +3,18 @@ export interface UIEvent extends Omit<Event, "target"> {
|
||||||
key?: string
|
key?: string
|
||||||
target?: any
|
target?: any
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface UITableResource {
|
||||||
|
type: "table"
|
||||||
|
label: string
|
||||||
|
tableId: string
|
||||||
|
resourceId: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UIViewResource {
|
||||||
|
type: "viewV2"
|
||||||
|
id: string
|
||||||
|
label: string
|
||||||
|
tableId: string
|
||||||
|
resourceId: string
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue