From a8ff4a8a783f4fe939b46adcff6fbce576048f4e Mon Sep 17 00:00:00 2001 From: Vinoth Kannan Date: Thu, 10 Jan 2019 21:19:53 +0530 Subject: [PATCH] UX: search all categories even if category-chooser is scoped to particular category --- .../select-kit/components/category-chooser.js.es6 | 11 ++++++++++- .../components/category-chooser-test.js.es6 | 4 ++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/select-kit/components/category-chooser.js.es6 b/app/assets/javascripts/select-kit/components/category-chooser.js.es6 index 5cc57a7f6cc..87dcf59afe5 100644 --- a/app/assets/javascripts/select-kit/components/category-chooser.js.es6 +++ b/app/assets/javascripts/select-kit/components/category-chooser.js.es6 @@ -30,6 +30,12 @@ export default ComboBoxComponent.extend({ return computedContent; } + if (this.get("scopedCategoryId")) { + computedContent = this.categoriesByScope().map(c => + this.computeContentItem(c) + ); + } + const _matchFunction = (f, text) => { return this._normalize(text).indexOf(f) > -1; }; @@ -111,11 +117,14 @@ export default ComboBoxComponent.extend({ }, computeContent() { + return this.categoriesByScope(this.get("scopedCategoryId")); + }, + + categoriesByScope(scopedCategoryId = null) { const categories = Discourse.SiteSettings.fixed_category_positions_on_create ? Category.list() : Category.listByActivity(); - let scopedCategoryId = this.get("scopedCategoryId"); if (scopedCategoryId) { const scopedCat = Category.findById(scopedCategoryId); scopedCategoryId = diff --git a/test/javascripts/components/category-chooser-test.js.es6 b/test/javascripts/components/category-chooser-test.js.es6 index 271b00aa695..ba02fb51a04 100644 --- a/test/javascripts/components/category-chooser-test.js.es6 +++ b/test/javascripts/components/category-chooser-test.js.es6 @@ -71,6 +71,10 @@ componentTest("with scopedCategoryId", { 26 ); assert.equal(this.get("subject").rows().length, 2); + + await this.get("subject").fillInFilter("dev"); + + assert.equal(this.get("subject").rows().length, 3); } });