mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 12:13:58 -06:00
FEATURE: bulk select on search results
This commit is contained in:
parent
83f76acbcb
commit
5865bd2abb
@ -0,0 +1,14 @@
|
||||
export default Ember.Component.extend({
|
||||
tagName: "span",
|
||||
selectionChanged: function(){
|
||||
const selected = this.get('selected');
|
||||
const list = this.get('selectedList');
|
||||
const id = this.get('selectedId');
|
||||
|
||||
if (selected) {
|
||||
list.addObject(id);
|
||||
} else {
|
||||
list.removeObject(id);
|
||||
}
|
||||
}.observes('selected')
|
||||
})
|
@ -6,6 +6,7 @@ export default Ember.Controller.extend({
|
||||
loading: Em.computed.not("model"),
|
||||
queryParams: ["q"],
|
||||
q: null,
|
||||
selected: [],
|
||||
|
||||
modelChanged: function() {
|
||||
if (this.get("searchTerm") !== this.get("q")) {
|
||||
@ -25,15 +26,33 @@ export default Ember.Controller.extend({
|
||||
this.set("controllers.application.showFooter", !this.get("loading"));
|
||||
}.observes("loading"),
|
||||
|
||||
actions: {
|
||||
search() {
|
||||
this.set("q", this.get("searchTerm"));
|
||||
this.set("model", null);
|
||||
canBulkSelect: Em.computed.alias('currentUser.staff'),
|
||||
|
||||
Discourse.ajax("/search", { data: { q: this.get("searchTerm") } }).then(results => {
|
||||
this.set("model", translateResults(results) || {});
|
||||
this.set("model.q", this.get("q"));
|
||||
});
|
||||
search(){
|
||||
this.set("q", this.get("searchTerm"));
|
||||
this.set("model", null);
|
||||
|
||||
Discourse.ajax("/search", { data: { q: this.get("searchTerm") } }).then(results => {
|
||||
this.set("model", translateResults(results) || {});
|
||||
this.set("model.q", this.get("q"));
|
||||
});
|
||||
},
|
||||
|
||||
actions: {
|
||||
|
||||
toggleBulkSelect() {
|
||||
this.toggleProperty('bulkSelectEnabled');
|
||||
this.get('selected').clear();
|
||||
},
|
||||
|
||||
refresh() {
|
||||
this.set('bulkSelectEnabled', false);
|
||||
this.get('selected').clear();
|
||||
this.search();
|
||||
},
|
||||
|
||||
search() {
|
||||
this.search();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -0,0 +1 @@
|
||||
{{input type="checkbox" checked=selected}}
|
@ -1,6 +1,12 @@
|
||||
<div class="search row">
|
||||
<div class="search row clearfix">
|
||||
{{input type="text" value=searchTerm class="input-xxlarge search no-blur" action="search"}}
|
||||
{{d-button action="search" icon="search" class="btn-primary"}}
|
||||
{{#if canBulkSelect}}
|
||||
{{#if model.posts}}
|
||||
{{d-button icon="list" class="bulk-select" title="topics.bulk.toggle" action="toggleBulkSelect"}}
|
||||
{{bulk-select-button selected=selected refreshTarget=controller}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
</div>
|
||||
|
||||
{{#conditional-loading-spinner condition=loading}}
|
||||
@ -14,6 +20,9 @@
|
||||
{{#each model.posts as |result|}}
|
||||
<div class='fps-result'>
|
||||
<div class='topic'>
|
||||
{{#if bulkSelectEnabled}}
|
||||
{{track-selected selectedList=selected selectedId=result.topic}}
|
||||
{{/if}}
|
||||
{{avatar result imageSize="tiny"}}
|
||||
<a class='search-link' href='{{unbound result.url}}'>
|
||||
{{topic-status topic=result.topic disableActions=true}}<span class='topic-title'>{{unbound result.topic.title}}</span>
|
||||
|
Loading…
Reference in New Issue
Block a user