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
{{topic-list showParticipants=showParticipants
showPosters=showPosters
hideCategory=hideCategory
topics=topics
expandExcerpts=expandExcerpts
bulkSelectEnabled=bulkSelectEnabled
canBulkSelect=canBulkSelect
selected=selected
}}
selected=selected}}
{{else}}
{{#unless loadingMore}}
<div class='alert alert-info'>

View File

@ -1,7 +1,6 @@
{{#unless skipHeader}}
<thead>
{{raw "topic-list-header"
currentUser=currentUser
{{raw "topic-list-header" currentUser=currentUser
canBulkSelect=canBulkSelect
toggleInTitle=toggleInTitle
hideCategory=hideCategory

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,8 +137,7 @@
<h3>{{{view.suggestedTitle}}}</h3>
<div class="topics">
{{#if model.isPrivateMessage}}
{{basic-topic-list
hideCategory="true"
{{basic-topic-list hideCategory="true"
showPosters="true"
topics=model.details.suggested_topics
postsAction="showTopicEntrance"}}