FIX: Topic entrance wasn't showing on mobile. Tidied up some stuff.

This commit is contained in:
Robin Ward 2016-03-15 12:15:39 -04:00
parent ee5acf1948
commit 243c5a74ce
7 changed files with 64 additions and 45 deletions

View File

@ -15,22 +15,45 @@ export default Ember.Component.extend({
this._initFromTopicList(this.get('topicList'));
}.observes('topicList.@each'),
_initFromTopicList: function(topicList) {
_initFromTopicList(topicList) {
if (topicList !== null) {
this.set('topics', topicList.get('topics'));
this.rerender();
}
},
init: function() {
init() {
this._super();
var topicList = this.get('topicList');
const topicList = this.get('topicList');
if (topicList) {
this._initFromTopicList(topicList);
} else {
// Without a topic list, we assume it's loaded always.
this.set('loaded', true);
}
},
click(e) {
// Mobile basic-topic-list doesn't use the `topic-list-item` view so
// the event for the topic entrance is never wired up.
if (!this.site.mobileView) { return; }
let target = $(e.target);
if (target.hasClass('posts-map')) {
const topicId = target.closest('tr').attr('data-topic-id');
if (topicId) {
if (target.prop('tagName') !== 'A') {
target = target.find('a');
}
const topic = this.get('topics').findProperty('id', parseInt(topicId));
this.sendAction('postsAction', {topic, position: target.offset()});
// this.container.lookup('controller:application').send("showTopicEntrance", {topic, position: target.offset()});
}
return false;
}
}
});

View File

@ -30,7 +30,7 @@ export default Ember.Component.extend({
return this.get('order') === "op_likes";
}.property('order'),
click: function(e){
click(e) {
var self = this;
var on = function(sel, callback){
var target = $(e.target).closest(sel);

View File

@ -1,15 +1,13 @@
{{#conditional-loading-spinner condition=loading}}
{{#if topics}}
{{topic-list
showParticipants=showParticipants
showPosters=showPosters
hideCategory=hideCategory
topics=topics
expandExcerpts=expandExcerpts
bulkSelectEnabled=bulkSelectEnabled
canBulkSelect=canBulkSelect
selected=selected
}}
{{topic-list showParticipants=showParticipants
showPosters=showPosters
hideCategory=hideCategory
topics=topics
expandExcerpts=expandExcerpts
bulkSelectEnabled=bulkSelectEnabled
canBulkSelect=canBulkSelect
selected=selected}}
{{else}}
{{#unless loadingMore}}
<div class='alert alert-info'>

View File

@ -1,19 +1,18 @@
{{#unless skipHeader}}
<thead>
{{raw "topic-list-header"
currentUser=currentUser
canBulkSelect=canBulkSelect
toggleInTitle=toggleInTitle
hideCategory=hideCategory
showPosters=showPosters
showLikes=showLikes
showOpLikes=showOpLikes
showParticipants=showParticipants
order=order
ascending=ascending
sortable=sortable
bulkSelectEnabled=bulkSelectEnabled}}
</thead>
<thead>
{{raw "topic-list-header" currentUser=currentUser
canBulkSelect=canBulkSelect
toggleInTitle=toggleInTitle
hideCategory=hideCategory
showPosters=showPosters
showLikes=showLikes
showOpLikes=showOpLikes
showParticipants=showParticipants
order=order
ascending=ascending
sortable=sortable
bulkSelectEnabled=bulkSelectEnabled}}
</thead>
{{/unless}}
<tbody>
{{each topic in topics itemView="topic-list-item"}}

View File

@ -1,7 +1,7 @@
{{#if controller.bulkSelectEnabled}}
<td class='star'>
<input type="checkbox" class="bulk-select">
</td>
<td class='star'>
<input type="checkbox" class="bulk-select">
</td>
{{/if}}
<td class='main-link clearfix' colspan="{{titleColSpan}}">
@ -36,18 +36,18 @@
{{#if controller.showLikes}}
<td class="num likes">
{{#if hasLikes}}
<a href='{{topic.summaryUrl}}'>
{{number topic.like_count}} <i class='fa fa-heart'></i></td>
</a>
<a href='{{topic.summaryUrl}}'>
{{number topic.like_count}} <i class='fa fa-heart'></i></td>
</a>
{{/if}}
{{/if}}
{{#if controller.showOpLikes}}
<td class="num likes">
{{#if hasOpLikes}}
<a href='{{topic.summaryUrl}}'>
{{number topic.op_like_count}} <i class='fa fa-heart'></i></td>
</a>
<a href='{{topic.summaryUrl}}'>
{{number topic.op_like_count}} <i class='fa fa-heart'></i></td>
</a>
{{/if}}
{{/if}}

View File

@ -3,7 +3,7 @@
<table class="topic-list">
<tbody>
{{#each t in topics}}
<tr {{bind-attr class="t.archived"}}>
<tr {{bind-attr class="t.archived"}} data-topic-id={{t.id}}>
<td>
<div class='main-link'>
{{topic-status topic=t}}

View File

@ -137,13 +137,12 @@
<h3>{{{view.suggestedTitle}}}</h3>
<div class="topics">
{{#if model.isPrivateMessage}}
{{basic-topic-list
hideCategory="true"
showPosters="true"
topics=model.details.suggested_topics
postsAction="showTopicEntrance"}}
{{basic-topic-list hideCategory="true"
showPosters="true"
topics=model.details.suggested_topics
postsAction="showTopicEntrance"}}
{{else}}
{{basic-topic-list topics=model.details.suggested_topics postsAction="showTopicEntrance"}}
{{basic-topic-list topics=model.details.suggested_topics postsAction="showTopicEntrance"}}
{{/if}}
</div>
<h3>{{{view.browseMoreMessage}}}</h3>