FEATURE: select all / deselect all on search page

This commit is contained in:
Sam
2015-09-08 16:11:21 +10:00
parent 0c5189fa2a
commit 71892cc5f4
4 changed files with 40 additions and 1 deletions
@@ -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();
@@ -9,6 +9,15 @@
{{/if}}
</div>
{{#if model.posts}}
{{#if bulkSelectEnabled}}
<div class='fps-select'>
<a href {{action "selectAll"}}>{{i18n "search.select_all"}}</a>
<a href {{action "clearAll"}}>{{i18n "search.clear_all"}}</a>
</div>
{{/if}}
{{/if}}
{{#if context}}
<div class='fps-search-context'>
<label>