DEV: Use new filterType property where possible
This commit is contained in:
parent
585a229d3f
commit
5762498391
|
@ -28,17 +28,8 @@ export default Component.extend(FilterModeMixin, {
|
||||||
@discourseComputed("category.can_edit")
|
@discourseComputed("category.can_edit")
|
||||||
showCategoryEdit: canEdit => canEdit,
|
showCategoryEdit: canEdit => canEdit,
|
||||||
|
|
||||||
@discourseComputed("filterMode", "category", "noSubcategories")
|
@discourseComputed("filterType", "category", "noSubcategories")
|
||||||
navItems(filterMode, category, noSubcategories) {
|
navItems(filterType, category, noSubcategories) {
|
||||||
const filterModeParts = filterMode.split("/");
|
|
||||||
if (
|
|
||||||
filterModeParts.length >= 2 &&
|
|
||||||
filterModeParts[filterModeParts.length - 2] === "top"
|
|
||||||
) {
|
|
||||||
filterModeParts.pop();
|
|
||||||
filterMode = filterModeParts.join("/");
|
|
||||||
}
|
|
||||||
|
|
||||||
let params;
|
let params;
|
||||||
const currentRouteQueryParams = this.get("router.currentRoute.queryParams");
|
const currentRouteQueryParams = this.get("router.currentRoute.queryParams");
|
||||||
if (this.persistedQueryParams && currentRouteQueryParams) {
|
if (this.persistedQueryParams && currentRouteQueryParams) {
|
||||||
|
@ -54,7 +45,7 @@ export default Component.extend(FilterModeMixin, {
|
||||||
}
|
}
|
||||||
|
|
||||||
return NavItem.buildList(category, {
|
return NavItem.buildList(category, {
|
||||||
filterMode,
|
filterType,
|
||||||
noSubcategories,
|
noSubcategories,
|
||||||
persistedQueryParams: params
|
persistedQueryParams: params
|
||||||
});
|
});
|
||||||
|
|
|
@ -18,21 +18,11 @@ export default Component.extend(FilterModeMixin, {
|
||||||
this.set("connectors", renderedConnectorsFor("extra-nav-item", null, this));
|
this.set("connectors", renderedConnectorsFor("extra-nav-item", null, this));
|
||||||
},
|
},
|
||||||
|
|
||||||
@discourseComputed("filterMode", "navItems")
|
@discourseComputed("filterType", "navItems")
|
||||||
selectedNavItem(filterMode, navItems) {
|
selectedNavItem(filterType, navItems) {
|
||||||
const filterModeParts = filterMode.split("/");
|
|
||||||
if (
|
|
||||||
filterModeParts.length >= 2 &&
|
|
||||||
filterModeParts[filterModeParts.length - 2] === "top"
|
|
||||||
) {
|
|
||||||
filterModeParts.pop();
|
|
||||||
filterMode = filterModeParts.join("/");
|
|
||||||
}
|
|
||||||
|
|
||||||
let item = navItems.find(i => i.active === true);
|
let item = navItems.find(i => i.active === true);
|
||||||
|
|
||||||
item =
|
item = item || navItems.find(i => i.get("filterType") === filterType);
|
||||||
item || navItems.find(i => i.get("filterMode").indexOf(filterMode) === 0);
|
|
||||||
|
|
||||||
if (!item) {
|
if (!item) {
|
||||||
let connectors = this.connectors;
|
let connectors = this.connectors;
|
||||||
|
@ -45,7 +35,7 @@ export default Component.extend(FilterModeMixin, {
|
||||||
typeof (c.connectorClass.displayName === "function")
|
typeof (c.connectorClass.displayName === "function")
|
||||||
) {
|
) {
|
||||||
let path = c.connectorClass.path(category);
|
let path = c.connectorClass.path(category);
|
||||||
if (path.indexOf(filterMode) > 0) {
|
if (path.indexOf(filterType) > 0) {
|
||||||
item = {
|
item = {
|
||||||
displayName: c.connectorClass.displayName()
|
displayName: c.connectorClass.displayName()
|
||||||
};
|
};
|
||||||
|
|
|
@ -17,15 +17,12 @@ export default Component.extend(
|
||||||
hidden: false,
|
hidden: false,
|
||||||
rerenderTriggers: ["content.count"],
|
rerenderTriggers: ["content.count"],
|
||||||
|
|
||||||
@discourseComputed("content.filterMode", "filterMode", "content.active")
|
@discourseComputed("content.filterType", "filterType", "content.active")
|
||||||
active(contentFilterMode, filterMode, active) {
|
active(contentFilterType, filterType, active) {
|
||||||
if (active !== undefined) {
|
if (active !== undefined) {
|
||||||
return active;
|
return active;
|
||||||
}
|
}
|
||||||
return (
|
return contentFilterType === filterType;
|
||||||
contentFilterMode === filterMode ||
|
|
||||||
filterMode.indexOf(contentFilterMode) === 0
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
buildBuffer(buffer) {
|
buildBuffer(buffer) {
|
||||||
|
|
|
@ -65,11 +65,11 @@ export default Controller.extend(BulkTopicSelection, FilterModeMixin, {
|
||||||
"q"
|
"q"
|
||||||
],
|
],
|
||||||
|
|
||||||
@discourseComputed("category", "tag.id", "filterMode", "noSubcategories")
|
@discourseComputed("category", "tag.id", "filterType", "noSubcategories")
|
||||||
navItems(category, tagId, filterMode, noSubcategories) {
|
navItems(category, tagId, filterType, noSubcategories) {
|
||||||
return NavItem.buildList(category, {
|
return NavItem.buildList(category, {
|
||||||
tagId,
|
tagId,
|
||||||
filterMode,
|
filterType,
|
||||||
noSubcategories
|
noSubcategories
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue