Code coverage report for src/components/scores/quick-external-stats.cjsx

Statements: 25% (8 / 32)      Branches: 0% (0 / 4)      Functions: 0% (0 / 8)      Lines: 25% (8 / 32)      Ignored: none     

All files » src/components/scores/ » quick-external-stats.cjsx
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77                                                                                                                                          
var LoadableItem, QuickStats, QuickStatsShell, React, TaskPlanStatsActions, TaskPlanStatsStore, _, ref;
 
React = require('react');
 
_ = require('underscore');
 
ref = require('../../flux/task-plan-stats'), TaskPlanStatsStore = ref.TaskPlanStatsStore, TaskPlanStatsActions = ref.TaskPlanStatsActions;
 
LoadableItem = require('../loadable-item');
 
QuickStats = React.createClass({displayName: "QuickStats",
  propTypes: {
    id: React.PropTypes.string.isRequired,
    periodId: React.PropTypes.string.isRequired
  },
  getInitialState: function() {
    return this.getStatsByPeriod(this.props);
  },
  componentWillReceiveProps: function(nextProps) {
    var stats;
    stats = this.getStatsByPeriod(nextProps);
    return this.setState(stats);
  },
  getStatsByPeriod: function(props) {
    var id, periodId, plan, stats;
    periodId = props.periodId, id = props.id;
    plan = TaskPlanStatsStore.get(id);
    stats = _(plan.stats).findWhere({
      period_id: periodId
    });
    return {
      stats: stats
    };
  },
  renderStats: function(data) {
    return data.complete_count + "/" + data.total_count + " clicked";
  },
  render: function() {
    var className, classes, course, id, ref1, stats;
    ref1 = this.props, id = ref1.id, className = ref1.className;
    stats = this.state.stats;
    classes = 'quick-external-stats';
    if (className != null) {
      classes += " " + className;
    }
    if (stats != null) {
      course = this.renderStats(stats);
    }
    return React.createElement("span", {
      "className": classes
    }, course);
  }
});
 
QuickStatsShell = React.createClass({displayName: "QuickStatsShell",
  render: function() {
    var id;
    id = this.props.id;
    return React.createElement(LoadableItem, {
      "id": id,
      "store": TaskPlanStatsStore,
      "actions": TaskPlanStatsActions,
      "renderItem": ((function(_this) {
        return function() {
          return React.createElement(QuickStats, React.__spread({}, _this.props));
        };
      })(this))
    });
  }
});
 
module.exports = {
  QuickStats: QuickStats,
  QuickStatsShell: QuickStatsShell
};