FIX: Simplify navigation to subcategories page (#27053)
Navigation to subcategories page was possible through the category drop
and the "view all" link or through the category drop from the categories
page. This commit removes the latter method.
Follow up to commit 77b032c2b5
.
This commit is contained in:
parent
73481e8f45
commit
f5a0da6eba
|
@ -24,13 +24,11 @@
|
|||
@tagId={{this.tag.id}}
|
||||
@editingCategory={{this.editingCategory}}
|
||||
@editingCategoryTab={{this.editingCategoryTab}}
|
||||
@filterType={{this.filterType}}
|
||||
@options={{hash
|
||||
parentCategory=breadcrumb.parentCategory
|
||||
subCategory=breadcrumb.isSubcategory
|
||||
noSubcategories=breadcrumb.noSubcategories
|
||||
autoFilterable=true
|
||||
disableIfHasNoChildren=(eq this.filterType "categories")
|
||||
}}
|
||||
/>
|
||||
</li>
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
@noSubcategories={{this.noSubcategories}}
|
||||
@tag={{this.tag}}
|
||||
@additionalTags={{this.additionalTags}}
|
||||
@filterType={{this.filterType}}
|
||||
/>
|
||||
|
||||
{{#unless this.additionalTags}}
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
import { currentRouteName, currentURL, visit } from "@ember/test-helpers";
|
||||
import { test } from "qunit";
|
||||
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
||||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||
|
||||
acceptance("Subcategories", function (needs) {
|
||||
needs.site({
|
||||
lazy_load_categories: true,
|
||||
});
|
||||
|
||||
test("navigation can be used to navigate subcategories pages", async function (assert) {
|
||||
await visit("/categories");
|
||||
|
||||
let categoryDrop = selectKit(
|
||||
".category-breadcrumb li:nth-of-type(1) .category-drop"
|
||||
);
|
||||
await categoryDrop.expand();
|
||||
await categoryDrop.selectRowByValue("2"); // "feature" category
|
||||
|
||||
assert.strictEqual(currentRouteName(), "discovery.subcategories");
|
||||
assert.strictEqual(currentURL(), "/c/feature/2/subcategories");
|
||||
|
||||
categoryDrop = selectKit(
|
||||
".category-breadcrumb li:nth-of-type(2) .category-drop"
|
||||
);
|
||||
await categoryDrop.expand();
|
||||
await categoryDrop.selectRowByValue("26"); // "spec" category
|
||||
|
||||
assert.strictEqual(currentRouteName(), "discovery.subcategories");
|
||||
assert.strictEqual(currentURL(), "/c/feature/spec/26/subcategories");
|
||||
});
|
||||
});
|
|
@ -27,6 +27,12 @@ export default class CategoryDropMoreCollection extends Component {
|
|||
return this.args.selectKit.totalCount - currentCount;
|
||||
}
|
||||
|
||||
get slugPath() {
|
||||
return this.args.selectKit.options.parentCategory.path.substring(
|
||||
"/c/".length
|
||||
);
|
||||
}
|
||||
|
||||
<template>
|
||||
{{#if this.moreCount}}
|
||||
<div class="category-drop-footer">
|
||||
|
@ -35,10 +41,7 @@ export default class CategoryDropMoreCollection extends Component {
|
|||
</span>
|
||||
|
||||
{{#if @selectKit.options.parentCategory}}
|
||||
<LinkTo
|
||||
@route="discovery.subcategories"
|
||||
@model={{@selectKit.options.parentCategory.id}}
|
||||
>
|
||||
<LinkTo @route="discovery.subcategories" @model={{this.slugPath}}>
|
||||
{{i18n "categories.view_all"}}
|
||||
{{icon "external-link-alt"}}
|
||||
</LinkTo>
|
||||
|
|
|
@ -46,7 +46,6 @@ export default ComboBoxComponent.extend({
|
|||
headerComponent: "category-drop/category-drop-header",
|
||||
parentCategory: false,
|
||||
allowUncategorized: "allowUncategorized",
|
||||
disableIfHasNoChildren: false,
|
||||
},
|
||||
|
||||
init() {
|
||||
|
@ -94,7 +93,6 @@ export default ComboBoxComponent.extend({
|
|||
|
||||
if (
|
||||
this.selectKit.options.subCategory &&
|
||||
this.filterType !== "categories" &&
|
||||
(this.value || !this.selectKit.options.noSubcategories)
|
||||
) {
|
||||
shortcuts.push({
|
||||
|
@ -236,20 +234,6 @@ export default ComboBoxComponent.extend({
|
|||
categoryId !== NO_CATEGORIES_ID,
|
||||
this.editingCategoryTab
|
||||
);
|
||||
} else if (
|
||||
this.site.lazy_load_categories &&
|
||||
this.filterType === "categories"
|
||||
) {
|
||||
// rendered on categories page
|
||||
if (categoryId === "all-categories" || categoryId === "no-categories") {
|
||||
route = this.selectKit.options.parentCategory
|
||||
? `${this.selectKit.options.parentCategory.url}/subcategories`
|
||||
: "/categories";
|
||||
} else if (categoryId) {
|
||||
route = `${Category.findById(categoryId).url}/subcategories`;
|
||||
} else {
|
||||
route = "/categories";
|
||||
}
|
||||
} else {
|
||||
route = getCategoryAndTagUrl(
|
||||
category,
|
||||
|
|
|
@ -90,13 +90,6 @@ export default class CategoryRow extends Component {
|
|||
return this.category.description_text;
|
||||
}
|
||||
|
||||
get isDisabled() {
|
||||
return (
|
||||
this.args.selectKit.options.disableIfHasNoChildren &&
|
||||
this.args.item.has_children === false
|
||||
);
|
||||
}
|
||||
|
||||
@cached
|
||||
get category() {
|
||||
if (isEmpty(this.rowValue)) {
|
||||
|
@ -194,9 +187,7 @@ export default class CategoryRow extends Component {
|
|||
handleClick(event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
if (!this.isDisabled) {
|
||||
this.args.selectKit.select(this.rowValue, this.args.item);
|
||||
}
|
||||
this.args.selectKit.select(this.rowValue, this.args.item);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -234,13 +225,10 @@ export default class CategoryRow extends Component {
|
|||
event.preventDefault();
|
||||
} else if (event.key === "Enter") {
|
||||
event.stopImmediatePropagation();
|
||||
|
||||
if (!this.isDisabled) {
|
||||
this.args.selectKit.select(
|
||||
this.args.selectKit.highlighted.id,
|
||||
this.args.selectKit.highlighted
|
||||
);
|
||||
}
|
||||
this.args.selectKit.select(
|
||||
this.args.selectKit.highlighted.id,
|
||||
this.args.selectKit.highlighted
|
||||
);
|
||||
event.preventDefault();
|
||||
} else if (event.key === "Escape") {
|
||||
this.args.selectKit.close(event);
|
||||
|
@ -283,7 +271,6 @@ export default class CategoryRow extends Component {
|
|||
(if this.isSelected "is-selected")
|
||||
(if this.isHighlighted "is-highlighted")
|
||||
(if this.isNone "is-none")
|
||||
(if this.isDisabled "is-disabled")
|
||||
}}
|
||||
role="menuitemradio"
|
||||
data-index={{@index}}
|
||||
|
|
|
@ -29,14 +29,6 @@
|
|||
font-weight: 700;
|
||||
}
|
||||
|
||||
&.is-disabled {
|
||||
cursor: not-allowed;
|
||||
|
||||
.badge-category__name {
|
||||
color: var(--primary-low-mid);
|
||||
}
|
||||
}
|
||||
|
||||
.category-desc {
|
||||
font-weight: normal;
|
||||
color: var(--primary-medium);
|
||||
|
|
Loading…
Reference in New Issue