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