mirror of
https://github.com/baserow/baserow.git
synced 2026-12-04 16:28:31 +00:00
* revert: undo unnecessary frontend changes fromf6a7d302fRevert all frontend changes introduced in "fix: bug in public view with hidden group by" (f6a7d302f). The backend changes from that commit are kept as they are the actual fix for the public view bug. The reverted frontend changes caused a regression where group bys would flicker (disappear and reappear) when changing the group by order, because activeGroupBys was being cleared at the start of every refresh. * fix: public view crash when group by is added or removed Add ViewType.forceViewRefresh() method that handles updating the view, fields, and (for grid views) activeGroupBys atomically during a force_view_refresh realtime event. This prevents components from accessing fields that have been removed or haven't been added yet. Also fix LinkRowFieldType.isEqual crashing with null/undefined values when rows have no linked items. * fix: inconsistency in counting hidden fields in grid view * fix issue deleting/restoring group bys
119 lines
3.0 KiB
JavaScript
119 lines
3.0 KiB
JavaScript
import { mapGetters } from 'vuex'
|
|
import { notifyIf } from '@baserow/modules/core/utils/error'
|
|
import { GRID_VIEW_MIN_FIELD_WIDTH } from '@baserow/modules/database/constants'
|
|
|
|
export default {
|
|
props: {
|
|
storePrefix: {
|
|
type: String,
|
|
required: true,
|
|
},
|
|
},
|
|
data() {
|
|
return {
|
|
gridViewRowDetailsWidth: 72,
|
|
}
|
|
},
|
|
computed: {
|
|
activeGroupByWidth() {
|
|
return this.activeGroupBys.reduce(
|
|
(width, groupBy) => width + groupBy.width,
|
|
0
|
|
)
|
|
},
|
|
GRID_VIEW_MIN_FIELD_WIDTH() {
|
|
return GRID_VIEW_MIN_FIELD_WIDTH
|
|
},
|
|
fieldOptions() {
|
|
return this.$store.getters[
|
|
this.storePrefix + 'view/grid/getAllFieldOptions'
|
|
]
|
|
},
|
|
publicGrid() {
|
|
return this.$store.getters['page/view/public/getIsPublic']
|
|
},
|
|
activeGroupBys() {
|
|
return this.$store.getters[
|
|
this.storePrefix + 'view/grid/getActiveGroupBys'
|
|
]
|
|
},
|
|
},
|
|
methods: {
|
|
getFieldWidth(field) {
|
|
const fieldId = field?.id
|
|
const options = fieldId ? this.fieldOptions[fieldId] : undefined
|
|
|
|
if (options?.hidden && !field.primary) {
|
|
return 0
|
|
}
|
|
|
|
return options?.width ?? 200
|
|
},
|
|
async moveFieldWidth(field, width) {
|
|
await this.$store.dispatch(
|
|
this.storePrefix + 'view/grid/setFieldOptionsOfField',
|
|
{
|
|
field,
|
|
values: { width },
|
|
}
|
|
)
|
|
},
|
|
async updateFieldWidth(
|
|
field,
|
|
view,
|
|
database,
|
|
readOnly,
|
|
{ width, oldWidth }
|
|
) {
|
|
try {
|
|
await this.$store.dispatch(
|
|
`${this.storePrefix}view/grid/updateFieldOptionsOfField`,
|
|
{
|
|
field,
|
|
values: { width },
|
|
oldValues: { width: oldWidth },
|
|
readOnly:
|
|
readOnly ||
|
|
!this.$hasPermission(
|
|
'database.table.view.update_field_options',
|
|
view,
|
|
database.workspace.id
|
|
),
|
|
}
|
|
)
|
|
} catch (error) {
|
|
notifyIf(error, 'field')
|
|
}
|
|
},
|
|
async moveGroupWidth(groupBy, view, width) {
|
|
await this.$store.dispatch('view/forceUpdateGroupBy', {
|
|
groupBy,
|
|
values: { width },
|
|
})
|
|
},
|
|
async updateGroupWidth(groupBy, view, database, readOnly, { width }) {
|
|
// The provided group by can be an object of the `activeGroupBys`, which not
|
|
// actually the same. Because active group by width has already been set using
|
|
// the `moveGroupWidth`, we would not want to update the real one so that the
|
|
// width change is applied there as well.
|
|
const sourceGroupBy = view.group_bys.find((gb) => gb.id === groupBy.id)
|
|
|
|
try {
|
|
await this.$store.dispatch(`view/updateGroupBy`, {
|
|
groupBy: sourceGroupBy,
|
|
values: { width },
|
|
readOnly:
|
|
readOnly ||
|
|
!this.$hasPermission(
|
|
'database.table.view.group_by.update',
|
|
view,
|
|
database.workspace.id
|
|
),
|
|
})
|
|
} catch (error) {
|
|
notifyIf(error, 'field')
|
|
}
|
|
},
|
|
},
|
|
}
|