DEV: Use new filterType property where possible

This commit is contained in:
Daniel Waterworth 2019-11-21 11:01:28 +00:00
parent 585a229d3f
commit 5762498391
4 changed files with 13 additions and 35 deletions

View File

@ -28,17 +28,8 @@ export default Component.extend(FilterModeMixin, {
@discourseComputed("category.can_edit")
showCategoryEdit: canEdit => canEdit,
@discourseComputed("filterMode", "category", "noSubcategories")
navItems(filterMode, category, noSubcategories) {
const filterModeParts = filterMode.split("/");
if (
filterModeParts.length >= 2 &&
filterModeParts[filterModeParts.length - 2] === "top"
) {
filterModeParts.pop();
filterMode = filterModeParts.join("/");
}
@discourseComputed("filterType", "category", "noSubcategories")
navItems(filterType, category, noSubcategories) {
let params;
const currentRouteQueryParams = this.get("router.currentRoute.queryParams");
if (this.persistedQueryParams && currentRouteQueryParams) {
@ -54,7 +45,7 @@ export default Component.extend(FilterModeMixin, {
}
return NavItem.buildList(category, {
filterMode,
filterType,
noSubcategories,
persistedQueryParams: params
});

View File

@ -18,21 +18,11 @@ export default Component.extend(FilterModeMixin, {
this.set("connectors", renderedConnectorsFor("extra-nav-item", null, this));
},
@discourseComputed("filterMode", "navItems")
selectedNavItem(filterMode, navItems) {
const filterModeParts = filterMode.split("/");
if (
filterModeParts.length >= 2 &&
filterModeParts[filterModeParts.length - 2] === "top"
) {
filterModeParts.pop();
filterMode = filterModeParts.join("/");
}
@discourseComputed("filterType", "navItems")
selectedNavItem(filterType, navItems) {
let item = navItems.find(i => i.active === true);
item =
item || navItems.find(i => i.get("filterMode").indexOf(filterMode) === 0);
item = item || navItems.find(i => i.get("filterType") === filterType);
if (!item) {
let connectors = this.connectors;
@ -45,7 +35,7 @@ export default Component.extend(FilterModeMixin, {
typeof (c.connectorClass.displayName === "function")
) {
let path = c.connectorClass.path(category);
if (path.indexOf(filterMode) > 0) {
if (path.indexOf(filterType) > 0) {
item = {
displayName: c.connectorClass.displayName()
};

View File

@ -17,15 +17,12 @@ export default Component.extend(
hidden: false,
rerenderTriggers: ["content.count"],
@discourseComputed("content.filterMode", "filterMode", "content.active")
active(contentFilterMode, filterMode, active) {
@discourseComputed("content.filterType", "filterType", "content.active")
active(contentFilterType, filterType, active) {
if (active !== undefined) {
return active;
}
return (
contentFilterMode === filterMode ||
filterMode.indexOf(contentFilterMode) === 0
);
return contentFilterType === filterType;
},
buildBuffer(buffer) {

View File

@ -65,11 +65,11 @@ export default Controller.extend(BulkTopicSelection, FilterModeMixin, {
"q"
],
@discourseComputed("category", "tag.id", "filterMode", "noSubcategories")
navItems(category, tagId, filterMode, noSubcategories) {
@discourseComputed("category", "tag.id", "filterType", "noSubcategories")
navItems(category, tagId, filterType, noSubcategories) {
return NavItem.buildList(category, {
tagId,
filterMode,
filterType,
noSubcategories
});
},