mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
core&ui: add problems gql to fix autocomplete (#389)
This commit is contained in:
1 parent
4b3c57549a
commit
a52c488e23
5 files changed
+17
-5
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "3.14.16",
|
||||
"version": "3.14.17",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "src/loader",
|
||||
"module": "src/loader",
|
||||
|
||||
@@ -80,6 +80,11 @@ registerResolver(
|
||||
return pdoc;
|
||||
},
|
||||
);
|
||||
registerResolver('Query', 'problems(ids: [Int])', '[Problem]', async (arg, ctx) => {
|
||||
const res = await problem.getList(ctx.args.domainId, arg.ids, ctx.user.hasPerm(PERM.PERM_VIEW_PROBLEM_HIDDEN) || ctx.user._id,
|
||||
ctx.user.group, undefined, undefined, true);
|
||||
return Object.keys(res).map((id) => res[+id]);
|
||||
}, 'Get a list of problem by ids');
|
||||
registerResolver(
|
||||
'Problem', 'manage', 'ProblemManage',
|
||||
(arg, ctx) => {
|
||||
|
||||
@@ -488,7 +488,8 @@ export async function get(domainId: string, tid: ObjectID): Promise<Tdoc<30>> {
|
||||
}
|
||||
|
||||
export async function getRelated(domainId: string, pid: number) {
|
||||
return await document.getMulti(domainId, document.TYPE_CONTEST, { pids: pid }).toArray();
|
||||
const rules = Object.keys(RULES).filter((i) => !RULES[i].hidden);
|
||||
return await document.getMulti(domainId, document.TYPE_CONTEST, { pids: pid, rule: { $in: rules } }).toArray();
|
||||
}
|
||||
|
||||
export async function getStatus(domainId: string, tid: ObjectID, uid: number) {
|
||||
|
||||
+8
-2
@@ -1,5 +1,6 @@
|
||||
import React, { forwardRef } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import api, { gql } from 'vj/utils/api';
|
||||
import request from 'vj/utils/request';
|
||||
import type { ProblemDoc } from 'hydrooj/src/interface';
|
||||
import AutoComplete, { AutoCompleteHandle, AutoCompleteProps } from './AutoComplete';
|
||||
@@ -9,8 +10,13 @@ const ProblemSelectAutoComplete = forwardRef<AutoCompleteHandle<ProblemDoc>, Aut
|
||||
ref={ref as any}
|
||||
cacheKey={`problem-${UiContext.domainId}`}
|
||||
queryItems={(query) => request.get(`/d/${UiContext.domainId}/problem/list`, { prefix: query })}
|
||||
// FIXME fetch items
|
||||
fetchItems={(ids) => ids.map((id) => ({ docId: id, pid: id, title: id }) as any)}
|
||||
fetchItems={(ids) => api(gql`
|
||||
problems(ids: ${ids.map((i) => +i)}) {
|
||||
docId
|
||||
pid
|
||||
title
|
||||
}
|
||||
`, ['data', 'problems'])}
|
||||
itemText={(pdoc) => `${`${pdoc.docId} ${pdoc.title}`}`}
|
||||
itemKey={(pdoc) => `${pdoc.docId || pdoc}`}
|
||||
renderItem={(pdoc) => (
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@hydrooj/ui-default",
|
||||
"version": "4.38.16",
|
||||
"version": "4.38.17",
|
||||
"author": "undefined <i@undefined.moe>",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "hydro.js",
|
||||
|
||||
Reference in new issue
Block a user