Skip to content

A platform for community discussion. Free, open, simple.

FIX: show none/all on cat/tag drop only when needed

Joffrey JAFFEUXa8079ab6793c
diff --git a/app/assets/javascripts/select-kit/components/category-drop.js.es6 b/app/assets/javascripts/select-kit/components/category-drop.js.es6
index cbfaa329611..f9c1f9a6f83 100644
--- a/app/assets/javascripts/select-kit/components/category-drop.js.es6
+++ b/app/assets/javascripts/select-kit/components/category-drop.js.es6
@@ -50,13 +50,19 @@ export default ComboBoxComponent.extend({
collectionHeader(allCategoriesUrl, allCategoriesLabel, noCategoriesUrl, noCategoriesLabel) {
let shortcuts = "";
- shortcuts += `
- <a href="${allCategoriesUrl}" class="category-filter">
- ${allCategoriesLabel}
- </a>
- `;
+ const currentRoute = Ember.getOwner(this)
+ .lookup("controller:application")
+ .get("currentRouteName");
- if (this.get("subCategory")) {
+ if (currentRoute !== "discovery.parentCategory") {
+ shortcuts += `
+ <a href="${allCategoriesUrl}" class="category-filter">
+ ${allCategoriesLabel}
+ </a>
+ `;
+ }
+
+ if (this.get("subCategory") && currentRoute !== "discovery.categoryNone") {
shortcuts += `
<a href="${noCategoriesUrl}" class="category-filter">
${noCategoriesLabel}
diff --git a/app/assets/javascripts/select-kit/components/tag-drop.js.es6 b/app/assets/javascripts/select-kit/components/tag-drop.js.es6
index 4e3768753cd..ba23945bcc7 100644
--- a/app/assets/javascripts/select-kit/components/tag-drop.js.es6
+++ b/app/assets/javascripts/select-kit/components/tag-drop.js.es6
@@ -77,14 +77,29 @@ export default ComboBoxComponent.extend({
@computed("allTagsUrl", "allTagsLabel", "noTagsUrl", "noTagsLabel")
collectionHeader(allTagsUrl, allTagsLabel, noTagsUrl, noTagsLabel) {
- return `
- <a href="${allTagsUrl}" class="tag-filter">
- ${allTagsLabel}
- </a>
- <a href="${noTagsUrl}" class="tag-filter">
- ${noTagsLabel}
- </a>
- `;
+ let content = "";
+
+ const currentRoute = Ember.getOwner(this)
+ .lookup("controller:application")
+ .get("currentRouteName");
+
+ if (this.get("tagId") !== "none") {
+ content += `
+ <a href="${noTagsUrl}" class="tag-filter">
+ ${noTagsLabel}
+ </a>
+ `;
+ }
+
+ if (currentRoute === "tags.showCategory") {
+ content += `
+ <a href="${allTagsUrl}" class="tag-filter">
+ ${allTagsLabel}
+ </a>
+ `;
+ }
+
+ return content;
},
@computed("tag")