mirror of
https://github.com/paricafe/misskey.git
synced 2024-11-24 12:56:43 -06:00
enhance(client): improve usability of user select
This commit is contained in:
parent
f3c5ca6cf4
commit
fbfe42d6f0
3 changed files with 17 additions and 4 deletions
|
@ -60,6 +60,7 @@ import MkModalWindow from '@/components/MkModalWindow.vue';
|
|||
import * as os from '@/os';
|
||||
import { defaultStore } from '@/store';
|
||||
import { i18n } from '@/i18n';
|
||||
import { $i } from '@/account';
|
||||
|
||||
const emit = defineEmits<{
|
||||
(ev: 'ok', selected: misskey.entities.UserDetailed): void;
|
||||
|
@ -67,6 +68,10 @@ const emit = defineEmits<{
|
|||
(ev: 'closed'): void;
|
||||
}>();
|
||||
|
||||
const props = defineProps<{
|
||||
includeSelf?: boolean;
|
||||
}>();
|
||||
|
||||
let username = $ref('');
|
||||
let host = $ref('');
|
||||
let users: misskey.entities.UserDetailed[] = $ref([]);
|
||||
|
@ -110,7 +115,11 @@ onMounted(() => {
|
|||
os.api('users/show', {
|
||||
userIds: defaultStore.state.recentlyUsedUsers,
|
||||
}).then(users => {
|
||||
recentUsers = users;
|
||||
if (props.includeSelf) {
|
||||
recentUsers = [$i, ...users];
|
||||
} else {
|
||||
recentUsers = users;
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -322,9 +322,11 @@ export function form(title, form) {
|
|||
});
|
||||
}
|
||||
|
||||
export async function selectUser() {
|
||||
export async function selectUser(opts: { includeSelf?: boolean } = {}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
popup(defineAsyncComponent(() => import('@/components/MkUserSelectDialog.vue')), {}, {
|
||||
popup(defineAsyncComponent(() => import('@/components/MkUserSelectDialog.vue')), {
|
||||
includeSelf: opts.includeSelf,
|
||||
}, {
|
||||
ok: user => {
|
||||
resolve(user);
|
||||
},
|
||||
|
|
|
@ -77,7 +77,9 @@ async function del() {
|
|||
}
|
||||
|
||||
function assign() {
|
||||
os.selectUser().then(async (user) => {
|
||||
os.selectUser({
|
||||
includeSelf: true,
|
||||
}).then(async (user) => {
|
||||
await os.apiWithDialog('admin/roles/assign', { roleId: role.id, userId: user.id });
|
||||
role.users.push(user);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue