mirror of
https://github.com/codeninjasllc/discourse.git
synced 2025-03-14 08:59:57 -04:00
FIX: don't show current topic when moving posts to another topic
This commit is contained in:
parent
00c9469fba
commit
eafeec51a5
3 changed files with 22 additions and 18 deletions
|
@ -2,7 +2,7 @@
|
|||
<p>{{{i18n 'topic.merge_topic.instructions' count=selectedPostsCount}}}</p>
|
||||
|
||||
<form>
|
||||
{{view "choose-topic" selectedTopicId=selectedTopicId}}
|
||||
{{view "choose-topic" currentTopicId=model.id selectedTopicId=selectedTopicId}}
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -5,14 +5,16 @@ export default Ember.View.extend({
|
|||
templateName: 'choose_topic',
|
||||
|
||||
topicTitleChanged: function() {
|
||||
this.set('loading', true);
|
||||
this.set('noResults', true);
|
||||
this.set('selectedTopicId', null);
|
||||
this.setProperties({
|
||||
loading: true,
|
||||
noResults: true,
|
||||
selectedTopicId: null,
|
||||
});
|
||||
this.search(this.get('topicTitle'));
|
||||
}.observes('topicTitle'),
|
||||
|
||||
topicsChanged: function() {
|
||||
var topics = this.get('topics');
|
||||
const topics = this.get('topics');
|
||||
if (topics) {
|
||||
this.set('noResults', topics.length === 0);
|
||||
}
|
||||
|
@ -20,14 +22,17 @@ export default Ember.View.extend({
|
|||
}.observes('topics'),
|
||||
|
||||
search: debounce(function(title) {
|
||||
var self = this;
|
||||
const self = this,
|
||||
currentTopicId = this.get("currentTopicId");
|
||||
|
||||
if (Em.isEmpty(title)) {
|
||||
self.setProperties({ topics: null, loading: false });
|
||||
return;
|
||||
}
|
||||
searchForTerm(title, {typeFilter: 'topic', searchForId: true}).then(function (results) {
|
||||
|
||||
searchForTerm(title, { typeFilter: 'topic', searchForId: true }).then(function (results) {
|
||||
if (results && results.posts && results.posts.length > 0) {
|
||||
self.set('topics', results.posts.mapBy('topic'));
|
||||
self.set('topics', results.posts.mapBy('topic').filter(t => t.get("id") !== currentTopicId));
|
||||
} else {
|
||||
self.setProperties({ topics: null, loading: false });
|
||||
}
|
||||
|
@ -36,7 +41,7 @@ export default Ember.View.extend({
|
|||
|
||||
actions: {
|
||||
chooseTopic: function (topic) {
|
||||
var topicId = Em.get(topic, 'id');
|
||||
const topicId = Em.get(topic, 'id');
|
||||
this.set('selectedTopicId', topicId);
|
||||
|
||||
Em.run.next(function () {
|
||||
|
|
|
@ -12,13 +12,12 @@ class SearchController < ApplicationController
|
|||
search = Search.new(params[:q], type_filter: 'topic', guardian: guardian, include_blurbs: true, blurb_length: 300)
|
||||
result = search.execute
|
||||
|
||||
serializer = serialize_data(result, GroupedSearchResultSerializer, :result => result)
|
||||
serializer = serialize_data(result, GroupedSearchResultSerializer, result: result)
|
||||
|
||||
respond_to do |format|
|
||||
format.html do
|
||||
store_preloaded("search", MultiJson.dump(serializer))
|
||||
end
|
||||
|
||||
format.json do
|
||||
render_json_dump(serializer)
|
||||
end
|
||||
|
@ -29,14 +28,14 @@ class SearchController < ApplicationController
|
|||
def query
|
||||
params.require(:term)
|
||||
|
||||
search_args = {guardian: guardian}
|
||||
search_args[:type_filter] = params[:type_filter] if params[:type_filter].present?
|
||||
if params[:include_blurbs].present?
|
||||
search_args[:include_blurbs] = params[:include_blurbs] == "true"
|
||||
end
|
||||
search_args[:search_for_id] = true if params[:search_for_id].present?
|
||||
search_args = { guardian: guardian }
|
||||
|
||||
search_args[:type_filter] = params[:type_filter] if params[:type_filter].present?
|
||||
search_args[:include_blurbs] = params[:include_blurbs] == "true" if params[:include_blurbs].present?
|
||||
search_args[:search_for_id] = true if params[:search_for_id].present?
|
||||
|
||||
search_context = params[:search_context]
|
||||
|
||||
if search_context.present?
|
||||
raise Discourse::InvalidParameters.new(:search_context) unless SearchController.valid_context_types.include?(search_context[:type])
|
||||
raise Discourse::InvalidParameters.new(:search_context) if search_context[:id].blank?
|
||||
|
@ -60,7 +59,7 @@ class SearchController < ApplicationController
|
|||
|
||||
search = Search.new(params[:term], search_args.symbolize_keys)
|
||||
result = search.execute
|
||||
render_serialized(result, GroupedSearchResultSerializer, :result => result)
|
||||
render_serialized(result, GroupedSearchResultSerializer, result: result)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue