mirror of
https://github.com/hotomoe/hotomoe
synced 2024-12-02 16:58:11 +09:00
enhance(client): improve usability of user select
This commit is contained in:
parent
f3c5ca6cf4
commit
fbfe42d6f0
@ -60,6 +60,7 @@ import MkModalWindow from '@/components/MkModalWindow.vue';
|
|||||||
import * as os from '@/os';
|
import * as os from '@/os';
|
||||||
import { defaultStore } from '@/store';
|
import { defaultStore } from '@/store';
|
||||||
import { i18n } from '@/i18n';
|
import { i18n } from '@/i18n';
|
||||||
|
import { $i } from '@/account';
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(ev: 'ok', selected: misskey.entities.UserDetailed): void;
|
(ev: 'ok', selected: misskey.entities.UserDetailed): void;
|
||||||
@ -67,6 +68,10 @@ const emit = defineEmits<{
|
|||||||
(ev: 'closed'): void;
|
(ev: 'closed'): void;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
includeSelf?: boolean;
|
||||||
|
}>();
|
||||||
|
|
||||||
let username = $ref('');
|
let username = $ref('');
|
||||||
let host = $ref('');
|
let host = $ref('');
|
||||||
let users: misskey.entities.UserDetailed[] = $ref([]);
|
let users: misskey.entities.UserDetailed[] = $ref([]);
|
||||||
@ -110,7 +115,11 @@ onMounted(() => {
|
|||||||
os.api('users/show', {
|
os.api('users/show', {
|
||||||
userIds: defaultStore.state.recentlyUsedUsers,
|
userIds: defaultStore.state.recentlyUsedUsers,
|
||||||
}).then(users => {
|
}).then(users => {
|
||||||
|
if (props.includeSelf) {
|
||||||
|
recentUsers = [$i, ...users];
|
||||||
|
} else {
|
||||||
recentUsers = users;
|
recentUsers = users;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</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) => {
|
return new Promise((resolve, reject) => {
|
||||||
popup(defineAsyncComponent(() => import('@/components/MkUserSelectDialog.vue')), {}, {
|
popup(defineAsyncComponent(() => import('@/components/MkUserSelectDialog.vue')), {
|
||||||
|
includeSelf: opts.includeSelf,
|
||||||
|
}, {
|
||||||
ok: user => {
|
ok: user => {
|
||||||
resolve(user);
|
resolve(user);
|
||||||
},
|
},
|
||||||
|
@ -77,7 +77,9 @@ async function del() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function assign() {
|
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 });
|
await os.apiWithDialog('admin/roles/assign', { roleId: role.id, userId: user.id });
|
||||||
role.users.push(user);
|
role.users.push(user);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user