2022-07-20 08:24:26 -05:00
|
|
|
<template>
|
|
|
|
<MkStickyContainer>
|
2022-06-20 03:38:49 -05:00
|
|
|
<template #header><MkPageHeader :actions="headerActions" :tabs="headerTabs"/></template>
|
2022-07-20 08:24:26 -05:00
|
|
|
<MkSpacer :content-max="700">
|
|
|
|
<div class="mk-list-page">
|
2022-12-29 22:52:40 -06:00
|
|
|
<Transition :name="$store.state.animation ? '_transition_zoom' : ''" mode="out-in">
|
2022-07-20 08:24:26 -05:00
|
|
|
<div v-if="list" class="_section">
|
|
|
|
<div class="_content">
|
|
|
|
<MkButton inline @click="addUser()">{{ i18n.ts.addUser }}</MkButton>
|
|
|
|
<MkButton inline @click="renameList()">{{ i18n.ts.rename }}</MkButton>
|
|
|
|
<MkButton inline @click="deleteList()">{{ i18n.ts.delete }}</MkButton>
|
|
|
|
</div>
|
2021-12-02 05:09:12 -06:00
|
|
|
</div>
|
2022-12-29 22:37:14 -06:00
|
|
|
</Transition>
|
2020-02-08 00:11:12 -06:00
|
|
|
|
2022-12-29 22:52:40 -06:00
|
|
|
<Transition :name="$store.state.animation ? '_transition_zoom' : ''" mode="out-in">
|
2023-01-05 06:04:56 -06:00
|
|
|
<div v-if="list" class="_section members _margin">
|
2022-07-20 08:24:26 -05:00
|
|
|
<div class="_title">{{ i18n.ts.members }}</div>
|
|
|
|
<div class="_content">
|
|
|
|
<div class="users">
|
|
|
|
<div v-for="user in users" :key="user.id" class="user _panel">
|
|
|
|
<MkAvatar :user="user" class="avatar" :show-indicator="true"/>
|
|
|
|
<div class="body">
|
|
|
|
<MkUserName :user="user" class="name"/>
|
|
|
|
<MkAcct :user="user" class="acct"/>
|
|
|
|
</div>
|
|
|
|
<div class="action">
|
2022-12-19 04:01:30 -06:00
|
|
|
<button class="_button" @click="removeUser(user)"><i class="ti ti-x"></i></button>
|
2022-07-20 08:24:26 -05:00
|
|
|
</div>
|
2021-12-02 05:09:12 -06:00
|
|
|
</div>
|
2020-01-29 13:37:25 -06:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-12-29 22:37:14 -06:00
|
|
|
</Transition>
|
2022-07-20 08:24:26 -05:00
|
|
|
</div>
|
|
|
|
</MkSpacer>
|
|
|
|
</MkStickyContainer>
|
2020-01-29 13:37:25 -06:00
|
|
|
</template>
|
|
|
|
|
2022-06-20 03:38:49 -05:00
|
|
|
<script lang="ts" setup>
|
2022-07-20 08:24:26 -05:00
|
|
|
import { computed, watch } from 'vue';
|
2022-09-06 04:21:49 -05:00
|
|
|
import MkButton from '@/components/MkButton.vue';
|
2021-11-11 11:02:25 -06:00
|
|
|
import * as os from '@/os';
|
2022-06-20 03:38:49 -05:00
|
|
|
import { mainRouter } from '@/router';
|
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
2022-07-04 09:33:55 -05:00
|
|
|
import { i18n } from '@/i18n';
|
2022-06-20 03:38:49 -05:00
|
|
|
|
|
|
|
const props = defineProps<{
|
|
|
|
listId: string;
|
|
|
|
}>();
|
|
|
|
|
|
|
|
let list = $ref(null);
|
|
|
|
let users = $ref([]);
|
|
|
|
|
|
|
|
function fetchList() {
|
|
|
|
os.api('users/lists/show', {
|
|
|
|
listId: props.listId,
|
|
|
|
}).then(_list => {
|
|
|
|
list = _list;
|
|
|
|
os.api('users/show', {
|
|
|
|
userIds: list.userIds,
|
|
|
|
}).then(_users => {
|
|
|
|
users = _users;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function addUser() {
|
|
|
|
os.selectUser().then(user => {
|
|
|
|
os.apiWithDialog('users/lists/push', {
|
|
|
|
listId: list.id,
|
|
|
|
userId: user.id,
|
|
|
|
}).then(() => {
|
|
|
|
users.push(user);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function removeUser(user) {
|
|
|
|
os.api('users/lists/pull', {
|
|
|
|
listId: list.id,
|
|
|
|
userId: user.id,
|
|
|
|
}).then(() => {
|
|
|
|
users = users.filter(x => x.id !== user.id);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async function renameList() {
|
|
|
|
const { canceled, result: name } = await os.inputText({
|
|
|
|
title: i18n.ts.enterListName,
|
|
|
|
default: list.name,
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
|
|
|
|
await os.api('users/lists/update', {
|
|
|
|
listId: list.id,
|
|
|
|
name: name,
|
|
|
|
});
|
|
|
|
|
|
|
|
list.name = name;
|
|
|
|
}
|
|
|
|
|
|
|
|
async function deleteList() {
|
|
|
|
const { canceled } = await os.confirm({
|
|
|
|
type: 'warning',
|
|
|
|
text: i18n.t('removeAreYouSure', { x: list.name }),
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
|
|
|
|
await os.api('users/lists/delete', {
|
|
|
|
listId: list.id,
|
|
|
|
});
|
|
|
|
os.success();
|
|
|
|
mainRouter.push('/my/lists');
|
|
|
|
}
|
|
|
|
|
|
|
|
watch(() => props.listId, fetchList, { immediate: true });
|
|
|
|
|
|
|
|
const headerActions = $computed(() => []);
|
|
|
|
|
|
|
|
const headerTabs = $computed(() => []);
|
|
|
|
|
|
|
|
definePageMetadata(computed(() => list ? {
|
|
|
|
title: list.name,
|
2022-12-19 04:01:30 -06:00
|
|
|
icon: 'ti ti-list',
|
2022-06-20 03:38:49 -05:00
|
|
|
} : null));
|
2020-01-29 13:37:25 -06:00
|
|
|
</script>
|
|
|
|
|
2022-12-27 03:29:39 -06:00
|
|
|
<style lang="scss" scoped>
|
2020-01-29 13:37:25 -06:00
|
|
|
.mk-list-page {
|
2020-02-08 00:11:12 -06:00
|
|
|
> .members {
|
2020-01-29 13:37:25 -06:00
|
|
|
> ._content {
|
|
|
|
> .users {
|
|
|
|
> .user {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
2020-10-17 06:12:00 -05:00
|
|
|
padding: 16px;
|
2020-01-29 13:37:25 -06:00
|
|
|
|
|
|
|
> .avatar {
|
|
|
|
width: 50px;
|
|
|
|
height: 50px;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .body {
|
|
|
|
flex: 1;
|
|
|
|
padding: 8px;
|
|
|
|
|
|
|
|
> .name {
|
|
|
|
display: block;
|
|
|
|
font-weight: bold;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .acct {
|
|
|
|
opacity: 0.5;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|