Code coverage report for src/components/course-calendar/add-menu-mixin.cjsx

Statements: 90.48% (19 / 21)      Branches: 100% (8 / 8)      Functions: 87.5% (7 / 8)      Lines: 90.48% (19 / 21)      Ignored: none     

All files » src/components/course-calendar/ » add-menu-mixin.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 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99                       39×                 196× 196×             49× 49× 49× 49×                                                                                     49× 49× 196× 196× 196×                          
var BS, CourseAddMenuMixin, React, _;
 
_ = require('underscore');
 
React = require('react');
 
BS = require('react-bootstrap');
 
CourseAddMenuMixin = {
  contextTypes: {
    router: React.PropTypes.func
  },
  propTypes: {
    dateFormat: React.PropTypes.string
  },
  getInitialState: function() {
    return {
      addDate: null
    };
  },
  getDefaultProps: function() {
    return {
      dateFormat: 'YYYY-MM-DD'
    };
  },
  goToBuilder: function(link) {
    return (function(_this) {
      return function(clickEvent) {
        clickEvent.preventDefault();
        return _this.context.router.transitionTo(link.to, link.params, link.query);
      };
    })(this);
  },
  renderAddActions: function() {
    var courseId, dateFormat, links, ref, ref1, ref2, ref3;
    courseId = this.context.router.getCurrentParams().courseId;
    dateFormat = this.props.dateFormat;
    links = [
      {
        text: 'Add Reading',
        to: 'createReading',
        params: {
          courseId: courseId
        },
        type: 'reading',
        query: {
          due_at: (ref = this.state.addDate) != null ? ref.format(dateFormat) : void 0
        }
      }, {
        text: 'Add Homework',
        to: 'createHomework',
        params: {
          courseId: courseId
        },
        type: 'homework',
        query: {
          due_at: (ref1 = this.state.addDate) != null ? ref1.format(dateFormat) : void 0
        }
      }, {
        text: 'Add External Assignment',
        to: 'createExternal',
        params: {
          courseId: courseId
        },
        type: 'external',
        query: {
          due_at: (ref2 = this.state.addDate) != null ? ref2.format(dateFormat) : void 0
        }
      }, {
        text: 'Add Event',
        to: 'createEvent',
        params: {
          courseId: courseId
        },
        type: 'event',
        query: {
          due_at: (ref3 = this.state.addDate) != null ? ref3.format(dateFormat) : void 0
        }
      }
    ];
    return _.map(links, (function(_this) {
      return function(link) {
        var href;
        href = _this.context.router.makeHref(link.to, link.params, link.query);
        return React.createElement(BS.MenuItem, {
          "onClick": _this.goToBuilder(link),
          "href": href,
          "key": link.type,
          "data-assignment-type": link.type,
          "ref": link.type + "Link"
        }, link.text);
      };
    })(this));
  }
};
 
module.exports = CourseAddMenuMixin;