Skip to content

Commit

Permalink
ui: fix edit subcategory tag
Browse files Browse the repository at this point in the history
  • Loading branch information
pandadtdyy committed Sep 6, 2023
1 parent 84962bf commit 2dc999b
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions packages/ui-default/pages/problem_edit.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,16 @@ function buildCategoryFilter() {
});
$(document).on('click', '.widget--category-filter__tag', (ev) => {
if (ev.shiftKey || ev.metaKey || ev.ctrlKey) return;
const category = $(ev.currentTarget).text();
const treeItem = categories[category];
const tag = $(ev.currentTarget).text();
const category = $(ev.currentTarget).attr('data-category');
const treeItem = category ? categories[category].children[tag] : categories[tag];
// the effect should be cancelSelect if it is shown as selected when clicking
const shouldSelect = treeItem.$tag.hasClass('selected') ? false : !treeItem.select;
treeItem.select = shouldSelect;
dirtyCategories.push({ type: 'category', category });
if (!shouldSelect) {
dirtyCategories.push(category
? { type: 'subcategory', subcategory: tag, category }
: { type: 'category', category: tag });
if (!category && !shouldSelect) {
// de-select children
_.forEach(treeItem.children, (treeSubItem, subcategory) => {
if (treeSubItem.select) {
Expand All @@ -134,16 +137,6 @@ function buildCategoryFilter() {
updateSelection();
ev.preventDefault();
});
$(document).on('click', '.widget--category-filter__subcategory-tag', (ev) => {
if (ev.shiftKey || ev.metaKey || ev.ctrlKey) return;
const subcategory = $(ev.currentTarget).text();
const category = $(ev.currentTarget).attr('data-category');
const treeItem = categories[category].children[subcategory];
treeItem.select = !treeItem.select;
dirtyCategories.push({ type: 'subcategory', subcategory, category });
updateSelection();
ev.preventDefault();
});
}

async function handleSection(ev, sidebar, type) {
Expand Down

0 comments on commit 2dc999b

Please sign in to comment.