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
2015-08-10 10:21:05 -04:00

34 lines
907 B
JavaScript

import { fmt } from 'discourse/lib/computed';
export default Ember.Object.extend({
tagName: "td",
ratio: function() {
var likes = parseFloat(this.get('topic.like_count')),
posts = parseFloat(this.get('topic.posts_count'));
if (posts < 10) { return 0; }
return (likes || 0) / posts;
}.property(),
title: function() {
return I18n.messageFormat('posts_likes_MF', {
count: this.get('topic.replyCount'),
ratio: this.get('ratioText')
}).trim();
}.property(),
ratioText: function() {
var ratio = this.get('ratio');
var settings = Discourse.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 '';
}.property(),
likesHeat: fmt('ratioText', 'heatmap-%@'),
});