UX: Update suggested topics to include topic status + category

This commit is contained in:
Robin Ward 2015-06-18 15:52:51 -04:00
parent 77595bcaa9
commit 4e898c604e
5 changed files with 22 additions and 17 deletions

View File

@ -0,0 +1,12 @@
import RestAdapter from 'discourse/adapters/rest';
export default RestAdapter.extend({
find(store, type, findArgs) {
if (findArgs.similar) {
return Discourse.ajax("/topics/similar_to", { data: findArgs.similar });
} else {
return this._super(store, type, findArgs);
}
}
});

View File

@ -332,9 +332,9 @@ export default Ember.ObjectController.extend(Presence, {
this.set('similarTopicsMessage', message);
}
Discourse.Topic.findSimilarTo(title, body).then(function (newTopics) {
this.store.find('topic', {similar: {title, raw: body}}).then(function(newTopics) {
similarTopics.clear();
similarTopics.pushObjects(newTopics);
similarTopics.pushObjects(newTopics.get('content'));
if (similarTopics.get('length') > 0) {
message.set('similarTopics', similarTopics);
@ -343,7 +343,6 @@ export default Ember.ObjectController.extend(Presence, {
messageController.send("hideMessage", message);
}
});
},
saveDraft() {

View File

@ -434,16 +434,6 @@ Topic.reopenClass({
return result;
},
findSimilarTo(title, body) {
return Discourse.ajax("/topics/similar_to", { data: {title: title, raw: body} }).then(function (results) {
if (Array.isArray(results)) {
return results.map(function(topic) { return Topic.create(topic); });
} else {
return Ember.A();
}
});
},
// Load a topic, but accepts a set of filters
find(topicId, opts) {
let url = Discourse.getURL("/t/") + topicId;

View File

@ -1,8 +1,12 @@
<a href='#' {{action "closeMessage" this}} class='close'>{{fa-icon "times-circle"}}</a>
<a href {{action "closeMessage" this}} class='close'>{{fa-icon "times-circle"}}</a>
<h3>{{i18n 'composer.similar_topics'}}</h3>
<ul class='topics'>
{{#each t in similarTopics}}
<li>{{topic-link t}} <span class='badge badge-notification posts-count'>{{t.posts_count}}</span></li>
{{#each similarTopics as |t|}}
<li>
{{topic-status topic=t}}
{{topic-link t}}
{{category-link t.category}}
</li>
{{/each}}
</ul>

View File

@ -155,7 +155,7 @@ class TopicsController < ApplicationController
return render json: [] unless Topic.count_exceeds_minimum?
topics = Topic.similar_to(title, raw, current_user).to_a
render_serialized(topics, BasicTopicSerializer)
render_serialized(topics, TopicListItemSerializer, root: :topics)
end
def feature_stats