core&ui: add new features about domain (#528)

Co-authored-by: undefined <i@undefined.moe>

- Add navigation hint
- Update homework/contest filter by assign
- Allow empty query for DomainSelectAutoComplete
This commit is contained in:
panda authored and GitHub committed 2023-03-12 22:45:23 +08:00
1 parent 9fb85300e7
commit 3581ccb065
12 files changed
+129 -35

No files matched your search

+5 -2
View File
@@ -72,10 +72,13 @@ ScheduleModel.Worker.addHandler('contest', async (doc) => {
export class ContestListHandler extends Handler {
@param('rule', Types.Range(contest.RULES), true)
@param('page', Types.PositiveInt, true)
async get(domainId: string, rule = '', page = 1) {
@param('all', Types.Boolean)
async get(domainId: string, rule = '', page = 1, all = false) {
if (rule && contest.RULES[rule].hidden) throw new BadRequestError();
const rules = Object.keys(contest.RULES).filter((i) => !contest.RULES[i].hidden);
const cursor = contest.getMulti(domainId, rule ? { rule } : { rule: { $in: rules } });
if (all && !this.user.hasPerm(PERM.PERM_MOD_BADGE)) all = false;
const q = { ...all ? { assign: { $in: [...this.user.group, null] } } : {}, ...rule ? { rule } : { rule: { $in: rules } } };
const cursor = contest.getMulti(domainId, q);
const qs = rule ? `rule=${rule}` : '';
const [tdocs, tpcount] = await paginate<Tdoc>(cursor, page, system.get('pagination.contest'));
const tids = [];