misskey/src/client/app/desktop/views/pages/user-list.users.vue

126 lines
2.4 KiB
Vue
Raw Normal View History

2018-04-25 15:37:08 +02:00
<template>
<div>
<mk-widget-container>
<template slot="header">%fa:users% %i18n:@users%</template>
<button slot="func" title="%i18n:@add-user%" @click="add">%fa:plus%</button>
2018-04-25 15:37:08 +02:00
<div data-id="d0b63759-a822-4556-a5ce-373ab966e08a">
<p class="fetching" v-if="fetching">%fa:spinner .pulse .fw% %i18n:common.loading%<mk-ellipsis/></p>
<template v-else-if="users.length != 0">
<div class="user" v-for="_user in users">
2018-04-29 10:17:15 +02:00
<mk-avatar class="avatar" :user="_user"/>
2018-04-25 15:37:08 +02:00
<div class="body">
<router-link class="name" :to="_user | userPage" v-user-preview="_user.id">{{ _user | userName }}</router-link>
<p class="username">@{{ _user | acct }}</p>
</div>
</div>
</template>
<p class="empty" v-else>%i18n:@no-one%</p>
</div>
</mk-widget-container>
</div>
</template>
<script lang="ts">
import Vue from 'vue';
export default Vue.extend({
props: {
list: {
type: Object,
required: true
}
},
data() {
return {
fetching: true,
users: []
};
},
mounted() {
(this as any).api('users/show', {
userIds: this.list.userIds
}).then(users => {
this.users = users;
this.fetching = false;
});
},
methods: {
add() {
(this as any).apis.input({
title: '%i18n:@username%',
2018-07-20 14:59:09 +02:00
}).then(async (username: string) => {
if (username.startsWith('@')) username = username.slice(1);
2018-04-25 15:37:08 +02:00
const user = await (this as any).api('users/show', {
username
});
(this as any).api('users/lists/push', {
listId: this.list.id,
userId: user.id
});
});
}
}
});
</script>
<style lang="stylus" scoped>
root(isDark)
> .user
padding 16px
border-bottom solid 1px isDark ? #1c2023 : #eee
&:last-child
border-bottom none
&:after
content ""
display block
clear both
2018-04-29 10:17:15 +02:00
> .avatar
2018-04-25 15:37:08 +02:00
display block
float left
margin 0 12px 0 0
2018-04-29 10:17:15 +02:00
width 42px
height 42px
border-radius 8px
2018-04-25 15:37:08 +02:00
> .body
float left
width calc(100% - 54px)
> .name
margin 0
font-size 16px
line-height 24px
color isDark ? #fff : #555
> .username
display block
margin 0
font-size 15px
line-height 16px
color isDark ? #606984 : #ccc
> .empty
margin 0
padding 16px
text-align center
color #aaa
> .fetching
margin 0
padding 16px
text-align center
color #aaa
[data-id="d0b63759-a822-4556-a5ce-373ab966e08a"][data-darkmode]
root(true)
[data-id="d0b63759-a822-4556-a5ce-373ab966e08a"]:not([data-darkmode])
root(false)
</style>