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

View File

@ -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();

View File

@ -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>

View File

@ -49,6 +49,20 @@
}
}
.fps-select {
margin-top: -15px;
margin-bottom: 15px;
a:hover {
color: $secondary;
background-color: $tertiary;
}
a {
margin-right: 15px;
font-size: 12px;
padding: 2px 5px;
}
}
.search.row {
margin-bottom: 15px;
input {

View File

@ -942,6 +942,8 @@ en:
image_link: "link your image will point to"
search:
select_all: "Select All"
clear_all: "Clear All"
title: "search topics, posts, users, or categories"
no_results: "No results found."
no_more_results: "No more results found."