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}}
|
@tagId={{this.tag.id}}
|
||||||
@editingCategory={{this.editingCategory}}
|
@editingCategory={{this.editingCategory}}
|
||||||
@editingCategoryTab={{this.editingCategoryTab}}
|
@editingCategoryTab={{this.editingCategoryTab}}
|
||||||
@filterType={{this.filterType}}
|
|
||||||
@options={{hash
|
@options={{hash
|
||||||
parentCategory=breadcrumb.parentCategory
|
parentCategory=breadcrumb.parentCategory
|
||||||
subCategory=breadcrumb.isSubcategory
|
subCategory=breadcrumb.isSubcategory
|
||||||
noSubcategories=breadcrumb.noSubcategories
|
noSubcategories=breadcrumb.noSubcategories
|
||||||
autoFilterable=true
|
autoFilterable=true
|
||||||
disableIfHasNoChildren=(eq this.filterType "categories")
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
@noSubcategories={{this.noSubcategories}}
|
@noSubcategories={{this.noSubcategories}}
|
||||||
@tag={{this.tag}}
|
@tag={{this.tag}}
|
||||||
@additionalTags={{this.additionalTags}}
|
@additionalTags={{this.additionalTags}}
|
||||||
@filterType={{this.filterType}}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{{#unless this.additionalTags}}
|
{{#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;
|
return this.args.selectKit.totalCount - currentCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get slugPath() {
|
||||||
|
return this.args.selectKit.options.parentCategory.path.substring(
|
||||||
|
"/c/".length
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
{{#if this.moreCount}}
|
{{#if this.moreCount}}
|
||||||
<div class="category-drop-footer">
|
<div class="category-drop-footer">
|
||||||
|
@ -35,10 +41,7 @@ export default class CategoryDropMoreCollection extends Component {
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
{{#if @selectKit.options.parentCategory}}
|
{{#if @selectKit.options.parentCategory}}
|
||||||
<LinkTo
|
<LinkTo @route="discovery.subcategories" @model={{this.slugPath}}>
|
||||||
@route="discovery.subcategories"
|
|
||||||
@model={{@selectKit.options.parentCategory.id}}
|
|
||||||
>
|
|
||||||
{{i18n "categories.view_all"}}
|
{{i18n "categories.view_all"}}
|
||||||
{{icon "external-link-alt"}}
|
{{icon "external-link-alt"}}
|
||||||
</LinkTo>
|
</LinkTo>
|
||||||
|
|
|
@ -46,7 +46,6 @@ export default ComboBoxComponent.extend({
|
||||||
headerComponent: "category-drop/category-drop-header",
|
headerComponent: "category-drop/category-drop-header",
|
||||||
parentCategory: false,
|
parentCategory: false,
|
||||||
allowUncategorized: "allowUncategorized",
|
allowUncategorized: "allowUncategorized",
|
||||||
disableIfHasNoChildren: false,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
|
@ -94,7 +93,6 @@ export default ComboBoxComponent.extend({
|
||||||
|
|
||||||
if (
|
if (
|
||||||
this.selectKit.options.subCategory &&
|
this.selectKit.options.subCategory &&
|
||||||
this.filterType !== "categories" &&
|
|
||||||
(this.value || !this.selectKit.options.noSubcategories)
|
(this.value || !this.selectKit.options.noSubcategories)
|
||||||
) {
|
) {
|
||||||
shortcuts.push({
|
shortcuts.push({
|
||||||
|
@ -236,20 +234,6 @@ export default ComboBoxComponent.extend({
|
||||||
categoryId !== NO_CATEGORIES_ID,
|
categoryId !== NO_CATEGORIES_ID,
|
||||||
this.editingCategoryTab
|
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 {
|
} else {
|
||||||
route = getCategoryAndTagUrl(
|
route = getCategoryAndTagUrl(
|
||||||
category,
|
category,
|
||||||
|
|
|
@ -90,13 +90,6 @@ export default class CategoryRow extends Component {
|
||||||
return this.category.description_text;
|
return this.category.description_text;
|
||||||
}
|
}
|
||||||
|
|
||||||
get isDisabled() {
|
|
||||||
return (
|
|
||||||
this.args.selectKit.options.disableIfHasNoChildren &&
|
|
||||||
this.args.item.has_children === false
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@cached
|
@cached
|
||||||
get category() {
|
get category() {
|
||||||
if (isEmpty(this.rowValue)) {
|
if (isEmpty(this.rowValue)) {
|
||||||
|
@ -194,9 +187,7 @@ export default class CategoryRow extends Component {
|
||||||
handleClick(event) {
|
handleClick(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,13 +225,10 @@ export default class CategoryRow extends Component {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
} else if (event.key === "Enter") {
|
} else if (event.key === "Enter") {
|
||||||
event.stopImmediatePropagation();
|
event.stopImmediatePropagation();
|
||||||
|
this.args.selectKit.select(
|
||||||
if (!this.isDisabled) {
|
this.args.selectKit.highlighted.id,
|
||||||
this.args.selectKit.select(
|
this.args.selectKit.highlighted
|
||||||
this.args.selectKit.highlighted.id,
|
);
|
||||||
this.args.selectKit.highlighted
|
|
||||||
);
|
|
||||||
}
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
} else if (event.key === "Escape") {
|
} else if (event.key === "Escape") {
|
||||||
this.args.selectKit.close(event);
|
this.args.selectKit.close(event);
|
||||||
|
@ -283,7 +271,6 @@ export default class CategoryRow extends Component {
|
||||||
(if this.isSelected "is-selected")
|
(if this.isSelected "is-selected")
|
||||||
(if this.isHighlighted "is-highlighted")
|
(if this.isHighlighted "is-highlighted")
|
||||||
(if this.isNone "is-none")
|
(if this.isNone "is-none")
|
||||||
(if this.isDisabled "is-disabled")
|
|
||||||
}}
|
}}
|
||||||
role="menuitemradio"
|
role="menuitemradio"
|
||||||
data-index={{@index}}
|
data-index={{@index}}
|
||||||
|
|
|
@ -29,14 +29,6 @@
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.is-disabled {
|
|
||||||
cursor: not-allowed;
|
|
||||||
|
|
||||||
.badge-category__name {
|
|
||||||
color: var(--primary-low-mid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.category-desc {
|
.category-desc {
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
color: var(--primary-medium);
|
color: var(--primary-medium);
|
||||||
|
|
Loading…
Reference in New Issue