ui: problem_files: pjax support

This commit is contained in:
undefined committed 2021-05-15 19:02:42 +08:00
1 parent c061c1ec93
commit 3e1d4635c4
16 files changed
+234 -184

No files matched your search

+13 -2
View File
@@ -379,13 +379,24 @@ export class ProblemEditHandler extends ProblemManageHandler {
export class ProblemFilesHandler extends ProblemDetailHandler {
@param('testdata', Types.Boolean)
@param('additional_file', Types.Boolean)
async get(domainId: string, getTestdata = true, getAdditionalFile = true) {
@param('pjax', Types.Boolean)
async get(domainId: string, getTestdata = true, getAdditionalFile = true, pjax = false) {
const canReadData = this.user.own(this.pdoc)
|| this.user.hasPriv(PRIV.PRIV_READ_PROBLEM_DATA)
|| this.user.hasPerm(PERM.PERM_READ_PROBLEM_DATA);
this.response.body.testdata = (getTestdata && canReadData) ? sortFiles(this.pdoc.data || []) : [];
this.response.body.additional_file = getAdditionalFile ? sortFiles(this.pdoc.additional_file || []) : [];
this.response.template = 'problem_files.html';
if (pjax) {
const { testdata, additional_file } = this.response.body;
this.response.body = {
fragments: (await Promise.all([
this.renderHTML('partials/problem_files-testdata.html', { testdata, pdoc: this.pdoc }),
this.renderHTML('partials/problem_files-additional_file.html', { additional_file, pdoc: this.pdoc }),
this.renderHTML('partials/problem-sidebar-information.html', { pdoc: this.pdoc }),
])).map((i) => ({ html: i })),
};
this.response.template = '';
} else this.response.template = 'problem_files.html';
}
@post('files', Types.Set)