mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
ui: problem_copy
This commit is contained in:
1 parent
42b73f36a4
commit
0aba9f8215
6 files changed
+40
-10
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "3.1.0",
|
"version": "3.1.1",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "src/loader",
|
"main": "src/loader",
|
||||||
"module": "src/loader",
|
"module": "src/loader",
|
||||||
|
|||||||
@@ -5,9 +5,10 @@ import { lookup } from 'mime-types';
|
|||||||
import { FilterQuery, ObjectID } from 'mongodb';
|
import { FilterQuery, ObjectID } from 'mongodb';
|
||||||
import { sortFiles } from '@hydrooj/utils/lib/utils';
|
import { sortFiles } from '@hydrooj/utils/lib/utils';
|
||||||
import {
|
import {
|
||||||
BadRequestError, ContestNotAttendedError, ContestNotFoundError, ContestNotLiveError, ForbiddenError, NoProblemError,
|
BadRequestError, ContestNotAttendedError, ContestNotFoundError,
|
||||||
PermissionError, ProblemNotFoundError, SolutionNotFoundError,
|
ContestNotLiveError, ForbiddenError, NoProblemError,
|
||||||
ValidationError,
|
NotFoundError, PermissionError, ProblemNotFoundError,
|
||||||
|
SolutionNotFoundError, ValidationError,
|
||||||
} from '../error';
|
} from '../error';
|
||||||
import {
|
import {
|
||||||
ProblemDoc, ProblemStatusDoc, Tdoc, User,
|
ProblemDoc, ProblemStatusDoc, Tdoc, User,
|
||||||
@@ -293,8 +294,10 @@ export class ProblemDetailHandler extends ProblemHandler {
|
|||||||
@param('target', Types.String)
|
@param('target', Types.String)
|
||||||
@param('pid', Types.String, true)
|
@param('pid', Types.String, true)
|
||||||
async postCopy(domainId: string, target: string, pid: string) {
|
async postCopy(domainId: string, target: string, pid: string) {
|
||||||
|
const ddoc = await domain.get(target);
|
||||||
|
if (!ddoc) throw new NotFoundError(target);
|
||||||
const dudoc = await user.getById(target, this.user._id);
|
const dudoc = await user.getById(target, this.user._id);
|
||||||
dudoc.checkPerm(PERM.PERM_CREATE_PROBLEM);
|
if (!dudoc.hasPerm(PERM.PERM_CREATE_PROBLEM)) throw new PermissionError(PERM.PERM_CREATE_PROBLEM);
|
||||||
const docId = await problem.copy(domainId, this.user.docId, target, pid);
|
const docId = await problem.copy(domainId, this.user.docId, target, pid);
|
||||||
this.response.redirect = this.url('problem_detail', { domainId: target, pid: docId });
|
this.response.redirect = this.url('problem_detail', { domainId: target, pid: docId });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/ui-default",
|
"name": "@hydrooj/ui-default",
|
||||||
"version": "4.26.1",
|
"version": "4.26.2",
|
||||||
"author": "undefined <i@undefined.moe>",
|
"author": "undefined <i@undefined.moe>",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"main": "hydro.js",
|
"main": "hydro.js",
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import { NamedPage } from 'vj/misc/Page';
|
import { NamedPage } from 'vj/misc/Page';
|
||||||
import tpl from 'vj/utils/tpl';
|
import tpl from 'vj/utils/tpl';
|
||||||
import i18n from 'vj/utils/i18n';
|
import i18n from 'vj/utils/i18n';
|
||||||
import { ConfirmDialog } from 'vj/components/dialog';
|
import request from 'vj/utils/request';
|
||||||
|
import { ActionDialog, ConfirmDialog } from 'vj/components/dialog';
|
||||||
|
import Notification from 'vj/components/notification';
|
||||||
|
|
||||||
const page = new NamedPage([
|
const page = new NamedPage([
|
||||||
'problem_create', 'problem_edit', 'problem_solution', 'problem_submit',
|
'problem_create', 'problem_edit', 'problem_solution', 'problem_submit',
|
||||||
@@ -20,6 +22,33 @@ const page = new NamedPage([
|
|||||||
$(ev.currentTarget).closest('form').trigger('submit');
|
$(ev.currentTarget).closest('form').trigger('submit');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
$(document).on('click', '[name="problem-sidebar__copy"]', () => {
|
||||||
|
new ActionDialog({
|
||||||
|
$body: tpl`
|
||||||
|
<div class="typo">
|
||||||
|
<label>
|
||||||
|
${i18n('Target')}
|
||||||
|
<div class="textbox-container">
|
||||||
|
<input name="target" type="text" class="textbox" data-autofocus>
|
||||||
|
</div>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
`,
|
||||||
|
}).open().then(async (action) => {
|
||||||
|
if (action !== 'ok') return;
|
||||||
|
const target = $('[name="target"]').val();
|
||||||
|
if (!target) return;
|
||||||
|
try {
|
||||||
|
const res = await request.post('', {
|
||||||
|
operation: 'copy',
|
||||||
|
target,
|
||||||
|
});
|
||||||
|
window.location.href = res.url;
|
||||||
|
} catch (error) {
|
||||||
|
Notification.error(error.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
export default page;
|
export default page;
|
||||||
@@ -19,5 +19,3 @@ Disallow: /p/*/edit
|
|||||||
Disallow: /d/*/p/*/edit
|
Disallow: /d/*/p/*/edit
|
||||||
Disallow: /p/*/file/
|
Disallow: /p/*/file/
|
||||||
Disallow: /d/*/p/*/file/
|
Disallow: /d/*/p/*/file/
|
||||||
Disallow: /contest/*/p/*/submit
|
|
||||||
Disallow: /d/*/contest/*/p/*/submit
|
|
||||||
@@ -91,7 +91,7 @@
|
|||||||
<span class="icon icon-download"></span> {{ _('Download') }}
|
<span class="icon icon-download"></span> {{ _('Download') }}
|
||||||
</a></li>
|
</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if handler.user.user.hasPriv(PRIV.PRIV_CREATE_DOMAIN) %}
|
{% if handler.user.hasPriv(PRIV.PRIV_CREATE_DOMAIN) %}
|
||||||
<li class="menu__item nojs--hide"><a class="menu__link" href="javascript:;" name="problem-sidebar__copy">
|
<li class="menu__item nojs--hide"><a class="menu__link" href="javascript:;" name="problem-sidebar__copy">
|
||||||
<span class="icon icon-copy"></span> {{ _('Copy') }}
|
<span class="icon icon-copy"></span> {{ _('Copy') }}
|
||||||
</a></li>
|
</a></li>
|
||||||
|
|||||||
Reference in new issue
Block a user