Code coverage report for src/components/task-plan/index.cjsx

Statements: 31.48% (17 / 54)      Branches: 0% (0 / 8)      Functions: 0% (0 / 11)      Lines: 31.48% (17 / 54)      Ignored: none     

All files » src/components/task-plan/ » index.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 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165                                                                                                                                                                                                                                                                                                        
var CourseActions, CourseStore, EventPlan, EventShell, ExternalPlan, ExternalShell, HomeworkPlan, HomeworkShell, LoadableItem, PLAN_TYPES, PlanShell, React, ReadingPlan, ReadingShell, TaskPlanActions, TaskPlanStore, getPlanType, ref, ref1;
 
React = require('react');
 
HomeworkPlan = require('./homework').HomeworkPlan;
 
ReadingPlan = require('./reading').ReadingPlan;
 
ExternalPlan = require('./external').ExternalPlan;
 
EventPlan = require('./event').EventPlan;
 
LoadableItem = require('../loadable-item');
 
ref = require('../../flux/course'), CourseStore = ref.CourseStore, CourseActions = ref.CourseActions;
 
ref1 = require('../../flux/task-plan'), TaskPlanStore = ref1.TaskPlanStore, TaskPlanActions = ref1.TaskPlanActions;
 
PLAN_TYPES = {
  reading: ReadingPlan,
  homework: HomeworkPlan,
  external: ExternalPlan,
  event: EventPlan
};
 
getPlanType = function(typeName) {
  var type;
  return type = PLAN_TYPES[typeName];
};
 
HomeworkShell = React.createClass({
  displayName: 'HomeworkShell',
  contextTypes: {
    router: React.PropTypes.func
  },
  render: function() {
    var courseId, id, ref2;
    ref2 = this.context.router.getCurrentParams(), courseId = ref2.courseId, id = ref2.id;
    return React.createElement(PlanShell, {
      "courseId": courseId,
      "id": id,
      "type": 'homework'
    });
  }
});
 
ReadingShell = React.createClass({
  displayName: 'ReadingShell',
  contextTypes: {
    router: React.PropTypes.func
  },
  render: function() {
    var courseId, id, ref2;
    ref2 = this.context.router.getCurrentParams(), courseId = ref2.courseId, id = ref2.id;
    return React.createElement(PlanShell, {
      "courseId": courseId,
      "id": id,
      "type": 'reading'
    });
  }
});
 
ExternalShell = React.createClass({
  displayName: 'ExternalShell',
  contextTypes: {
    router: React.PropTypes.func
  },
  render: function() {
    var courseId, id, ref2;
    ref2 = this.context.router.getCurrentParams(), courseId = ref2.courseId, id = ref2.id;
    return React.createElement(PlanShell, {
      "courseId": courseId,
      "id": id,
      "type": 'external'
    });
  }
});
 
EventShell = React.createClass({
  displayName: 'EventShell',
  contextTypes: {
    router: React.PropTypes.func
  },
  render: function() {
    var courseId, id, ref2;
    ref2 = this.context.router.getCurrentParams(), courseId = ref2.courseId, id = ref2.id;
    return React.createElement(PlanShell, {
      "courseId": courseId,
      "id": id,
      "type": 'event'
    });
  }
});
 
PlanShell = React.createClass({
  displayName: 'PlanShell',
  contextTypes: {
    router: React.PropTypes.func
  },
  getInitialState: function() {
    var courseId, id, ref2, type;
    ref2 = this.context.router.getCurrentParams(), courseId = ref2.courseId, id = ref2.id;
    type = this.props.type;
    if (!getPlanType(type)) {
      this.context.router.transitionTo('NotFoundRoute');
      return;
    }
    if (!id) {
      id = TaskPlanStore.freshLocalId();
      TaskPlanActions.create(id, {
        _HACK_courseId: courseId,
        type: type
      });
    }
    return {
      id: id
    };
  },
  getId: function() {
    return this.context.router.getCurrentParams().id || this.state.id;
  },
  getType: function() {
    var typeName;
    typeName = this.props.type;
    return getPlanType(typeName);
  },
  getFlux: function() {
    return {
      store: TaskPlanStore,
      actions: TaskPlanActions
    };
  },
  render: function() {
    var Type, courseId, id;
    Type = this.getType();
    courseId = this.context.router.getCurrentParams().courseId;
    id = this.getId();
    if (TaskPlanStore.isDeleteRequested(id)) {
      return React.createElement(Type, {
        "id": id,
        "courseId": courseId
      });
    }
    return React.createElement(LoadableItem, {
      "id": id,
      "store": TaskPlanStore,
      "actions": TaskPlanActions,
      "renderItem": (function() {
        return React.createElement(Type, {
          "id": id,
          "courseId": courseId
        });
      })
    });
  }
});
 
module.exports = {
  ReadingShell: ReadingShell,
  HomeworkShell: HomeworkShell,
  ExternalShell: ExternalShell,
  EventShell: EventShell
};