1
0
mirror of https://gitlab.com/bramw/baserow.git synced 2024-11-22 07:42:36 +00:00
bramw_baserow/web-frontend/modules/builder/components/page/PageTemplateContent.vue
2024-10-17 15:49:51 +00:00

117 lines
3.0 KiB
Vue

<template>
<div v-if="page" :key="page.id" class="page-template">
<PageHeader :page="page" />
<div class="layout__col-2-2 page-editor__content">
<div :style="{ width: `calc(100% - ${panelWidth}px)` }">
<PagePreview />
</div>
<div
class="page-editor__side-panel"
:style="{ width: `${panelWidth}px` }"
>
<PageSidePanels />
</div>
</div>
</div>
</template>
<script>
import PageHeader from '@baserow/modules/builder/components/page/header/PageHeader'
import PagePreview from '@baserow/modules/builder/components/page/PagePreview'
import PageSidePanels from '@baserow/modules/builder/components/page/PageSidePanels'
import ApplicationBuilderFormulaInput from '@baserow/modules/builder/components/ApplicationBuilderFormulaInput'
import { DataProviderType } from '@baserow/modules/core/dataProviderTypes'
import _ from 'lodash'
const mode = 'editing'
export default {
name: 'PageTemplate',
components: { PagePreview, PageHeader, PageSidePanels },
provide() {
return {
workspace: this.workspace,
builder: this.builder,
page: this.page,
mode,
formulaComponent: ApplicationBuilderFormulaInput,
applicationContext: { builder: this.builder, page: this.page, mode },
}
},
props: {
workspace: {
type: Object,
required: true,
},
builder: {
type: Object,
required: true,
},
page: {
type: Object,
required: true,
},
mode: {
type: String,
required: true,
},
},
data() {
return { panelWidth: 300 }
},
computed: {
applicationContext() {
return {
builder: this.builder,
page: this.page,
mode,
}
},
sharedPage() {
return this.$store.getters['page/getSharedPage'](this.builder)
},
sharedDataSources() {
return this.$store.getters['dataSource/getPageDataSources'](
this.sharedPage
)
},
dataSources() {
return this.$store.getters['dataSource/getPageDataSources'](this.page)
},
dispatchContext() {
return DataProviderType.getAllDataSourceDispatchContext(
this.$registry.getAll('builderDataProvider'),
this.applicationContext
)
},
},
watch: {
dispatchContext: {
deep: true,
/**
* Update data source content on backend context changes
*/
handler(newDispatchContext, oldDispatchContext) {
if (!_.isEqual(newDispatchContext, oldDispatchContext)) {
this.$store.dispatch(
'dataSourceContent/debouncedFetchPageDataSourceContent',
{
page: this.page,
data: newDispatchContext,
mode: this.mode,
}
)
this.$store.dispatch(
'dataSourceContent/debouncedFetchPageDataSourceContent',
{
page: this.sharedPage,
data: newDispatchContext,
}
)
}
},
},
},
}
</script>