mirror of
https://github.com/baserow/baserow.git
synced 2026-12-05 16:58:36 +00:00
* chore(deps): update Iconoir to 7.12.2 * test: update grid visibility selector for Iconoir 7 * fix: restore open and slashed eye icons * docs: document Iconoir 7 plugin changes
136 lines
3.4 KiB
Vue
136 lines
3.4 KiB
Vue
<template>
|
|
<div>
|
|
<a
|
|
ref="contextLink"
|
|
class="header__filter-link"
|
|
:class="{
|
|
'active active--error': hiddenFields.length > 0,
|
|
}"
|
|
@click="$refs.context.toggle($refs.contextLink, 'bottom', 'left', 4)"
|
|
>
|
|
<i class="header__filter-icon baserow-icon-eye-off"></i>
|
|
<span class="header__filter-name">{{
|
|
$t('gridViewHide.hideField', {
|
|
count: hiddenFields.length,
|
|
})
|
|
}}</span>
|
|
</a>
|
|
<ViewFieldsContext
|
|
ref="context"
|
|
:database="database"
|
|
:view="view"
|
|
:fields="fields"
|
|
:field-options="fieldOptions"
|
|
@update-all-field-options="updateAllFieldOptions"
|
|
@update-field-options-of-field="updateFieldOptionsOfField"
|
|
@update-order="orderFieldOptions"
|
|
></ViewFieldsContext>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import { filterHiddenFieldsFunction } from '@baserow/modules/database/utils/view'
|
|
import { notifyIf } from '@baserow/modules/core/utils/error'
|
|
import ViewFieldsContext from '@baserow/modules/database/components/view/ViewFieldsContext'
|
|
|
|
export default {
|
|
name: 'GridViewHide',
|
|
components: { ViewFieldsContext },
|
|
props: {
|
|
database: {
|
|
type: Object,
|
|
required: true,
|
|
},
|
|
fields: {
|
|
type: Array,
|
|
required: true,
|
|
},
|
|
view: {
|
|
type: Object,
|
|
required: true,
|
|
},
|
|
readOnly: {
|
|
type: Boolean,
|
|
required: true,
|
|
},
|
|
storePrefix: {
|
|
type: String,
|
|
required: true,
|
|
},
|
|
},
|
|
computed: {
|
|
hiddenFields() {
|
|
const isFieldHidden = filterHiddenFieldsFunction(this.fieldOptions)
|
|
return this.fields.filter((field) => isFieldHidden(field))
|
|
},
|
|
fieldOptions() {
|
|
return this.$store.getters[
|
|
this.storePrefix + 'view/grid/getAllFieldOptions'
|
|
]
|
|
},
|
|
},
|
|
methods: {
|
|
async updateAllFieldOptions({ newFieldOptions, oldFieldOptions }) {
|
|
try {
|
|
await this.$store.dispatch(
|
|
this.storePrefix + 'view/grid/updateAllFieldOptions',
|
|
{
|
|
newFieldOptions,
|
|
oldFieldOptions,
|
|
readOnly:
|
|
this.readOnly ||
|
|
!this.$hasPermission(
|
|
'database.table.view.update_field_options',
|
|
this.view,
|
|
this.database.workspace.id
|
|
),
|
|
}
|
|
)
|
|
} catch (error) {
|
|
notifyIf(error, 'view')
|
|
}
|
|
},
|
|
async updateFieldOptionsOfField({ field, values, oldValues }) {
|
|
try {
|
|
await this.$store.dispatch(
|
|
this.storePrefix + 'view/grid/updateFieldOptionsOfField',
|
|
{
|
|
field,
|
|
values,
|
|
oldValues,
|
|
readOnly:
|
|
this.readOnly ||
|
|
!this.$hasPermission(
|
|
'database.table.view.update_field_options',
|
|
this.view,
|
|
this.database.workspace.id
|
|
),
|
|
}
|
|
)
|
|
} catch (error) {
|
|
notifyIf(error, 'view')
|
|
}
|
|
},
|
|
async orderFieldOptions({ order }) {
|
|
try {
|
|
await this.$store.dispatch(
|
|
this.storePrefix + 'view/grid/updateFieldOptionsOrder',
|
|
{
|
|
order,
|
|
readOnly:
|
|
this.readOnly ||
|
|
!this.$hasPermission(
|
|
'database.table.view.update_field_options',
|
|
this.view,
|
|
this.database.workspace.id
|
|
),
|
|
}
|
|
)
|
|
} catch (error) {
|
|
notifyIf(error, 'view')
|
|
}
|
|
},
|
|
},
|
|
}
|
|
</script>
|