formatting

This commit is contained in:
ThatOneCalculator 2022-09-13 17:56:19 -07:00
parent 25b032e1aa
commit 64a96b8f67

View file

@ -1,26 +1,36 @@
<template> <template>
<MkStickyContainer> <MkStickyContainer>
<template #header><MkPageHeader/></template> <template #header><MkPageHeader /></template>
<div class="mk-group-page"> <div class="mk-group-page">
<div class="_section"> <div class="_section">
<div class="_content" style="display: flex; gap: var(--margin); flex-wrap: wrap;"> <div
class="_content"
style="display: flex; gap: var(--margin); flex-wrap: wrap"
>
<MkButton inline @click="invite()">{{ i18n.ts.invite }}</MkButton> <MkButton inline @click="invite()">{{ i18n.ts.invite }}</MkButton>
<MkButton inline @click="renameGroup()">{{ i18n.ts.rename }}</MkButton> <MkButton inline @click="renameGroup()">{{
i18n.ts.rename
}}</MkButton>
<MkButton inline @click="transfer()">{{ i18n.ts.transfer }}</MkButton> <MkButton inline @click="transfer()">{{ i18n.ts.transfer }}</MkButton>
<MkButton inline @click="deleteGroup()">{{ i18n.ts.delete }}</MkButton> <MkButton inline @click="deleteGroup()">{{
i18n.ts.delete
}}
</MkButton>
</div> </div>
</div> </div>
<div class="_section members _gap"> <div class="_section members _gap">
<div class="_content"> <div class="_content">
<div class="users"> <div class="users">
<div v-for="user in users" :key="user.id" class="user _panel"> <div v-for="user in users" :key="user.id" class="user _panel">
<MkAvatar :user="user" class="avatar" :show-indicator="true"/> <MkAvatar :user="user" class="avatar" :show-indicator="true" />
<div class="body"> <div class="body">
<MkUserName :user="user" class="name"/> <MkUserName :user="user" class="name" />
<MkAcct :user="user" class="acct"/> <MkAcct :user="user" class="acct" />
</div> </div>
<div class="action"> <div class="action">
<button class="_button" @click="removeUser(user)"><i class="fas fa-times"></i></button> <button class="_button" @click="removeUser(user)">
<i class="fas fa-times"></i>
</button>
</div> </div>
</div> </div>
</div> </div>
@ -31,18 +41,18 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { computed, ref, watch } from 'vue'; import { computed, ref, watch } from "vue";
import MkButton from '@/components/MkButton.vue'; import MkButton from "@/components/MkButton.vue";
import { definePageMetadata } from '@/scripts/page-metadata'; import { definePageMetadata } from "@/scripts/page-metadata";
import { i18n } from '@/i18n'; import { i18n } from "@/i18n";
import { useRouter } from '@/router'; import { useRouter } from "@/router";
import * as os from '@/os'; import * as os from "@/os";
const props = defineProps<{ const props = defineProps<{
groupId: { groupId: {
type: string, type: string;
required: true, required: true;
} };
}>(); }>();
const users = ref<any[]>([]); const users = ref<any[]>([]);
@ -50,18 +60,21 @@ const group = ref<any>();
const router = useRouter(); const router = useRouter();
watch(() => props.groupId, () => { watch(
fetch(); () => props.groupId,
}); () => {
fetch();
}
);
async function fetch() { async function fetch() {
os.api('users/groups/show', { os.api("users/groups/show", {
groupId: props.groupId, groupId: props.groupId,
}).then(gp => { }).then((gp) => {
group.value = gp; group.value = gp;
os.api('users/show', { os.api("users/show", {
userIds: group.value.userIds userIds: group.value.userIds,
}).then(us => { }).then((us) => {
users.value = us; users.value = us;
}); });
}); });
@ -70,8 +83,8 @@ async function fetch() {
fetch(); fetch();
function invite() { function invite() {
os.selectUser().then(user => { os.selectUser().then((user) => {
os.apiWithDialog('users/groups/invite', { os.apiWithDialog("users/groups/invite", {
groupId: group.value.id, groupId: group.value.id,
userId: user.id, userId: user.id,
}); });
@ -79,32 +92,32 @@ function invite() {
} }
function removeUser(user) { function removeUser(user) {
os.api('users/groups/pull', { os.api("users/groups/pull", {
groupId: group.value.id, groupId: group.value.id,
userId: user.id userId: user.id,
}).then(() => { }).then(() => {
users.value = users.value.filter(x => x.id !== user.id); users.value = users.value.filter((x) => x.id !== user.id);
}); });
} }
async function renameGroup() { async function renameGroup() {
const { canceled, result: name } = await os.inputText({ const { canceled, result: name } = await os.inputText({
title: i18n.ts.groupName, title: i18n.ts.groupName,
default: group.value.name default: group.value.name,
}); });
if (canceled) return; if (canceled) return;
await os.api('users/groups/update', { await os.api("users/groups/update", {
groupId: group.value.id, groupId: group.value.id,
name: name name: name,
}); });
group.value.name = name; group.value.name = name;
} }
function transfer() { function transfer() {
os.selectUser().then(user => { os.selectUser().then((user) => {
os.apiWithDialog('users/groups/transfer', { os.apiWithDialog("users/groups/transfer", {
groupId: group.value.id, groupId: group.value.id,
userId: user.id, userId: user.id,
}); });
@ -113,61 +126,65 @@ function transfer() {
async function deleteGroup() { async function deleteGroup() {
const { canceled } = await os.confirm({ const { canceled } = await os.confirm({
type: 'warning', type: "warning",
text: i18n.t('removeAreYouSure', { x: group.value.name }), text: i18n.t("removeAreYouSure", { x: group.value.name }),
}); });
if (canceled) return; if (canceled) return;
await os.apiWithDialog('users/groups/delete', { await os.apiWithDialog("users/groups/delete", {
groupId: group.value.id, groupId: group.value.id,
}); });
router.push('/my/groups'); router.push("/my/groups");
} }
definePageMetadata(computed(() => ({ definePageMetadata(
title: i18n.ts.members, computed(() => ({
icon: 'fas fa-users', title: i18n.ts.members,
}))); icon: "fas fa-users",
}))
);
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.mk-group-page { .mk-group-page {
> ._section { > ._section {
> ._content { > ._content {
padding-top: 1rem; padding-top: 1rem;
justify-content: center; justify-content: center;
}
} }
> .members { }
> ._content { > .members {
> .users { > ._content {
> .user { > .users {
display: flex; > ._panel {
align-items: center; margin: 1rem 2rem;
padding: 16px; }
> .user {
display: flex;
align-items: center;
padding: 16px;
> .avatar { > .avatar {
width: 50px; width: 50px;
height: 50px; height: 50px;
}
> .body {
flex: 1;
padding: 8px;
> .name {
display: block;
font-weight: bold;
} }
> .body { > .acct {
flex: 1; opacity: 0.5;
padding: 8px;
> .name {
display: block;
font-weight: bold;
}
> .acct {
opacity: 0.5;
}
} }
} }
} }
} }
} }
} }
</style> }
</style>