(function(){ 'use strict'; angular.module('raz') .component('lcmBlockInfo', { templateUrl: '/js/angular/literacy-curriculum-map/components/lcm-block-info.html', controller: 'LCMBlockInfoController', bindings: { gradeIndex: '<', block: '<' } }) .controller('LCMBlockInfoController', LCMBlockInfoController); LCMBlockInfoController.$inject = ['blockMetaData', '$sce']; function LCMBlockInfoController (blockMetaData, $sce) { var ctrl = this; ctrl.$onInit = function() { ctrl.blockMetaData = blockMetaData; setTitle(); setBlockInfo(); } ctrl.trustAsHtml = function(html) { return $sce.trustAsHtml(html); }; function setTitle() { ctrl.mainTitle = ctrl.block['name']; var parenthetical = ctrl.mainTitle.indexOf('('); if (parenthetical !== -1) { ctrl.extraTitle = ctrl.mainTitle.slice(parenthetical); ctrl.mainTitle = ctrl.mainTitle.slice(0, parenthetical); } } function setBlockInfo() { var coreBlockId = ctrl.block['core_block_id']; ctrl.helpText = null; ctrl.timeValue = null; ctrl.forSmallGroups = null; if (coreBlockId && ctrl.gradeIndex) { var block = ctrl.blockMetaData[coreBlockId][ctrl.gradeIndex]; ctrl.helpText = block['help_text']; ctrl.timeValue = parseInt(block['time_value']) > 0 ? block['time_value'] : null; ctrl.forSmallGroups = block['is_small_group'] === 'y' ? 'for small groups' : ''; } } } })();