mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
core: add contest score ratio (#765)
Co-authored-by: panda <panda_dtdyy@outlook.com>
This commit is contained in:
1 parent
9013c4eaa6
commit
e25db178fd
11 files changed
+121
-23
No files matched your search
@@ -120,6 +120,10 @@ $highlight-button-color = #F6DF45
|
||||
&.nojs .col--submit-at
|
||||
width: rem(160px)
|
||||
|
||||
.col--score
|
||||
width: rem(80px)
|
||||
text-align: center;
|
||||
|
||||
.col--problem
|
||||
border-left: 1px solid $table-border-color
|
||||
|
||||
@@ -208,3 +212,7 @@ $highlight-button-color = #F6DF45
|
||||
|
||||
.col--awards
|
||||
width: rem(130px)
|
||||
|
||||
.page--contest_manage
|
||||
.col--score
|
||||
width: rem(80px)
|
||||
@@ -1,5 +1,9 @@
|
||||
import $ from 'jquery';
|
||||
import { ActionDialog } from 'vj/components/dialog';
|
||||
import Notification from 'vj/components/notification';
|
||||
import { NamedPage } from 'vj/misc/Page';
|
||||
import { i18n, request, tpl } from 'vj/utils';
|
||||
|
||||
function handleReplyOrBroadcast(ev) {
|
||||
const title = $(ev.currentTarget).data('title');
|
||||
const did = $(ev.currentTarget).data('did');
|
||||
@@ -19,6 +23,50 @@ function handleReplyOrBroadcast(ev) {
|
||||
const page = new NamedPage('contest_manage', () => {
|
||||
$(document).on('click', '[name="broadcast"]', handleReplyOrBroadcast);
|
||||
$(document).on('click', '[name="reply"]', handleReplyOrBroadcast);
|
||||
$(document).on('click', '[name="set_score"]', async (ev) => {
|
||||
const pid = $(ev.currentTarget).data('pid');
|
||||
const op = await new ActionDialog({
|
||||
$body: tpl`
|
||||
<div class="row"><div class="columns">
|
||||
<h1>${i18n('Set Score for Contest')}</h1>
|
||||
</div></div>
|
||||
<div class="row"><div class="columns">
|
||||
<label>
|
||||
${i18n('score')}
|
||||
<div class="textbox-container">
|
||||
<input class="textbox" type="number" step="1" name="score" data-autofocus value="${$(ev.currentTarget).data('score')}"></input>
|
||||
</div>
|
||||
</label>
|
||||
</div></div>
|
||||
`,
|
||||
onDispatch(action) {
|
||||
if (action === 'ok' && $('[name="score"]').val() === null) {
|
||||
$('[name="score"]').focus();
|
||||
return false;
|
||||
}
|
||||
if (!Number.isFinite(+$('[name="score"]').val()) || +$('[name="score"]').val() <= 0) {
|
||||
Notification.error('Invalid score');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
}).open();
|
||||
if (op !== 'ok') return;
|
||||
try {
|
||||
const res = await request.post('', {
|
||||
operation: 'set_score',
|
||||
pid,
|
||||
score: $('[name="score"]').val(),
|
||||
});
|
||||
if (!res.error) {
|
||||
Notification.success('Score Updated');
|
||||
$(ev.currentTarget).text($('[name="score"]').val() as number);
|
||||
$(ev.currentTarget).data('score', $('[name="score"]').val());
|
||||
}
|
||||
} catch (e) {
|
||||
Notification.error(e.message);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
export default page;
|
||||
@@ -3,7 +3,7 @@
|
||||
width: 60px
|
||||
|
||||
.col--size
|
||||
width: 120px
|
||||
width: 100px
|
||||
|
||||
.col--operation
|
||||
width: 40px
|
||||
Reference in new issue
Block a user