2020-01-29 19:37:25 +00:00
|
|
|
<template>
|
2020-10-17 11:12:00 +00:00
|
|
|
<XModalWindow ref="dialog"
|
|
|
|
:with-ok-button="true"
|
|
|
|
:ok-button-disabled="selected == null"
|
|
|
|
@click="cancel()"
|
|
|
|
@close="cancel()"
|
|
|
|
@ok="ok()"
|
|
|
|
@closed="$emit('closed')"
|
|
|
|
>
|
2020-12-26 01:47:36 +00:00
|
|
|
<template #header>{{ $ts.selectUser }}</template>
|
2020-10-17 11:12:00 +00:00
|
|
|
<div class="tbhwbxda _section">
|
2020-01-29 19:37:25 +00:00
|
|
|
<div class="inputs">
|
2020-12-26 01:47:36 +00:00
|
|
|
<MkInput v-model:value="username" class="input" @update:value="search" ref="username"><span>{{ $ts.username }}</span><template #prefix>@</template></MkInput>
|
|
|
|
<MkInput v-model:value="host" class="input" @update:value="search"><span>{{ $ts.host }}</span><template #prefix>@</template></MkInput>
|
2020-01-29 19:37:25 +00:00
|
|
|
</div>
|
2020-10-17 11:12:00 +00:00
|
|
|
</div>
|
2020-11-08 03:40:56 +00:00
|
|
|
<div class="tbhwbxda _section result" v-if="username != '' || host != ''" :class="{ hit: users.length > 0 }">
|
2020-10-17 11:12:00 +00:00
|
|
|
<div class="users" v-if="users.length > 0">
|
2020-01-29 19:37:25 +00:00
|
|
|
<div class="user" v-for="user in users" :key="user.id" :class="{ selected: selected && selected.id === user.id }" @click="selected = user" @dblclick="ok()">
|
2020-11-08 03:40:56 +00:00
|
|
|
<MkAvatar :user="user" class="avatar"/>
|
2020-01-29 19:37:25 +00:00
|
|
|
<div class="body">
|
2020-10-17 11:12:00 +00:00
|
|
|
<MkUserName :user="user" class="name"/>
|
|
|
|
<MkAcct :user="user" class="acct"/>
|
2020-01-29 19:37:25 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-10-17 11:12:00 +00:00
|
|
|
<div v-else class="empty">
|
2020-12-26 01:47:36 +00:00
|
|
|
<span>{{ $ts.noUsers }}</span>
|
2020-10-17 11:12:00 +00:00
|
|
|
</div>
|
2020-01-29 19:37:25 +00:00
|
|
|
</div>
|
2020-11-08 03:40:56 +00:00
|
|
|
<div class="tbhwbxda _section recent" v-if="username == '' && host == ''">
|
|
|
|
<div class="users">
|
|
|
|
<div class="user" v-for="user in recentUsers" :key="user.id" :class="{ selected: selected && selected.id === user.id }" @click="selected = user" @dblclick="ok()">
|
|
|
|
<MkAvatar :user="user" class="avatar"/>
|
|
|
|
<div class="body">
|
|
|
|
<MkUserName :user="user" class="name"/>
|
|
|
|
<MkAcct :user="user" class="acct"/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-10-17 11:12:00 +00:00
|
|
|
</XModalWindow>
|
2020-01-29 19:37:25 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 11:12:00 +00:00
|
|
|
import { defineComponent } from 'vue';
|
2020-01-29 19:37:25 +00:00
|
|
|
import { faTimes, faCheck } from '@fortawesome/free-solid-svg-icons';
|
|
|
|
import MkInput from './ui/input.vue';
|
2021-03-23 08:30:14 +00:00
|
|
|
import XModalWindow from '@client/components/ui/modal-window.vue';
|
|
|
|
import * as os from '@client/os';
|
2020-01-29 19:37:25 +00:00
|
|
|
|
2020-10-17 11:12:00 +00:00
|
|
|
export default defineComponent({
|
2020-01-29 19:37:25 +00:00
|
|
|
components: {
|
|
|
|
MkInput,
|
2020-10-17 11:12:00 +00:00
|
|
|
XModalWindow,
|
2020-01-29 19:37:25 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
props: {
|
|
|
|
},
|
|
|
|
|
2020-10-17 11:12:00 +00:00
|
|
|
emits: ['ok', 'cancel', 'closed'],
|
|
|
|
|
2020-01-29 19:37:25 +00:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
username: '',
|
|
|
|
host: '',
|
2020-11-08 03:40:56 +00:00
|
|
|
recentUsers: [],
|
2020-01-29 19:37:25 +00:00
|
|
|
users: [],
|
|
|
|
selected: null,
|
|
|
|
faTimes, faCheck
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
2020-11-08 03:40:56 +00:00
|
|
|
async mounted() {
|
2020-01-29 19:37:25 +00:00
|
|
|
this.focus();
|
|
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
this.focus();
|
|
|
|
});
|
2020-11-08 03:40:56 +00:00
|
|
|
|
|
|
|
this.recentUsers = await os.api('users/show', {
|
2020-12-19 01:55:52 +00:00
|
|
|
userIds: this.$store.state.recentlyUsedUsers
|
2020-11-08 03:40:56 +00:00
|
|
|
});
|
2020-01-29 19:37:25 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
search() {
|
|
|
|
if (this.username == '' && this.host == '') {
|
|
|
|
this.users = [];
|
|
|
|
return;
|
|
|
|
}
|
2020-10-17 11:12:00 +00:00
|
|
|
os.api('users/search-by-username-and-host', {
|
2020-01-29 19:37:25 +00:00
|
|
|
username: this.username,
|
|
|
|
host: this.host,
|
|
|
|
limit: 10,
|
|
|
|
detail: false
|
|
|
|
}).then(users => {
|
|
|
|
this.users = users;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
focus() {
|
|
|
|
this.$refs.username.focus();
|
|
|
|
},
|
|
|
|
|
2020-10-17 11:12:00 +00:00
|
|
|
ok() {
|
|
|
|
this.$emit('ok', this.selected);
|
|
|
|
this.$refs.dialog.close();
|
2020-11-08 03:40:56 +00:00
|
|
|
|
|
|
|
// 最近使ったユーザー更新
|
2020-12-19 01:55:52 +00:00
|
|
|
let recents = this.$store.state.recentlyUsedUsers;
|
2020-11-08 03:40:56 +00:00
|
|
|
recents = recents.filter(x => x !== this.selected.id);
|
|
|
|
recents.unshift(this.selected.id);
|
2020-12-19 01:55:52 +00:00
|
|
|
this.$store.set('recentlyUsedUsers', recents.splice(0, 16));
|
2020-01-29 19:37:25 +00:00
|
|
|
},
|
|
|
|
|
2020-10-17 11:12:00 +00:00
|
|
|
cancel() {
|
|
|
|
this.$emit('cancel');
|
|
|
|
this.$refs.dialog.close();
|
2020-01-29 19:37:25 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.tbhwbxda {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
overflow: auto;
|
|
|
|
height: 100%;
|
|
|
|
|
2020-11-08 03:40:56 +00:00
|
|
|
&.result.hit {
|
|
|
|
padding: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
&.recent {
|
|
|
|
padding: 0;
|
|
|
|
}
|
|
|
|
|
2020-10-17 11:12:00 +00:00
|
|
|
> .inputs {
|
2020-01-29 19:37:25 +00:00
|
|
|
> .input {
|
|
|
|
display: inline-block;
|
|
|
|
width: 50%;
|
|
|
|
margin: 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> .users {
|
|
|
|
flex: 1;
|
|
|
|
overflow: auto;
|
2020-10-17 11:12:00 +00:00
|
|
|
padding: 8px 0;
|
2020-01-29 19:37:25 +00:00
|
|
|
|
|
|
|
> .user {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
2020-10-17 11:12:00 +00:00
|
|
|
padding: 8px var(--section-padding);
|
2020-01-29 19:37:25 +00:00
|
|
|
font-size: 14px;
|
|
|
|
|
|
|
|
&:hover {
|
2020-07-04 18:49:58 +00:00
|
|
|
background: var(--X7);
|
2020-01-29 19:37:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
&.selected {
|
|
|
|
background: var(--accent);
|
|
|
|
color: #fff;
|
|
|
|
}
|
|
|
|
|
|
|
|
> * {
|
|
|
|
pointer-events: none;
|
|
|
|
user-select: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .avatar {
|
|
|
|
width: 45px;
|
|
|
|
height: 45px;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .body {
|
|
|
|
padding: 0 8px;
|
|
|
|
min-width: 0;
|
|
|
|
|
|
|
|
> .name {
|
|
|
|
display: block;
|
|
|
|
font-weight: bold;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .acct {
|
|
|
|
opacity: 0.5;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-10-17 11:12:00 +00:00
|
|
|
|
|
|
|
> .empty {
|
|
|
|
opacity: 0.7;
|
|
|
|
text-align: center;
|
|
|
|
}
|
2020-01-29 19:37:25 +00:00
|
|
|
}
|
|
|
|
</style>
|