Some topic list re-organization.

This commit is contained in:
Robin Ward 2013-11-11 15:01:42 -05:00
parent 2f8866add5
commit e5fd2946e0
14 changed files with 67 additions and 61 deletions

View file

@ -0,0 +1,9 @@
/**
This view is used for rendering a basic list of topics.
@class BasicTopicListView
@extends Discourse.View
@namespace Discourse
@module Discourse
**/
Discourse.BasicTopicListComponent = Ember.Component.extend({});

View file

@ -88,7 +88,7 @@ Discourse.ListTopicsController = Discourse.ObjectController.extend({
loadMore: function() {
var topicList = this.get('model');
return topicList.loadMoreTopics().then(function(moreUrl) {
return topicList.loadMore().then(function(moreUrl) {
if (!Em.isEmpty(moreUrl)) {
Discourse.URL.replaceState(Discourse.getURL("/") + topicList.get('filter') + "/more");
}

View file

@ -0,0 +1,17 @@
/**
Lists of topics on a user's page.
@class UserTopicsListController
@extends Discourse.ObjectController
@namespace Discourse
@module Discourse
**/
Discourse.UserTopicsListController = Discourse.ObjectController.extend({
actions: {
loadMore: function() {
this.get('model').loadMore();
}
}
});

View file

@ -8,25 +8,21 @@
@namespace Discourse
@module Discourse
**/
Discourse.LoadMore = Em.Mixin.create(Discourse.Scrolling, {
Discourse.LoadMore = Em.Mixin.create(Ember.ViewTargetActionSupport, Discourse.Scrolling, {
scrolled: function(e) {
var eyeline = this.get('eyeline');
if (eyeline) { eyeline.update(); }
},
loadMore: function() {
console.error('loadMore() not defined');
},
didInsertElement: function() {
this._super();
var eyeline = new Discourse.Eyeline(this.get('eyelineSelector'));
this.set('eyeline', eyeline);
var paginatedTopicListView = this;
var self = this;
eyeline.on('sawBottom', function() {
paginatedTopicListView.loadMore();
self.send('loadMore');
});
this.bindScrolling();
},

View file

@ -22,7 +22,7 @@ Discourse.TopicList = Discourse.Model.extend({
});
},
loadMoreTopics: function() {
loadMore: function() {
if (this.get('loadingMore')) { return Ember.RSVP.reject(); }

View file

@ -1,12 +1,11 @@
Discourse.UserTopicListRoute = Discourse.Route.extend({
renderTemplate: function() {
this.render('paginated_topic_list', {into: 'user', outlet: 'userOutlet'});
this.render('user_topics_list', {into: 'user', outlet: 'userOutlet'});
},
setupController: function(controller, model) {
this.controllerFor('user_activity').set('userActionType', this.get('userActionType'));
controller.set('model', model);
this.controllerFor('user_topics_list').set('model', model);
this.controllerFor('user').set('indexStream', false);
}
});
@ -21,7 +20,6 @@ function createPMRoute(viewName, path, type) {
setupController: function(controller, model) {
this._super.apply(this, arguments);
controller.set('hideCategories', true);
this.controllerFor('user').setProperties({
pmView: viewName,
indexStream: false

View file

@ -1,10 +1,10 @@
{{#if view.topics}}
{{#if topics}}
<table id="topic-list">
<tr>
<th>
{{i18n topic.title}}
</th>
{{#unless controller.hideCategories}}
{{#unless hideCategories}}
<th>{{i18n category_title}}</th>
{{/unless}}
<th class='num posts'>{{i18n posts}}</th>
@ -13,7 +13,7 @@
<th class='num activity' colspan='2'>{{i18n activity}}</th>
</tr>
{{#groupedEach topic in view.topics}}
{{#groupedEach topic in topics}}
<tr {{bindAttr class="archived"}}>
<td class='main-link'>
{{topicStatus topic=topic}}
@ -28,7 +28,7 @@
<a href="{{unbound topic.lastUnreadUrl}}" class='badge new-posts badge-notification' title='{{i18n topic.new}}'><i class='icon icon-asterisk'></i></a>
{{/if}}
</td>
{{#unless controller.hideCategories}}
{{#unless view.hideCategories}}
<td class='category'>
{{categoryLink topic.category}}
</td>

View file

@ -0,0 +1 @@
{{discourse-basic-topic-list topics=model.topics hideCategories="true"}}

View file

@ -83,7 +83,7 @@
<div id='suggested-topics'>
<h3>{{i18n suggested_topics.title}}</h3>
<div class='topics'>
{{basicTopicList topics=details.suggested_topics}}
{{discourse-basic-topic-list topics=details.suggested_topics}}
</div>
<br/>
<h3>{{{view.browseMoreMessage}}}</h3>

View file

@ -1,12 +0,0 @@
/**
This view is used for rendering a basic list of topics.
@class BasicTopicListView
@extends Discourse.View
@namespace Discourse
@module Discourse
**/
Discourse.BasicTopicListView = Discourse.View.extend({
templateName: 'list/basic_topic_list'
});
Discourse.View.registerHelper('basicTopicList', Discourse.BasicTopicListView);

View file

@ -34,17 +34,19 @@ Discourse.ListTopicsView = Discourse.View.extend(Discourse.LoadMore, {
Discourse.notifyTitle(this.get('topicTrackingState.incomingCount'));
}.observes('topicTrackingState.incomingCount'),
loadMore: function() {
var listTopicsView = this;
Discourse.notifyTitle(0);
listTopicsView.get('controller').loadMore().then(function (hasMoreResults) {
Em.run.schedule('afterRender', function() {
listTopicsView.saveScrollPosition();
actions: {
loadMore: function() {
var self = this;
Discourse.notifyTitle(0);
self.get('controller').loadMore().then(function (hasMoreResults) {
Em.run.schedule('afterRender', function() {
self.saveScrollPosition();
});
if (!hasMoreResults) {
self.get('eyeline').flushRest();
}
});
if (!hasMoreResults) {
listTopicsView.get('eyeline').flushRest();
}
});
}
},
// Remember where we were scrolled to

View file

@ -1,20 +0,0 @@
/**
This view is used for rendering a basic list of topics.
@class PaginatedTopicListView
@extends Discourse.View
@namespace Discourse
@uses Discourse.LoadMore
@module Discourse
**/
Discourse.PaginatedTopicListView = Discourse.BasicTopicListView.extend(Discourse.LoadMore, {
topics: Em.computed.alias('controller.model.topics'),
classNames: ['paginated-topics-list'],
eyelineSelector: '.paginated-topics-list #topic-list tr',
loadMore: function() {
this.get('controller.model').loadMoreTopics();
}
});

View file

@ -0,0 +1,15 @@
/**
This view is used for rendering a basic list of topics on a user's page.
@class UserTopicsListView
@extends Discourse.View
@namespace Discourse
@uses Discourse.LoadMore
@module Discourse
**/
Discourse.UserTopicsListView = Discourse.View.extend(Discourse.LoadMore, {
classNames: ['paginated-topics-list'],
eyelineSelector: '.paginated-topics-list #topic-list tr',
templateName: 'list/user_topics_list'
});

View file

@ -65,8 +65,8 @@
//= require_tree ./discourse/controllers
//= require_tree ./discourse/lib
//= require_tree ./discourse/models
//= require_tree ./discourse/views
//= require_tree ./discourse/components
//= require_tree ./discourse/views
//= require_tree ./discourse/helpers
//= require_tree ./discourse/templates
//= require_tree ./discourse/routes