1
0
Fork 0
mirror of https://gitlab.com/bramw/baserow.git synced 2025-04-13 08:41:46 +00:00
bramw_baserow/web-frontend/modules/database/components/view/gallery/GalleryViewHeader.vue
2021-12-17 14:02:54 +00:00

148 lines
3.3 KiB
Vue

<template>
<ul v-if="!tableLoading" class="header__filter header__filter--full-width">
<li class="header__filter-item">
<a
ref="customizeContextLink"
class="header__filter-link"
@click="
$refs.customizeContext.toggle(
$refs.customizeContextLink,
'bottom',
'left',
4
)
"
>
<i class="header__filter-icon fas fa-cog"></i>
<span class="header__filter-name">{{
$t('galleryViewHeader.customizeCards')
}}</span>
</a>
<ViewFieldsContext
ref="customizeContext"
:fields="allFields"
:read-only="readOnly"
:field-options="fieldOptions"
@update-all-field-options="updateAllFieldOptions"
@update-field-options-of-field="updateFieldOptionsOfField"
@update-order="orderFieldOptions"
></ViewFieldsContext>
</li>
</ul>
</template>
<script>
import { mapGetters, mapState } from 'vuex'
import { notifyIf } from '@baserow/modules/core/utils/error'
import ViewFieldsContext from '@baserow/modules/database/components/view/ViewFieldsContext'
export default {
name: 'GalleryViewHeader',
components: { ViewFieldsContext },
props: {
database: {
type: Object,
required: true,
},
table: {
type: Object,
required: true,
},
view: {
type: Object,
required: true,
},
fields: {
type: Array,
required: true,
},
primary: {
type: Object,
required: true,
},
readOnly: {
type: Boolean,
required: true,
},
storePrefix: {
type: String,
required: true,
},
},
computed: {
allFields() {
return [this.primary].concat(this.fields)
},
...mapState({
tableLoading: (state) => state.table.loading,
}),
},
beforeCreate() {
this.$options.computed = {
...(this.$options.computed || {}),
...mapGetters({
fieldOptions:
this.$options.propsData.storePrefix +
'view/gallery/getAllFieldOptions',
}),
}
},
methods: {
async updateAllFieldOptions({ newFieldOptions, oldFieldOptions }) {
try {
await this.$store.dispatch(
this.storePrefix + 'view/gallery/updateAllFieldOptions',
{
newFieldOptions,
oldFieldOptions,
}
)
} catch (error) {
notifyIf(error, 'view')
}
},
async updateFieldOptionsOfField({ field, values, oldValues }) {
try {
await this.$store.dispatch(
this.storePrefix + 'view/gallery/updateFieldOptionsOfField',
{
field,
values,
oldValues,
}
)
} catch (error) {
notifyIf(error, 'view')
}
},
async orderFieldOptions({ order }) {
try {
await this.$store.dispatch(
this.storePrefix + 'view/gallery/updateFieldOptionsOrder',
{
order,
}
)
} catch (error) {
notifyIf(error, 'view')
}
},
},
}
</script>
<i18n>
{
"en":{
"galleryViewHeader":{
"customizeCards": "Customize cards"
}
},
"fr":{
"settings":{
"customizeCards": "Configurer les cartes"
}
}
}
</i18n>