Use an `itemController` for topic lists. This will make bulk operations
easier.
This commit is contained in:
parent
52ff68f74f
commit
4626519cdc
|
@ -8,10 +8,6 @@
|
|||
**/
|
||||
Discourse.DiscoveryTopicsController = Discourse.DiscoveryController.extend({
|
||||
actions: {
|
||||
// Star a topic
|
||||
toggleStar: function(topic) {
|
||||
topic.toggleStar();
|
||||
},
|
||||
|
||||
// Show newly inserted topics
|
||||
showInserted: function() {
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
/**
|
||||
Handles displaying of a topic as a list item
|
||||
|
||||
@class TopicListItemController
|
||||
@extends Discourse.ObjectController
|
||||
@namespace Discourse
|
||||
@module Discourse
|
||||
**/
|
||||
Discourse.TopicListItemController = Ember.ObjectController.extend({
|
||||
needs: ['discoveryTopics'],
|
||||
|
||||
canStar: Em.computed.alias('controllers.discoveryTopics.currentUser.id'),
|
||||
hideCategory: Em.computed.alias('controllers.discoveryTopics.hideCategory'),
|
||||
|
||||
actions: {
|
||||
toggleStar: function() {
|
||||
this.get('model').toggleStar();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -45,7 +45,7 @@
|
|||
</tbody>
|
||||
{{/if}}
|
||||
|
||||
{{collection contentBinding="topics" tagName="tbody" itemViewClass="Discourse.TopicListItemView"}}
|
||||
{{each topics itemController="topicListItem" itemViewClass="Discourse.TopicListItemView"}}
|
||||
</table>
|
||||
{{/if}}
|
||||
</div>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{{#if controller.currentUser.id}}
|
||||
{{#if canStar}}
|
||||
<td class='star'>
|
||||
<a {{bind-attr class=":star :fa :fa-star starred:starred"}} {{action toggleStar this}} href='#' {{bind-attr title="starTooltip"}}></a>
|
||||
<a {{bind-attr class=":star :fa :fa-star starred:starred"}} {{action toggleStar}} href='#' {{bind-attr title="starTooltip"}}></a>
|
||||
</td>
|
||||
{{/if}}
|
||||
|
||||
|
@ -30,10 +30,8 @@
|
|||
{{/if}}
|
||||
</td>
|
||||
|
||||
{{#unless controller.hideCategory}}
|
||||
<td class='category'>
|
||||
{{categoryLink category}}
|
||||
</td>
|
||||
{{#unless hideCategory}}
|
||||
<td class='category'>{{categoryLink category}}</td>
|
||||
{{/unless}}
|
||||
|
||||
<td class='posters'>
|
||||
|
|
Loading…
Reference in New Issue