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/mixins/selected_posts_count.js
2013-09-05 11:03:29 -04:00

27 lines
683 B
JavaScript

/**
This mixin allows a modal to list a selected posts count nicely.
@class Discourse.SelectedPostsCount
@extends Ember.Mixin
@namespace Discourse
@module Discourse
**/
Discourse.SelectedPostsCount = Em.Mixin.create({
selectedPostsCount: function() {
if (this.get('allPostsSelected')) return this.get('posts_count') || this.get('topic.posts_count');
var sum = this.get('selectedPosts.length') || 0;
if (this.get('selectedReplies')) {
this.get('selectedReplies').forEach(function (p) {
sum += p.get('reply_count') || 0;
});
}
return sum;
}.property('selectedPosts.length', 'allPostsSelected', 'selectedReplies.length')
});