koel/resources/assets/js/components/screens/UserListScreen.vue

88 lines
2.7 KiB
Vue
Raw Normal View History

2022-04-15 14:24:30 +00:00
<template>
2024-04-04 22:20:42 +00:00
<ScreenBase>
<template #header>
<ScreenHeader layout="collapsed">
Users
<template #controls>
2024-09-05 10:34:57 +00:00
<BtnGroup uppercase>
2024-04-04 22:20:42 +00:00
<Btn success @click="showAddUserForm">
<Icon :icon="faPlus" />
Add
</Btn>
<Btn v-if="canInvite" highlight @click="showInviteUserForm">Invite</Btn>
</BtnGroup>
</template>
</ScreenHeader>
</template>
<ul class="space-y-3">
<li v-for="user in users" :key="user.id">
<UserCard :user="user" />
</li>
</ul>
<template v-if="prospects.length">
<h2
class="px-0 pt-6 pb-3 uppercase tracking-widest text-center relative flex justify-center text-k-text-secondary"
data-testid="prospects-heading"
>
<i class="invited-heading-decoration" />
<span class="px-4 py-1 relative rounded-md border border-k-text-secondary">
Invited
</span>
<i class="invited-heading-decoration" />
</h2>
<ul class="space-y-3">
<li v-for="user in prospects" :key="user.id">
2022-12-02 16:17:37 +00:00
<UserCard :user="user" />
</li>
</ul>
2024-04-04 22:20:42 +00:00
</template>
</ScreenBase>
2022-04-15 14:24:30 +00:00
</template>
2022-04-15 17:00:08 +00:00
<script lang="ts" setup>
2022-07-15 07:23:55 +00:00
import { faPlus } from '@fortawesome/free-solid-svg-icons'
2022-04-15 14:24:30 +00:00
import isMobile from 'ismobilejs'
2023-08-20 22:35:58 +00:00
import { computed, defineAsyncComponent, onMounted, ref, toRef } from 'vue'
2022-04-15 14:24:30 +00:00
import { userStore } from '@/stores'
import { eventBus } from '@/utils'
2024-04-04 22:20:42 +00:00
import { useAuthorization } from '@/composables'
2022-04-15 14:24:30 +00:00
import ScreenHeader from '@/components/ui/ScreenHeader.vue'
import ControlsToggle from '@/components/ui/ScreenControlsToggle.vue'
import UserCard from '@/components/user/UserCard.vue'
2024-04-04 22:20:42 +00:00
import BtnGroup from '@/components/ui/form/BtnGroup.vue'
import ScreenBase from '@/components/screens/ScreenBase.vue'
2024-04-04 22:20:42 +00:00
const Btn = defineAsyncComponent(() => import('@/components/ui/form/Btn.vue'))
2022-04-15 14:24:30 +00:00
const { currentUser } = useAuthorization()
2023-08-20 22:35:58 +00:00
const allUsers = toRef(userStore.state, 'users')
2024-02-25 19:32:53 +00:00
const users = computed(() => allUsers
.value
.filter(({ is_prospect }) => !is_prospect)
.sort((a, b) => a.id === currentUser.value.id ? -1 : b.id === currentUser.value.id ? 1 : a.name.localeCompare(b.name))
)
2024-02-25 19:32:53 +00:00
2024-01-24 22:39:47 +00:00
const prospects = computed(() => allUsers.value.filter(({ is_prospect }) => is_prospect))
2023-08-20 22:35:58 +00:00
2024-02-25 19:32:53 +00:00
const canInvite = window.MAILER_CONFIGURED
2022-04-15 14:24:30 +00:00
2022-04-15 17:00:08 +00:00
const showAddUserForm = () => eventBus.emit('MODAL_SHOW_ADD_USER_FORM')
2023-08-20 22:35:58 +00:00
const showInviteUserForm = () => eventBus.emit('MODAL_SHOW_INVITE_USER_FORM')
2022-06-10 10:47:46 +00:00
onMounted(async () => await userStore.fetch())
2022-04-15 14:24:30 +00:00
</script>
2024-04-04 20:13:35 +00:00
<style lang="postcss" scoped>
2024-04-04 22:20:42 +00:00
.invited-heading-decoration {
@apply relative flex-1 before:absolute before:top-1/2;
@apply before:left-0 before:right-0 before:h-px before:opacity-20 before:bg-k-text-secondary;
2023-08-20 22:35:58 +00:00
}
2022-04-15 14:24:30 +00:00
</style>