From 71892cc5f4fa9d39ee492b2d2707bc8cfed44708 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 8 Sep 2015 16:11:21 +1000 Subject: [PATCH] FEATURE: select all / deselect all on search page --- .../controllers/full-page-search.js.es6 | 16 +++++++++++++++- .../discourse/templates/full-page-search.hbs | 9 +++++++++ app/assets/stylesheets/common/base/search.scss | 14 ++++++++++++++ config/locales/client.en.yml | 2 ++ 4 files changed, 40 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/controllers/full-page-search.js.es6 b/app/assets/javascripts/discourse/controllers/full-page-search.js.es6 index 8efc5c6adfe..3641329f833 100644 --- a/app/assets/javascripts/discourse/controllers/full-page-search.js.es6 +++ b/app/assets/javascripts/discourse/controllers/full-page-search.js.es6 @@ -79,12 +79,26 @@ export default Ember.Controller.extend({ Discourse.ajax("/search", { data: args }).then(results => { this.set("model", translateResults(results) || {}); - // this.set("model.q", this.get("q")); }); }, actions: { + selectAll() { + this.get('selected').addObjects(this.get('model.posts').map(r => r.topic)); + // Doing this the proper way is a HUGE pain, + // we can hack this to work by observing each on the array + // in the component, however, when we select ANYTHING, we would force + // 50 traversals of the list + // This hack is cheap and easy + $('.fps-result input[type=checkbox]').prop('checked', true); + }, + + clearAll() { + this.get('selected').clear() + $('.fps-result input[type=checkbox]').prop('checked', false); + }, + toggleBulkSelect() { this.toggleProperty('bulkSelectEnabled'); this.get('selected').clear(); diff --git a/app/assets/javascripts/discourse/templates/full-page-search.hbs b/app/assets/javascripts/discourse/templates/full-page-search.hbs index f0278b64072..db60849ff9a 100644 --- a/app/assets/javascripts/discourse/templates/full-page-search.hbs +++ b/app/assets/javascripts/discourse/templates/full-page-search.hbs @@ -9,6 +9,15 @@ {{/if}} +{{#if model.posts}} + {{#if bulkSelectEnabled}} +
+ {{i18n "search.select_all"}} + {{i18n "search.clear_all"}} +
+ {{/if}} +{{/if}} + {{#if context}}