mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
Some topic list re-organization.
This commit is contained in:
parent
2f8866add5
commit
e5fd2946e0
14 changed files with 67 additions and 61 deletions
|
@ -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({});
|
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
|
@ -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();
|
||||
},
|
||||
|
|
|
@ -22,7 +22,7 @@ Discourse.TopicList = Discourse.Model.extend({
|
|||
});
|
||||
},
|
||||
|
||||
loadMoreTopics: function() {
|
||||
loadMore: function() {
|
||||
|
||||
if (this.get('loadingMore')) { return Ember.RSVP.reject(); }
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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>
|
|
@ -0,0 +1 @@
|
|||
{{discourse-basic-topic-list topics=model.topics hideCategories="true"}}
|
|
@ -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>
|
||||
|
|
|
@ -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);
|
|
@ -34,17 +34,19 @@ Discourse.ListTopicsView = Discourse.View.extend(Discourse.LoadMore, {
|
|||
Discourse.notifyTitle(this.get('topicTrackingState.incomingCount'));
|
||||
}.observes('topicTrackingState.incomingCount'),
|
||||
|
||||
actions: {
|
||||
loadMore: function() {
|
||||
var listTopicsView = this;
|
||||
var self = this;
|
||||
Discourse.notifyTitle(0);
|
||||
listTopicsView.get('controller').loadMore().then(function (hasMoreResults) {
|
||||
self.get('controller').loadMore().then(function (hasMoreResults) {
|
||||
Em.run.schedule('afterRender', function() {
|
||||
listTopicsView.saveScrollPosition();
|
||||
self.saveScrollPosition();
|
||||
});
|
||||
if (!hasMoreResults) {
|
||||
listTopicsView.get('eyeline').flushRest();
|
||||
self.get('eyeline').flushRest();
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// Remember where we were scrolled to
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
});
|
||||
|
|
@ -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'
|
||||
});
|
||||
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue