1
0
Fork 0
mirror of https://gitlab.com/bramw/baserow.git synced 2025-04-27 14:06:13 +00:00
bramw_baserow/web-frontend/modules/database/mixins/collaboratorName.js
2022-09-06 15:32:12 +00:00

29 lines
841 B
JavaScript

export default {
methods: {
getCollaboratorName(collaboratorValue, store) {
if (store === undefined) {
store = this.$store
}
// If groups are unavailable, public views are served
const groups = store.getters['group/getAll']
if (groups.length === 0) {
return collaboratorValue.name
}
// Otherwise, get name from the store to reflect real-time updates
const user = store.getters['group/getUserById'](collaboratorValue.id)
if (user) {
return user.name
}
// Fallback if for some reason the user is missing from the store
return collaboratorValue.name
},
getCollaboratorNameInitials(collaboratorValue, store) {
return this.getCollaboratorName(collaboratorValue, store)
.slice(0, 1)
.toUpperCase()
},
},
}