1
0
Fork 0
mirror of https://gitlab.com/bramw/baserow.git synced 2025-04-23 12:50:16 +00:00
bramw_baserow/web-frontend/modules/builder/components/page/PreviewNavigationBar.vue
2023-08-04 14:29:34 +00:00

65 lines
1.6 KiB
Vue

<template>
<div class="preview-navigation-bar">
<div />
<div class="preview-navigation-bar__address-bar">
<template v-for="pathPart in splitPath">
<input
v-if="pathPart.type === 'variable'"
:key="pathPart.key"
class="preview-navigation-bar__address-bar-parameter"
:class="`preview-navigation-bar__address-bar-parameter--${
paramTypeMap[pathPart.value]
}`"
:value="pageParameters[pathPart.value]"
@input="
actionSetParameter({
name: pathPart.value,
value: $event.target.value,
})
"
/>
<div
v-else
:key="pathPart.key"
class="preview-navigation-bar__address-bar-path"
>
{{ pathPart.value }}
</div>
</template>
</div>
<div />
</div>
</template>
<script>
import { mapGetters, mapActions } from 'vuex'
import { splitPath } from '@baserow/modules/builder/utils/path'
export default {
props: {
page: {
type: Object,
required: true,
},
},
computed: {
...mapGetters({
pageParameters: 'pageParameter/getParameters',
}),
splitPath() {
return splitPath(this.page.path).map((pathPart, index) => ({
...pathPart,
key: `${pathPart.value}-${index}`,
}))
},
paramTypeMap() {
return Object.fromEntries(
this.page.path_params.map(({ name, type }) => [name, type])
)
},
},
methods: {
...mapActions({ actionSetParameter: 'pageParameter/setParameter' }),
},
}
</script>