Use global context when requesting client context and no component is selected

This commit is contained in:
Andrew Kingston 2025-01-14 15:44:10 +00:00
parent 19974f24ff
commit cc765ef6b4
No known key found for this signature in database
4 changed files with 10 additions and 6 deletions

View File

@ -15,6 +15,7 @@ export const ActionTypes = {
export const DNDPlaceholderID = "dnd-placeholder" export const DNDPlaceholderID = "dnd-placeholder"
export const ScreenslotType = "screenslot" export const ScreenslotType = "screenslot"
export const ScreenslotID = "screenslot"
export const GridRowHeight = 24 export const GridRowHeight = 24
export const GridColumns = 12 export const GridColumns = 12
export const GridSpacing = 4 export const GridSpacing = 4

View File

@ -86,8 +86,10 @@ const loadBudibase = async () => {
dndStore.actions.reset() dndStore.actions.reset()
} }
} else if (type === "request-context") { } else if (type === "request-context") {
const { selectedComponentInstance } = get(componentStore) const { selectedComponentInstance, screenslotInstance } =
const context = selectedComponentInstance?.getDataContext() get(componentStore)
const instance = selectedComponentInstance || screenslotInstance
const context = instance?.getDataContext()
let stringifiedContext = null let stringifiedContext = null
try { try {
stringifiedContext = JSON.stringify(context) stringifiedContext = JSON.stringify(context)

View File

@ -6,7 +6,7 @@ import { screenStore } from "./screens"
import { builderStore } from "./builder" import { builderStore } from "./builder"
import Router from "../components/Router.svelte" import Router from "../components/Router.svelte"
import * as AppComponents from "../components/app/index.js" import * as AppComponents from "../components/app/index.js"
import { ScreenslotType } from "../constants.js" import { ScreenslotID, ScreenslotType } from "../constants.js"
export const BudibasePrefix = "@budibase/standard-components/" export const BudibasePrefix = "@budibase/standard-components/"
@ -43,6 +43,7 @@ const createComponentStore = () => {
selectedComponentDefinition: definition, selectedComponentDefinition: definition,
selectedComponentPath: selectedPath?.map(component => component._id), selectedComponentPath: selectedPath?.map(component => component._id),
mountedComponentCount: Object.keys($store.mountedComponents).length, mountedComponentCount: Object.keys($store.mountedComponents).length,
screenslotInstance: $store.mountedComponents[ScreenslotID],
} }
} }
) )

View File

@ -7,7 +7,7 @@ import { dndIndex, dndParent, dndIsNewComponent, dndBounds } from "./dnd.js"
import { RoleUtils } from "@budibase/frontend-core" import { RoleUtils } from "@budibase/frontend-core"
import { findComponentById, findComponentParent } from "../utils/components.js" import { findComponentById, findComponentParent } from "../utils/components.js"
import { Helpers } from "@budibase/bbui" import { Helpers } from "@budibase/bbui"
import { DNDPlaceholderID } from "constants" import { DNDPlaceholderID, ScreenslotID, ScreenslotType } from "constants"
const createScreenStore = () => { const createScreenStore = () => {
const store = derived( const store = derived(
@ -163,8 +163,8 @@ const createScreenStore = () => {
_component: "@budibase/standard-components/layout", _component: "@budibase/standard-components/layout",
_children: [ _children: [
{ {
_component: "screenslot", _component: ScreenslotType,
_id: "screenslot", _id: ScreenslotID,
_styles: { _styles: {
normal: { normal: {
flex: "1 1 auto", flex: "1 1 auto",