2020-01-29 13:37:25 -06:00
|
|
|
<template>
|
|
|
|
<div class="mk-list-page">
|
|
|
|
<transition name="zoom" mode="out-in">
|
2020-10-17 06:12:00 -05:00
|
|
|
<div v-if="list" class="_section">
|
2020-02-08 00:11:12 -06:00
|
|
|
<div class="_content">
|
2020-12-25 19:47:36 -06: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 00:11:12 -06:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</transition>
|
|
|
|
|
|
|
|
<transition name="zoom" mode="out-in">
|
2021-04-10 04:17:42 -05:00
|
|
|
<div v-if="list" class="_section members _gap">
|
2020-12-25 19:47:36 -06:00
|
|
|
<div class="_title">{{ $ts.members }}</div>
|
2020-01-29 13:37:25 -06:00
|
|
|
<div class="_content">
|
|
|
|
<div class="users">
|
2020-10-17 06:12:00 -05:00
|
|
|
<div class="user _panel" v-for="user in users" :key="user.id">
|
2021-04-17 09:52:54 -05:00
|
|
|
<MkAvatar :user="user" class="avatar" :show-indicator="true"/>
|
2020-01-29 13:37:25 -06:00
|
|
|
<div class="body">
|
2020-10-17 06:12:00 -05:00
|
|
|
<MkUserName :user="user" class="name"/>
|
|
|
|
<MkAcct :user="user" class="acct"/>
|
2020-01-29 13:37:25 -06:00
|
|
|
</div>
|
|
|
|
<div class="action">
|
2021-04-20 09:22:59 -05:00
|
|
|
<button class="_button" @click="removeUser(user)"><i class="fas fa-times"></i></button>
|
2020-01-29 13:37:25 -06:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</transition>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 06:12:00 -05:00
|
|
|
import { computed, defineComponent } from 'vue';
|
2021-03-23 03:30:14 -05:00
|
|
|
import Progress from '@client/scripts/loading';
|
|
|
|
import MkButton from '@client/components/ui/button.vue';
|
|
|
|
import * as os from '@client/os';
|
2021-04-09 22:54:12 -05:00
|
|
|
import * as symbols from '@client/symbols';
|
2020-01-29 13:37:25 -06:00
|
|
|
|
2020-10-17 06:12:00 -05:00
|
|
|
export default defineComponent({
|
2020-01-29 13:37:25 -06:00
|
|
|
components: {
|
|
|
|
MkButton
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
2021-04-09 22:54:12 -05:00
|
|
|
[symbols.PAGE_INFO]: computed(() => this.list ? {
|
2020-11-03 05:36:12 -06:00
|
|
|
title: this.list.name,
|
2021-04-20 09:22:59 -05:00
|
|
|
icon: 'fas fa-list-ul',
|
2020-10-17 06:12:00 -05:00
|
|
|
} : null),
|
2020-01-29 13:37:25 -06:00
|
|
|
list: null,
|
|
|
|
users: [],
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
watch: {
|
|
|
|
$route: 'fetch'
|
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
|
|
|
this.fetch();
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
fetch() {
|
|
|
|
Progress.start();
|
2020-10-17 06:12:00 -05:00
|
|
|
os.api('users/lists/show', {
|
2020-01-29 13:37:25 -06:00
|
|
|
listId: this.$route.params.list
|
|
|
|
}).then(list => {
|
|
|
|
this.list = list;
|
2020-10-17 06:12:00 -05:00
|
|
|
os.api('users/show', {
|
2020-01-29 13:37:25 -06:00
|
|
|
userIds: this.list.userIds
|
|
|
|
}).then(users => {
|
|
|
|
this.users = users;
|
|
|
|
Progress.done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2020-02-08 00:11:12 -06:00
|
|
|
addUser() {
|
2020-10-17 06:12:00 -05:00
|
|
|
os.selectUser().then(user => {
|
|
|
|
os.apiWithDialog('users/lists/push', {
|
2020-02-08 00:11:12 -06:00
|
|
|
listId: this.list.id,
|
|
|
|
userId: user.id
|
|
|
|
}).then(() => {
|
|
|
|
this.users.push(user);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2020-01-29 13:37:25 -06:00
|
|
|
removeUser(user) {
|
2020-10-17 06:12:00 -05:00
|
|
|
os.api('users/lists/pull', {
|
2020-01-29 13:37:25 -06:00
|
|
|
listId: this.list.id,
|
|
|
|
userId: user.id
|
|
|
|
}).then(() => {
|
|
|
|
this.users = this.users.filter(x => x.id !== user.id);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
async renameList() {
|
2020-10-17 06:12:00 -05:00
|
|
|
const { canceled, result: name } = await os.dialog({
|
2020-12-25 19:47:36 -06:00
|
|
|
title: this.$ts.enterListName,
|
2020-01-29 13:37:25 -06:00
|
|
|
input: {
|
|
|
|
default: this.list.name
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
|
2020-10-17 06:12:00 -05:00
|
|
|
await os.api('users/lists/update', {
|
2020-01-29 13:37:25 -06:00
|
|
|
listId: this.list.id,
|
|
|
|
name: name
|
|
|
|
});
|
|
|
|
|
|
|
|
this.list.name = name;
|
|
|
|
},
|
|
|
|
|
|
|
|
async deleteList() {
|
2020-10-17 06:12:00 -05:00
|
|
|
const { canceled } = await os.dialog({
|
2020-01-29 13:37:25 -06:00
|
|
|
type: 'warning',
|
2020-02-08 00:11:12 -06:00
|
|
|
text: this.$t('removeAreYouSure', { x: this.list.name }),
|
2020-01-29 13:37:25 -06:00
|
|
|
showCancelButton: true
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
|
2020-10-17 06:12:00 -05:00
|
|
|
await os.api('users/lists/delete', {
|
2020-01-29 13:37:25 -06:00
|
|
|
listId: this.list.id
|
|
|
|
});
|
2020-10-17 06:12:00 -05:00
|
|
|
os.success();
|
2020-01-29 13:37:25 -06:00
|
|
|
this.$router.push('/my/lists');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.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>
|