ui: fix the problematic search stringify function

This commit is contained in:
undefined committed 2023-08-10 14:04:00 +08:00
1 parent 81d6582d33
commit f79f3d2d79
6 files changed
+41 -6

No files matched your search

-1
View File
@@ -126,7 +126,6 @@
"markdown-it-table-of-contents": "^0.6.0",
"nunjucks": "^3.2.4",
"schemastery-jsonschema": "^1.0.3",
"search-query-parser": "^1.6.0",
"streamsaver": "^2.0.6",
"xss": "^1.0.14"
}
@@ -1,6 +1,6 @@
import parser, { SearchParserResult } from '@hydrooj/utils/lib/search';
import $ from 'jquery';
import _ from 'lodash';
import parser from 'search-query-parser';
import DomainSelectAutoComplete from 'vj/components/autocomplete/DomainSelectAutoComplete';
import { ActionDialog, ConfirmDialog } from 'vj/components/dialog';
import Dropdown from 'vj/components/dropdown/Dropdown';
@@ -30,7 +30,7 @@ const parserOptions = {
function writeSelectionToInput() {
const currentValue = $('[name="q"]').val() as string;
const parsedCurrentValue = parser.parse(currentValue, parserOptions) as parser.SearchParserResult;
const parsedCurrentValue = parser.parse(currentValue, parserOptions) as SearchParserResult;
const q = parser.stringify({
...parsedCurrentValue,
category: selections,
@@ -138,7 +138,7 @@ function buildCategoryFilter() {
}
function parseCategorySelection() {
const parsed = parser.parse($('[name="q"]').val() as string || '', parserOptions) as parser.SearchParserResult;
const parsed = parser.parse($('[name="q"]').val() as string || '', parserOptions) as SearchParserResult;
selections = _.uniq(parsed.category || []);
updateSelection();
}