1
0
Fork 0
mirror of https://gitlab.com/bramw/baserow.git synced 2025-04-26 05:37:13 +00:00
bramw_baserow/web-frontend/modules/database/mixins/collaboratorName.js

29 lines
861 B
JavaScript

export default {
methods: {
getCollaboratorName(collaboratorValue, store) {
if (store === undefined) {
store = this.$store
}
// If workspaces are unavailable, public views are served
const workspaces = store.getters['workspace/getAll']
if (workspaces.length === 0) {
return collaboratorValue.name
}
// Otherwise, get name from the store to reflect real-time updates
const user = store.getters['workspace/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()
},
},
}