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

56 lines
1.8 KiB
Vue
Raw Normal View History

2022-04-15 14:24:30 +00:00
<template>
<section id="usersWrapper">
2022-04-15 17:00:08 +00:00
<ScreenHeader>
2022-04-15 14:24:30 +00:00
Users
2022-04-15 17:00:08 +00:00
<ControlsToggler :showing-controls="showingControls" @toggleControls="toggleControls"/>
2022-04-15 14:24:30 +00:00
<template v-slot:controls>
2022-04-15 17:00:08 +00:00
<BtnGroup uppercased v-if="showingControls || !isPhone">
2022-04-23 22:04:16 +00:00
<Btn class="btn-add" data-testid="add-user-btn" green @click="showAddUserForm">
2022-04-15 14:24:30 +00:00
<i class="fa fa-plus"></i>
Add
2022-04-15 17:00:08 +00:00
</Btn>
</BtnGroup>
2022-04-15 14:24:30 +00:00
</template>
2022-04-15 17:00:08 +00:00
</ScreenHeader>
2022-04-15 14:24:30 +00:00
<div class="main-scroll-wrap">
<div class="users">
2022-04-23 22:04:16 +00:00
<UserCard v-for="user in users" :key="user.id" :user="user" @editUser="showEditUserForm"/>
2022-04-15 14:24:30 +00:00
</div>
</div>
</section>
</template>
2022-04-15 17:00:08 +00:00
<script lang="ts" setup>
2022-04-15 14:24:30 +00:00
import isMobile from 'ismobilejs'
2022-04-23 22:04:16 +00:00
import { defineAsyncComponent, ref, toRef } from 'vue'
2022-04-15 14:24:30 +00:00
import { userStore } from '@/stores'
import { eventBus } from '@/utils'
2022-04-21 16:06:45 +00:00
const ScreenHeader = defineAsyncComponent(() => import('@/components/ui/ScreenHeader.vue'))
const ControlsToggler = defineAsyncComponent(() => import('@/components/ui/ScreenControlsToggler.vue'))
2022-04-21 18:39:18 +00:00
const Btn = defineAsyncComponent(() => import('@/components/ui/Btn.vue'))
2022-04-21 16:06:45 +00:00
const BtnGroup = defineAsyncComponent(() => import('@/components/ui/BtnGroup.vue'))
2022-04-23 21:50:05 +00:00
const UserCard = defineAsyncComponent(() => import('@/components/user/UserCard.vue'))
2022-04-15 14:24:30 +00:00
2022-04-23 22:04:16 +00:00
const users = toRef(userStore.state, 'users')
2022-04-15 17:00:08 +00:00
const isPhone = isMobile.phone
const showingControls = ref(false)
2022-04-15 14:24:30 +00:00
2022-04-15 17:00:08 +00:00
const toggleControls = () => (showingControls.value = !showingControls.value)
const showAddUserForm = () => eventBus.emit('MODAL_SHOW_ADD_USER_FORM')
const showEditUserForm = (user: User) => eventBus.emit('MODAL_SHOW_EDIT_USER_FORM', user)
2022-04-15 14:24:30 +00:00
</script>
<style lang="scss">
#usersWrapper {
.users {
display: grid;
grid-gap: .7rem 1rem;
grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}
}
</style>