Code coverage report for src/flux/toc.coffee

Statements: 30.77% (8 / 26)      Branches: 0% (0 / 6)      Functions: 0% (0 / 9)      Lines: 30.77% (8 / 26)      Ignored: none     

All files » src/flux/ » toc.coffee
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                                                                                                      
var CrudConfig, TocConfig, _, actions, extendConfig, flux, makeSimpleStore, ref, ref1, store;
 
flux = require('flux-react');
 
_ = require('underscore');
 
ref = require('./helpers'), CrudConfig = ref.CrudConfig, extendConfig = ref.extendConfig, makeSimpleStore = ref.makeSimpleStore;
 
TocConfig = {
  _sections: {},
  FAILED: function() {
    return console.error('BUG: could not load readings');
  },
  _reset: function() {
    return this._sections = {};
  },
  _loaded: function(obj, id) {
    var chap, chapters, i, j, len, len1, ref1, section;
    chapters = obj[0].children;
    for (i = 0, len = chapters.length; i < len; i++) {
      chap = chapters[i];
      ref1 = chap.children;
      for (j = 0, len1 = ref1.length; j < len1; j++) {
        section = ref1[j];
        this._sections[section.id] = section;
      }
    }
    return chapters;
  },
  exports: {
    getChapterSection: function(sectionId) {
      var ref1;
      return ((ref1 = this._sections[sectionId]) != null ? ref1.chapter_section : void 0) || (function() {
        throw new Error('BUG: Invalid section');
      })();
    },
    getSectionInfo: function(sectionId) {
      return this._sections[sectionId] || (function() {
        throw new Error('BUG: Invalid section');
      })();
    },
    getSectionLabel: function(key) {
      return _.find(this._sections, function(section) {
        return section.chapter_section.toString() === key;
      });
    }
  }
};
 
extendConfig(TocConfig, new CrudConfig());
 
ref1 = makeSimpleStore(TocConfig), actions = ref1.actions, store = ref1.store;
 
module.exports = {
  TocActions: actions,
  TocStore: store
};