Simplify groups index
This commit is contained in:
parent
4c021e196f
commit
5001e27f49
2 changed files with 24 additions and 90 deletions
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "calckey",
|
"name": "calckey",
|
||||||
"version": "12.119.0-calc-rc.4.1",
|
"version": "12.119.0-calc-rc.5",
|
||||||
"codename": "aqua",
|
"codename": "aqua",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|
|
@ -1,61 +1,33 @@
|
||||||
<template>
|
<template>
|
||||||
<MkStickyContainer>
|
<MkStickyContainer>
|
||||||
<template #header><MkPageHeader v-model:tab="tab" :actions="headerActions" :tabs="headerTabs"/></template>
|
<template #header><MkPageHeader v-model:tab="tab" :actions="headerActions" :tabs="headerTabs"/></template>
|
||||||
<MkSpacer :content-max="1000">
|
<MkSpacer :content-max="800" :margin-min="20">
|
||||||
<swiper
|
<MkButton primary style="margin: 0 auto var(--margin) auto;" @click="create"><i class="fas fa-plus"></i> {{ i18n.ts.createGroup }}</MkButton>
|
||||||
:modules="[Virtual]"
|
<MkPagination v-slot="{items}" ref="owned" :pagination="ownedPagination">
|
||||||
:space-between="20"
|
<div v-for="group in items" :key="group.id" class="_card">
|
||||||
:virtual="true"
|
<div class="_title"><MkA :to="`/my/groups/${ group.id }`" class="_link">{{ group.name }}</MkA></div>
|
||||||
@swiper="setSwiperRef"
|
<div class="_content">
|
||||||
@slide-change="onSlideChange"
|
<MkAvatars :user-ids="group.userIds"/>
|
||||||
>
|
</div>
|
||||||
<swiper-slide class="_content">
|
</div>
|
||||||
<MkButton primary style="margin: 0 auto var(--margin) auto;" @click="create"><i class="fas fa-plus"></i> {{ i18n.ts.createGroup }}</MkButton>
|
</MkPagination>
|
||||||
<MkPagination v-slot="{items}" ref="owned" :pagination="ownedPagination">
|
<MkPagination v-slot="{items}" ref="joined" :pagination="joinedPagination">
|
||||||
<div v-for="group in items" :key="group.id" class="_card">
|
<div v-for="group in items" :key="group.id" class="_card">
|
||||||
<div class="_title"><MkA :to="`/my/groups/${ group.id }`" class="_link">{{ group.name }}</MkA></div>
|
<div class="_title">{{ group.name }}</div>
|
||||||
<div class="_content">
|
<div class="_content">
|
||||||
<MkAvatars :user-ids="group.userIds"/>
|
<MkAvatars :user-ids="group.userIds"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="_footer">
|
||||||
</MkPagination>
|
<MkButton danger @click="leave(group)">{{ i18n.ts.leaveGroup }}</MkButton>
|
||||||
</swiper-slide>
|
</div>
|
||||||
<swiper-slide class="_content">
|
</div>
|
||||||
<MkPagination v-slot="{items}" ref="joined" :pagination="joinedPagination">
|
</MkPagination>
|
||||||
<div v-for="group in items" :key="group.id" class="_card">
|
|
||||||
<div class="_title">{{ group.name }}</div>
|
|
||||||
<div class="_content">
|
|
||||||
<MkAvatars :user-ids="group.userIds"/>
|
|
||||||
</div>
|
|
||||||
<div class="_footer">
|
|
||||||
<MkButton danger @click="leave(group)">{{ i18n.ts.leaveGroup }}</MkButton>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</MkPagination>
|
|
||||||
</swiper-slide>
|
|
||||||
<swiper-slide class="_content">
|
|
||||||
<MkPagination v-slot="{items}" ref="invitations" :pagination="invitationPagination">
|
|
||||||
<div v-for="invitation in items" :key="invitation.id" class="_card">
|
|
||||||
<div class="_title">{{ invitation.group.name }}</div>
|
|
||||||
<div class="_content">
|
|
||||||
<MkAvatars :user-ids="invitation.group.userIds"/>
|
|
||||||
</div>
|
|
||||||
<div class="_footer">
|
|
||||||
<MkButton primary inline @click="acceptInvite(invitation)"><i class="fas fa-check"></i> {{ i18n.ts.accept }}</MkButton>
|
|
||||||
<MkButton primary inline @click="rejectInvite(invitation)"><i class="fas fa-ban"></i> {{ i18n.ts.reject }}</MkButton>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</MkPagination>
|
|
||||||
</swiper-slide>
|
|
||||||
</swiper>
|
|
||||||
</MkSpacer>
|
</MkSpacer>
|
||||||
</MkStickyContainer>
|
</MkStickyContainer>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, ref } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
import { Virtual } from 'swiper';
|
|
||||||
import { Swiper, SwiperSlide } from 'swiper/vue';
|
|
||||||
import MkPagination from '@/components/MkPagination.vue';
|
import MkPagination from '@/components/MkPagination.vue';
|
||||||
import MkButton from '@/components/MkButton.vue';
|
import MkButton from '@/components/MkButton.vue';
|
||||||
import MkAvatars from '@/components/MkAvatars.vue';
|
import MkAvatars from '@/components/MkAvatars.vue';
|
||||||
|
@ -72,17 +44,12 @@ const invitations = ref('invitations');
|
||||||
|
|
||||||
const ownedPagination = {
|
const ownedPagination = {
|
||||||
endpoint: 'users/groups/owned' as const,
|
endpoint: 'users/groups/owned' as const,
|
||||||
limit: 12,
|
limit: 10,
|
||||||
};
|
};
|
||||||
|
|
||||||
const joinedPagination = {
|
const joinedPagination = {
|
||||||
endpoint: 'users/groups/joined' as const,
|
endpoint: 'users/groups/joined' as const,
|
||||||
limit: 12,
|
limit: 10,
|
||||||
};
|
|
||||||
|
|
||||||
const invitationPagination = {
|
|
||||||
endpoint: 'i/user-group-invites' as const,
|
|
||||||
limit: 12,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const headerActions = $computed(() => [
|
const headerActions = $computed(() => [
|
||||||
|
@ -124,24 +91,6 @@ async function create() {
|
||||||
os.success();
|
os.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
function acceptInvite(invitation) {
|
|
||||||
os.api('users/groups/invitations/accept', {
|
|
||||||
invitationId: invitation.id,
|
|
||||||
}).then(() => {
|
|
||||||
os.success();
|
|
||||||
invitations.value.reload();
|
|
||||||
joined.value.reload();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function rejectInvite(invitation) {
|
|
||||||
os.api('users/groups/invitations/reject', {
|
|
||||||
invitationId: invitation.id,
|
|
||||||
}).then(() => {
|
|
||||||
invitations.value.reload();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async function leave(group) {
|
async function leave(group) {
|
||||||
const { canceled } = await os.confirm({
|
const { canceled } = await os.confirm({
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
|
@ -154,21 +103,6 @@ async function leave(group) {
|
||||||
joined.value.reload();
|
joined.value.reload();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let swiperRef = null;
|
|
||||||
|
|
||||||
function setSwiperRef(swiper) {
|
|
||||||
swiperRef = swiper;
|
|
||||||
syncSlide(tabs.indexOf(tab));
|
|
||||||
}
|
|
||||||
|
|
||||||
function onSlideChange() {
|
|
||||||
tab = tabs[swiperRef.activeIndex];
|
|
||||||
}
|
|
||||||
|
|
||||||
function syncSlide(index) {
|
|
||||||
swiperRef.slideTo(index);
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|
Loading…
Reference in a new issue