2020-01-30 04:37:25 +09:00
|
|
|
<template>
|
|
|
|
<div class="mk-list-page">
|
|
|
|
<transition name="zoom" mode="out-in">
|
2020-10-17 20:12:00 +09:00
|
|
|
<div v-if="list" class="_section">
|
2020-02-08 15:11:12 +09:00
|
|
|
<div class="_content">
|
2020-12-26 10:47:36 +09:00
|
|
|
<MkButton inline @click="addUser()">{{ $ts.addUser }}</MkButton>
|
|
|
|
<MkButton inline @click="renameList()">{{ $ts.rename }}</MkButton>
|
|
|
|
<MkButton inline @click="deleteList()">{{ $ts.delete }}</MkButton>
|
2020-02-08 15:11:12 +09:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</transition>
|
|
|
|
|
|
|
|
<transition name="zoom" mode="out-in">
|
2020-10-17 20:12:00 +09:00
|
|
|
<div v-if="list" class="_section members _vMargin">
|
2020-12-26 10:47:36 +09:00
|
|
|
<div class="_title">{{ $ts.members }}</div>
|
2020-01-30 04:37:25 +09:00
|
|
|
<div class="_content">
|
|
|
|
<div class="users">
|
2020-10-17 20:12:00 +09:00
|
|
|
<div class="user _panel" v-for="user in users" :key="user.id">
|
|
|
|
<MkAvatar :user="user" class="avatar"/>
|
2020-01-30 04:37:25 +09:00
|
|
|
<div class="body">
|
2020-10-17 20:12:00 +09:00
|
|
|
<MkUserName :user="user" class="name"/>
|
|
|
|
<MkAcct :user="user" class="acct"/>
|
2020-01-30 04:37:25 +09:00
|
|
|
</div>
|
|
|
|
<div class="action">
|
2020-10-17 20:12:00 +09:00
|
|
|
<button class="_button" @click="removeUser(user)"><Fa :icon="faTimes"/></button>
|
2020-01-30 04:37:25 +09:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</transition>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 20:12:00 +09:00
|
|
|
import { computed, defineComponent } from 'vue';
|
2020-02-08 15:11:12 +09:00
|
|
|
import { faTimes, faListUl } from '@fortawesome/free-solid-svg-icons';
|
2021-03-23 17:30:14 +09:00
|
|
|
import Progress from '@client/scripts/loading';
|
|
|
|
import MkButton from '@client/components/ui/button.vue';
|
|
|
|
import * as os from '@client/os';
|
2021-04-10 12:54:12 +09:00
|
|
|
import * as symbols from '@client/symbols';
|
2020-01-30 04:37:25 +09:00
|
|
|
|
2020-10-17 20:12:00 +09:00
|
|
|
export default defineComponent({
|
2020-01-30 04:37:25 +09:00
|
|
|
components: {
|
|
|
|
MkButton
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
2021-04-10 12:54:12 +09:00
|
|
|
[symbols.PAGE_INFO]: computed(() => this.list ? {
|
2020-11-03 20:36:12 +09:00
|
|
|
title: this.list.name,
|
|
|
|
icon: faListUl,
|
2020-10-17 20:12:00 +09:00
|
|
|
} : null),
|
2020-01-30 04:37:25 +09:00
|
|
|
list: null,
|
|
|
|
users: [],
|
2020-02-08 15:11:12 +09:00
|
|
|
faTimes, faListUl
|
2020-01-30 04:37:25 +09:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
watch: {
|
|
|
|
$route: 'fetch'
|
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
|
|
|
this.fetch();
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
fetch() {
|
|
|
|
Progress.start();
|
2020-10-17 20:12:00 +09:00
|
|
|
os.api('users/lists/show', {
|
2020-01-30 04:37:25 +09:00
|
|
|
listId: this.$route.params.list
|
|
|
|
}).then(list => {
|
|
|
|
this.list = list;
|
2020-10-17 20:12:00 +09:00
|
|
|
os.api('users/show', {
|
2020-01-30 04:37:25 +09:00
|
|
|
userIds: this.list.userIds
|
|
|
|
}).then(users => {
|
|
|
|
this.users = users;
|
|
|
|
Progress.done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2020-02-08 15:11:12 +09:00
|
|
|
addUser() {
|
2020-10-17 20:12:00 +09:00
|
|
|
os.selectUser().then(user => {
|
|
|
|
os.apiWithDialog('users/lists/push', {
|
2020-02-08 15:11:12 +09:00
|
|
|
listId: this.list.id,
|
|
|
|
userId: user.id
|
|
|
|
}).then(() => {
|
|
|
|
this.users.push(user);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2020-01-30 04:37:25 +09:00
|
|
|
removeUser(user) {
|
2020-10-17 20:12:00 +09:00
|
|
|
os.api('users/lists/pull', {
|
2020-01-30 04:37:25 +09:00
|
|
|
listId: this.list.id,
|
|
|
|
userId: user.id
|
|
|
|
}).then(() => {
|
|
|
|
this.users = this.users.filter(x => x.id !== user.id);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
async renameList() {
|
2020-10-17 20:12:00 +09:00
|
|
|
const { canceled, result: name } = await os.dialog({
|
2020-12-26 10:47:36 +09:00
|
|
|
title: this.$ts.enterListName,
|
2020-01-30 04:37:25 +09:00
|
|
|
input: {
|
|
|
|
default: this.list.name
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
|
2020-10-17 20:12:00 +09:00
|
|
|
await os.api('users/lists/update', {
|
2020-01-30 04:37:25 +09:00
|
|
|
listId: this.list.id,
|
|
|
|
name: name
|
|
|
|
});
|
|
|
|
|
|
|
|
this.list.name = name;
|
|
|
|
},
|
|
|
|
|
|
|
|
async deleteList() {
|
2020-10-17 20:12:00 +09:00
|
|
|
const { canceled } = await os.dialog({
|
2020-01-30 04:37:25 +09:00
|
|
|
type: 'warning',
|
2020-02-08 15:11:12 +09:00
|
|
|
text: this.$t('removeAreYouSure', { x: this.list.name }),
|
2020-01-30 04:37:25 +09:00
|
|
|
showCancelButton: true
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
|
2020-10-17 20:12:00 +09:00
|
|
|
await os.api('users/lists/delete', {
|
2020-01-30 04:37:25 +09:00
|
|
|
listId: this.list.id
|
|
|
|
});
|
2020-10-17 20:12:00 +09:00
|
|
|
os.success();
|
2020-01-30 04:37:25 +09:00
|
|
|
this.$router.push('/my/lists');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.mk-list-page {
|
2020-02-08 15:11:12 +09:00
|
|
|
> .members {
|
2020-01-30 04:37:25 +09:00
|
|
|
> ._content {
|
|
|
|
> .users {
|
|
|
|
> .user {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
2020-10-17 20:12:00 +09:00
|
|
|
padding: 16px;
|
2020-01-30 04:37:25 +09:00
|
|
|
|
|
|
|
> .avatar {
|
|
|
|
width: 50px;
|
|
|
|
height: 50px;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .body {
|
|
|
|
flex: 1;
|
|
|
|
padding: 8px;
|
|
|
|
|
|
|
|
> .name {
|
|
|
|
display: block;
|
|
|
|
font-weight: bold;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .acct {
|
|
|
|
opacity: 0.5;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|