mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 06:49:14 +08:00
UX: Update suggested topics to include topic status + category
This commit is contained in:
parent
77595bcaa9
commit
4e898c604e
12
app/assets/javascripts/discourse/adapters/topic.js.es6
Normal file
12
app/assets/javascripts/discourse/adapters/topic.js.es6
Normal 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);
|
||||
}
|
||||
}
|
||||
});
|
|
@ -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() {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user