This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/views/list/posts-count-column.js.es6
Régis Hanol 96b6d342cc FIX: /categories page issues
FIX: endless spinner when /categories is set to homepage and you click the home logo
FIX: latest column should respect topic state for the current user (new, unread, etc.)
FIX: post count should have heat colors applied based on like ratios
FIX: Add "More" button at the bottom of the latest column
UX: The topic count number in the categories panel should be slightly larger
2016-08-18 19:41:21 +02:00

34 lines
926 B
JavaScript

import computed from 'ember-addons/ember-computed-decorators';
import { fmt } from 'discourse/lib/computed';
export default Ember.Object.extend({
tagName: "td",
@computed("topic.like_count", "topic.posts_count")
ratio(likeCount, postCount) {
const likes = parseFloat(likeCount);
const posts = parseFloat(postCount);
if (posts < 10) { return 0; }
return (likes || 0) / posts;
},
@computed("topic.replyCount", "ratioText")
title(count, ratio) {
return I18n.messageFormat('posts_likes_MF', { count, ratio }).trim();
},
@computed("ratio")
ratioText(ratio) {
const settings = this.siteSettings;
if (ratio > settings.topic_post_like_heat_high) { return 'high'; }
if (ratio > settings.topic_post_like_heat_medium) { return 'med'; }
if (ratio > settings.topic_post_like_heat_low) { return 'low'; }
return '';
},
likesHeat: fmt('ratioText', 'heatmap-%@'),
});