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')); this._initFromTopicList(this.get('topicList'));
}.observes('topicList.@each'), }.observes('topicList.@each'),
_initFromTopicList: function(topicList) { _initFromTopicList(topicList) {
if (topicList !== null) { if (topicList !== null) {
this.set('topics', topicList.get('topics')); this.set('topics', topicList.get('topics'));
this.rerender(); this.rerender();
} }
}, },
init: function() { init() {
this._super(); this._super();
var topicList = this.get('topicList'); const topicList = this.get('topicList');
if (topicList) { if (topicList) {
this._initFromTopicList(topicList); this._initFromTopicList(topicList);
} else { } else {
// Without a topic list, we assume it's loaded always. // Without a topic list, we assume it's loaded always.
this.set('loaded', true); 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"; return this.get('order') === "op_likes";
}.property('order'), }.property('order'),
click: function(e){ click(e) {
var self = this; var self = this;
var on = function(sel, callback){ var on = function(sel, callback){
var target = $(e.target).closest(sel); var target = $(e.target).closest(sel);

View File

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

View File

@ -1,7 +1,6 @@
{{#unless skipHeader}} {{#unless skipHeader}}
<thead> <thead>
{{raw "topic-list-header" {{raw "topic-list-header" currentUser=currentUser
currentUser=currentUser
canBulkSelect=canBulkSelect canBulkSelect=canBulkSelect
toggleInTitle=toggleInTitle toggleInTitle=toggleInTitle
hideCategory=hideCategory hideCategory=hideCategory
@ -13,7 +12,7 @@
ascending=ascending ascending=ascending
sortable=sortable sortable=sortable
bulkSelectEnabled=bulkSelectEnabled}} bulkSelectEnabled=bulkSelectEnabled}}
</thead> </thead>
{{/unless}} {{/unless}}
<tbody> <tbody>
{{each topic in topics itemView="topic-list-item"}} {{each topic in topics itemView="topic-list-item"}}

View File

@ -1,7 +1,7 @@
{{#if controller.bulkSelectEnabled}} {{#if controller.bulkSelectEnabled}}
<td class='star'> <td class='star'>
<input type="checkbox" class="bulk-select"> <input type="checkbox" class="bulk-select">
</td> </td>
{{/if}} {{/if}}
<td class='main-link clearfix' colspan="{{titleColSpan}}"> <td class='main-link clearfix' colspan="{{titleColSpan}}">

View File

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

View File

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