feat: use getter and helper in other components as well
This commit is contained in:
parent
c4d7f6fdfa
commit
9de20b4c54
@ -44,8 +44,8 @@
|
|||||||
variant="secondary"
|
variant="secondary"
|
||||||
:shadow="false"
|
:shadow="false"
|
||||||
>
|
>
|
||||||
<img :src="userAvatar" alt="" class="avatar" width="40" height="40"/>
|
<img :src="authStore.avatarUrl" alt="" class="avatar" width="40" height="40"/>
|
||||||
<span class="username">{{ userInfo.name !== '' ? userInfo.name : userInfo.username }}</span>
|
<span class="username">{{ authStore.userDisplayName }}</span>
|
||||||
<span class="icon is-small">
|
<span class="icon is-small">
|
||||||
<icon icon="chevron-down"/>
|
<icon icon="chevron-down"/>
|
||||||
</span>
|
</span>
|
||||||
@ -80,7 +80,7 @@
|
|||||||
{{ $t('about.title') }}
|
{{ $t('about.title') }}
|
||||||
</dropdown-item>
|
</dropdown-item>
|
||||||
<dropdown-item
|
<dropdown-item
|
||||||
@click="logout()"
|
@click="authStore.logout()"
|
||||||
>
|
>
|
||||||
{{ $t('user.auth.logout') }}
|
{{ $t('user.auth.logout') }}
|
||||||
</dropdown-item>
|
</dropdown-item>
|
||||||
@ -117,8 +117,6 @@ const canWriteCurrentList = computed(() => baseStore.currentList.maxRight > Righ
|
|||||||
const menuActive = computed(() => baseStore.menuActive)
|
const menuActive = computed(() => baseStore.menuActive)
|
||||||
|
|
||||||
const authStore = useAuthStore()
|
const authStore = useAuthStore()
|
||||||
const userInfo = computed(() => authStore.info)
|
|
||||||
const userAvatar = computed(() => authStore.avatarUrl)
|
|
||||||
|
|
||||||
const configStore = useConfigStore()
|
const configStore = useConfigStore()
|
||||||
const imprintUrl = computed(() => configStore.legal.imprintUrl)
|
const imprintUrl = computed(() => configStore.legal.imprintUrl)
|
||||||
@ -136,10 +134,6 @@ onMounted(async () => {
|
|||||||
listTitle.value.style.setProperty('--nav-username-width', `${usernameWidth}px`)
|
listTitle.value.style.setProperty('--nav-username-width', `${usernameWidth}px`)
|
||||||
})
|
})
|
||||||
|
|
||||||
function logout() {
|
|
||||||
authStore.logout()
|
|
||||||
}
|
|
||||||
|
|
||||||
function openQuickActions() {
|
function openQuickActions() {
|
||||||
baseStore.setQuickActionsActive(true)
|
baseStore.setQuickActionsActive(true)
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,7 @@ import {success} from '@/message'
|
|||||||
import {useTaskStore} from '@/stores/tasks'
|
import {useTaskStore} from '@/stores/tasks'
|
||||||
|
|
||||||
import type {IUser} from '@/modelTypes/IUser'
|
import type {IUser} from '@/modelTypes/IUser'
|
||||||
|
import { getDisplayName } from '@/models/user'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
taskId: {
|
taskId: {
|
||||||
@ -65,7 +66,7 @@ const taskStore = useTaskStore()
|
|||||||
const {t} = useI18n({useScope: 'global'})
|
const {t} = useI18n({useScope: 'global'})
|
||||||
|
|
||||||
const listUserService = shallowReactive(new ListUserService())
|
const listUserService = shallowReactive(new ListUserService())
|
||||||
const foundUsers = ref([])
|
const foundUsers = ref<IUser[]>([])
|
||||||
const assignees = ref<IUser[]>([])
|
const assignees = ref<IUser[]>([])
|
||||||
let isAdding = false
|
let isAdding = false
|
||||||
|
|
||||||
@ -114,13 +115,14 @@ async function findUser(query: string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await listUserService.getAll({listId: props.listId}, {s: query})
|
const response = await listUserService.getAll({listId: props.listId}, {s: query}) as IUser[]
|
||||||
|
|
||||||
// Filter the results to not include users who are already assigned
|
// Filter the results to not include users who are already assigned
|
||||||
foundUsers.value = response.filter(({id}) => !includesById(assignees.value, id))
|
foundUsers.value = response
|
||||||
|
.filter(({id}) => !includesById(assignees.value, id))
|
||||||
.map(u => {
|
.map(u => {
|
||||||
// Users may not have a display name set, so we fall back on the username in that case
|
// Users may not have a display name set, so we fall back on the username in that case
|
||||||
u.name = u.name === '' ? u.username : u.name
|
u.name = getDisplayName(u)
|
||||||
return u
|
return u
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ export const AUTH_TYPES = {
|
|||||||
'LINK_SHARE': 2,
|
'LINK_SHARE': 2,
|
||||||
} as const
|
} as const
|
||||||
|
|
||||||
type AuthType = typeof AUTH_TYPES[keyof typeof AUTH_TYPES]
|
export type AuthType = typeof AUTH_TYPES[keyof typeof AUTH_TYPES]
|
||||||
|
|
||||||
export interface IUser extends IAbstract {
|
export interface IUser extends IAbstract {
|
||||||
id: number
|
id: number
|
||||||
|
Loading…
x
Reference in New Issue
Block a user