mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -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"),
|
loading: Em.computed.not("model"),
|
||||||
queryParams: ["q"],
|
queryParams: ["q"],
|
||||||
q: null,
|
q: null,
|
||||||
|
selected: [],
|
||||||
|
|
||||||
modelChanged: function() {
|
modelChanged: function() {
|
||||||
if (this.get("searchTerm") !== this.get("q")) {
|
if (this.get("searchTerm") !== this.get("q")) {
|
||||||
@ -25,15 +26,33 @@ export default Ember.Controller.extend({
|
|||||||
this.set("controllers.application.showFooter", !this.get("loading"));
|
this.set("controllers.application.showFooter", !this.get("loading"));
|
||||||
}.observes("loading"),
|
}.observes("loading"),
|
||||||
|
|
||||||
actions: {
|
canBulkSelect: Em.computed.alias('currentUser.staff'),
|
||||||
search() {
|
|
||||||
this.set("q", this.get("searchTerm"));
|
|
||||||
this.set("model", null);
|
|
||||||
|
|
||||||
Discourse.ajax("/search", { data: { q: this.get("searchTerm") } }).then(results => {
|
search(){
|
||||||
this.set("model", translateResults(results) || {});
|
this.set("q", this.get("searchTerm"));
|
||||||
this.set("model.q", this.get("q"));
|
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"}}
|
{{input type="text" value=searchTerm class="input-xxlarge search no-blur" action="search"}}
|
||||||
{{d-button action="search" icon="search" class="btn-primary"}}
|
{{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>
|
</div>
|
||||||
|
|
||||||
{{#conditional-loading-spinner condition=loading}}
|
{{#conditional-loading-spinner condition=loading}}
|
||||||
@ -14,6 +20,9 @@
|
|||||||
{{#each model.posts as |result|}}
|
{{#each model.posts as |result|}}
|
||||||
<div class='fps-result'>
|
<div class='fps-result'>
|
||||||
<div class='topic'>
|
<div class='topic'>
|
||||||
|
{{#if bulkSelectEnabled}}
|
||||||
|
{{track-selected selectedList=selected selectedId=result.topic}}
|
||||||
|
{{/if}}
|
||||||
{{avatar result imageSize="tiny"}}
|
{{avatar result imageSize="tiny"}}
|
||||||
<a class='search-link' href='{{unbound result.url}}'>
|
<a class='search-link' href='{{unbound result.url}}'>
|
||||||
{{topic-status topic=result.topic disableActions=true}}<span class='topic-title'>{{unbound result.topic.title}}</span>
|
{{topic-status topic=result.topic disableActions=true}}<span class='topic-title'>{{unbound result.topic.title}}</span>
|
||||||
|
Loading…
Reference in New Issue
Block a user