mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
ui: fix contest_edit
This commit is contained in:
1 parent
b406b8989d
commit
fa4b7b6f33
7 files changed
+32
-27
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "2.23.24",
|
"version": "2.23.25",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "dist/loader.js",
|
"main": "dist/loader.js",
|
||||||
"typings": "dist/loader.d.ts",
|
"typings": "dist/loader.d.ts",
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ class ContestEditHandler extends ContestHandler {
|
|||||||
domainId: string, beginAtDate: string, beginAtTime: string, duration: number,
|
domainId: string, beginAtDate: string, beginAtTime: string, duration: number,
|
||||||
title: string, content: string, rule: string, _pids: string, rated = false,
|
title: string, content: string, rule: string, _pids: string, rated = false,
|
||||||
) {
|
) {
|
||||||
let pids = _pids.split(',').map((i) => {
|
let pids = _pids.replace(/,/g, ',').split(',').map((i) => {
|
||||||
if (isSafeInteger(parseInt(i, 10))) return parseInt(i, 10);
|
if (isSafeInteger(parseInt(i, 10))) return parseInt(i, 10);
|
||||||
return i;
|
return i;
|
||||||
});
|
});
|
||||||
@@ -422,7 +422,7 @@ class ContestCreateHandler extends ContestHandler {
|
|||||||
domainId: string, beginAtDate: string, beginAtTime: string, duration: number,
|
domainId: string, beginAtDate: string, beginAtTime: string, duration: number,
|
||||||
title: string, content: string, rule: string, _pids: string, rated = false,
|
title: string, content: string, rule: string, _pids: string, rated = false,
|
||||||
) {
|
) {
|
||||||
let pids = _pids.split(',').map((i) => {
|
let pids = _pids.replace(/,/g, ',').split(',').map((i) => {
|
||||||
if (isSafeInteger(parseInt(i, 10))) return parseInt(i, 10);
|
if (isSafeInteger(parseInt(i, 10))) return parseInt(i, 10);
|
||||||
return i;
|
return i;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -244,7 +244,7 @@ class HomeworkCreateHandler extends HomeworkHandler {
|
|||||||
penaltySinceDate: string, penaltySinceTime: string, extensionDays: number,
|
penaltySinceDate: string, penaltySinceTime: string, extensionDays: number,
|
||||||
penaltyRules: PenaltyRules, title: string, content: string, _pids: string, rated = false,
|
penaltyRules: PenaltyRules, title: string, content: string, _pids: string, rated = false,
|
||||||
) {
|
) {
|
||||||
const pids = _pids.split(',').map((i) => {
|
const pids = _pids.replace(/,/g, ',').split(',').map((i) => {
|
||||||
if (isSafeInteger(parseInt(i, 10))) return parseInt(i, 10);
|
if (isSafeInteger(parseInt(i, 10))) return parseInt(i, 10);
|
||||||
return i;
|
return i;
|
||||||
});
|
});
|
||||||
@@ -311,7 +311,7 @@ class HomeworkEditHandler extends HomeworkHandler {
|
|||||||
penaltySinceDate: string, penaltySinceTime: string, extensionDays: number,
|
penaltySinceDate: string, penaltySinceTime: string, extensionDays: number,
|
||||||
penaltyRules: string, title: string, content: string, _pids: string, rated = false,
|
penaltyRules: string, title: string, content: string, _pids: string, rated = false,
|
||||||
) {
|
) {
|
||||||
const pids = _pids.split(',').map((i) => {
|
const pids = _pids.replace(/,/g, ',').split(',').map((i) => {
|
||||||
if (isSafeInteger(parseInt(i, 10))) return parseInt(i, 10);
|
if (isSafeInteger(parseInt(i, 10))) return parseInt(i, 10);
|
||||||
return i;
|
return i;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -95,16 +95,21 @@ export default class AutoComplete extends DOMAttachedObject {
|
|||||||
|
|
||||||
onItemClick(ev) {
|
onItemClick(ev) {
|
||||||
const idx = $(ev.currentTarget).attr('data-idx');
|
const idx = $(ev.currentTarget).attr('data-idx');
|
||||||
if (idx === undefined) {
|
if (idx === undefined) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
const item = this.currentItems[idx];
|
const item = this.currentItems[idx];
|
||||||
const text = this.options.text(item);
|
const text = this.options.text(item);
|
||||||
this._value = item;
|
this._value = item;
|
||||||
this.$dom.trigger('vjAutoCompleteSelect', item);
|
this.$dom.trigger('vjAutoCompleteSelect', item);
|
||||||
if (text != null) {
|
if (text != null) {
|
||||||
if (!this.options.multi) this.$dom.val(text);
|
if (!this.options.multi) this.$dom.val(text);
|
||||||
else this.$dom.val(`${this.$dom.val() + text}, `);
|
else {
|
||||||
|
const current = this.$dom.val().replace(/,/g, ',');
|
||||||
|
if (current.indexOf(',') !== -1) {
|
||||||
|
const items = current.split(',');
|
||||||
|
items[items.length - 1] = text;
|
||||||
|
this.$dom.val(items.join(', '));
|
||||||
|
} else this.$dom.val(`${text}, `);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.close();
|
this.close();
|
||||||
}
|
}
|
||||||
@@ -150,24 +155,23 @@ export default class AutoComplete extends DOMAttachedObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
close() {
|
close() {
|
||||||
if (!this.isOpen) {
|
if (!this.isOpen) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.dropInstance.close();
|
this.dropInstance.close();
|
||||||
this.isOpen = false;
|
this.isOpen = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateOpenState() {
|
updateOpenState() {
|
||||||
if (this.isFocus && this.$dom.val().length >= this.options.minChar) {
|
let content = this.$dom.val();
|
||||||
|
if (this.options.multi) {
|
||||||
|
content = content.split(',');
|
||||||
|
content = content[content.length - 1].trim();
|
||||||
|
}
|
||||||
|
if (this.isFocus && content >= this.options.minChar) {
|
||||||
if (!this.isOpen) {
|
if (!this.isOpen) {
|
||||||
this.open();
|
this.open();
|
||||||
this.renderList();
|
this.renderList();
|
||||||
}
|
}
|
||||||
} else {
|
} else if (this.isOpen) this.close();
|
||||||
if (this.isOpen) {
|
|
||||||
this.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
detach() {
|
detach() {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { AutoloadPage } from 'vj/misc/Page';
|
import { AutoloadPage } from 'vj/misc/Page';
|
||||||
import delay from 'vj/utils/delay'
|
import delay from 'vj/utils/delay';
|
||||||
|
|
||||||
const formPage = new AutoloadPage('formPage', () => {
|
const formPage = new AutoloadPage('formPage', () => {
|
||||||
$(document).on('vjFormDisableUpdate', 'input, select, textarea', (ev) => {
|
$(document).on('vjFormDisableUpdate', 'input, select, textarea', (ev) => {
|
||||||
@@ -13,13 +13,14 @@ const formPage = new AutoloadPage('formPage', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const submitting = {};
|
const submitting = {};
|
||||||
|
$(document).on('click', '[type="submit"]', (ev) => {
|
||||||
$('[type="submit"]').on('click', async (ev) => {
|
const $dom = $(ev.currentTarget);
|
||||||
if (!submitting[ev.currentTarget]) $(ev.currentTarget).closest('form').submit();
|
if ($dom.attr('name') && $dom.attr('value')) return;
|
||||||
|
ev.preventDefault();
|
||||||
|
if (!submitting[ev.currentTarget]) $dom.closest('form').trigger('submit');
|
||||||
submitting[ev.currentTarget] = true;
|
submitting[ev.currentTarget] = true;
|
||||||
await delay(5000);
|
delay(5000).then(() => { submitting[ev.currentTarget] = false; });
|
||||||
submitting[ev.currentTarget] = false;
|
});
|
||||||
})
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export default formPage;
|
export default formPage;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/ui-default",
|
"name": "@hydrooj/ui-default",
|
||||||
"version": "4.6.11",
|
"version": "4.6.12",
|
||||||
"author": "undefined <i@undefined.moe>",
|
"author": "undefined <i@undefined.moe>",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"main": "hydro.js",
|
"main": "hydro.js",
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import i18n from 'vj/utils/i18n';
|
|||||||
import request from 'vj/utils/request';
|
import request from 'vj/utils/request';
|
||||||
|
|
||||||
const page = new NamedPage(['contest_edit', 'contest_create', 'homework_create', 'homework_edit'], (pagename) => {
|
const page = new NamedPage(['contest_edit', 'contest_create', 'homework_create', 'homework_edit'], (pagename) => {
|
||||||
ProblemSelectAutoComplete.getOrConstruct($('[name="pids"]'), { multi: true });
|
ProblemSelectAutoComplete.getOrConstruct($('[name="pids"]'), { multi: true, clearDefaultValue: false });
|
||||||
if (pagename.endsWith('edit')) {
|
if (pagename.endsWith('edit')) {
|
||||||
let confirmed = false;
|
let confirmed = false;
|
||||||
$(document).on('click', '[name="operation"]', (ev) => {
|
$(document).on('click', '[name="operation"]', (ev) => {
|
||||||
|
|||||||
Reference in new issue
Block a user