mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core&ui: fix defaultPriv edit (#444)
Co-authored-by: undefined <i@undefined.moe>
This commit is contained in:
1 parent
e964eec099
commit
a230d1c7c3
5 files changed
+39
-38
No files matched your search
@@ -4,37 +4,36 @@ import i18n from 'vj/utils/i18n';
|
||||
import tpl from 'vj/utils/tpl';
|
||||
import createHint from './hint';
|
||||
|
||||
let inserted = false;
|
||||
let hintInserted = false;
|
||||
$(tpl`<div style="display: none" class="dialog__body--user-select">
|
||||
<div class="row"><div class="columns">
|
||||
<h1 name="select_user_hint">${i18n('Select User')}</h1>
|
||||
</div></div>
|
||||
<div class="row">
|
||||
<div class="columns">
|
||||
<label>${i18n('Username / UID')}
|
||||
<input name="user" type="text" class="textbox" autocomplete="off" data-autofocus>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>`).appendTo(document.body);
|
||||
const userSelector = UserSelectAutoComplete.getOrConstruct($('.dialog__body--user-select [name="user"]')) as any;
|
||||
const userSelectDialog = new ActionDialog({
|
||||
$body: $('.dialog__body--user-select > div'),
|
||||
onDispatch(action) {
|
||||
if (action === 'ok' && userSelector.value() === null) {
|
||||
userSelector.focus();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
});
|
||||
|
||||
export default async function selectUser(hint?: string) {
|
||||
if (!inserted) {
|
||||
const el = $(tpl`<div style="display: none" class="dialog__body--user-select">
|
||||
<div class="row"><div class="columns">
|
||||
<h1 name="select_user_hint">${i18n('Select User')}</h1>
|
||||
</div></div>
|
||||
<div class="row">
|
||||
<div class="columns">
|
||||
<label>${i18n('Username / UID')}
|
||||
<input name="user" type="text" class="textbox" autocomplete="off" data-autofocus>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>`);
|
||||
el.appendTo(document.body);
|
||||
if (hint) createHint(hint, $('[name="select_user_hint"]'));
|
||||
inserted = true;
|
||||
if (hint && !hintInserted) {
|
||||
createHint(hint, $('[name="select_user_hint"]'));
|
||||
hintInserted = true;
|
||||
}
|
||||
const userSelector = UserSelectAutoComplete.getOrConstruct($('.dialog__body--user-select [name="user"]')) as any;
|
||||
const userSelectDialog = new ActionDialog({
|
||||
$body: $('.dialog__body--user-select > div'),
|
||||
onDispatch(action) {
|
||||
if (action === 'ok' && userSelector.value() === null) {
|
||||
userSelector.focus();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
});
|
||||
userSelector.clear();
|
||||
const action = await userSelectDialog.open();
|
||||
if (action !== 'ok') return null;
|
||||
|
||||
Reference in new issue
Block a user