|
1 | 1 | "use strict";
|
| 2 | +var__extends=(this&&this.__extends)||function(d,b){ |
| 3 | +for(varpinb)if(b.hasOwnProperty(p))d[p]=b[p]; |
| 4 | +function__(){this.constructor=d;} |
| 5 | +d.prototype=b===null ?Object.create(b) :(__.prototype=b.prototype,new__()); |
| 6 | +}; |
| 7 | +var__decorate=(this&&this.__decorate)||function(decorators,target,key,desc){ |
| 8 | +varc=arguments.length,r=c<3 ?target :desc===null ?desc=Object.getOwnPropertyDescriptor(target,key) :desc,d; |
| 9 | +if(typeofReflect==="object"&&typeofReflect.decorate==="function")r=Reflect.decorate(decorators,target,key,desc); |
| 10 | +elsefor(vari=decorators.length-1;i>=0;i--)if(d=decorators[i])r=(c<3 ?d(r) :c>3 ?d(target,key,r) :d(target,key))||r; |
| 11 | +returnc>3&&r&&Object.defineProperty(target,key,r),r; |
| 12 | +}; |
| 13 | +var__metadata=(this&&this.__metadata)||function(k,v){ |
| 14 | +if(typeofReflect==="object"&&typeofReflect.metadata==="function")returnReflect.metadata(k,v); |
| 15 | +}; |
2 | 16 | varReact=require('react');
|
| 17 | +varreact_redux_1=require('react-redux'); |
| 18 | +varAction=require('../../actions/actions'); |
3 | 19 | varmaterial_ui_1=require('material-ui');
|
4 | 20 | var_components_1=require('../_components');
|
5 |
| -functionhintsShown(task,hintPosition){ |
6 |
| -if(hintPosition>-1&&task.hints&&task.hints.length>0){ |
7 |
| -returntask.hints.slice(0,hintPosition+1); |
| 21 | +vardefault_1=(function(_super){ |
| 22 | +__extends(default_1,_super); |
| 23 | +functiondefault_1(){ |
| 24 | +_super.apply(this,arguments); |
8 | 25 | }
|
9 |
| -returnnull; |
10 |
| -} |
11 |
| -exports.TaskHint=function(_a){ |
12 |
| -varhint=_a.hint,index=_a.index; |
13 |
| -return(React.createElement(material_ui_1.ListItem,{className:'cr-task-hint',key:'hint'+index},React.createElement("div",{class:'cr-task-hint-box'},React.createElement("span",{className:'cr-task-hint-index'},index+1,"."),React.createElement("div",{className:'cr-task-hint-description'},React.createElement(_components_1.MarkdownText,{text:hint}))))); |
14 |
| -}; |
15 |
| -exports.TaskHints=function(_a){ |
16 |
| -vartask=_a.task,hintPosition=_a.hintPosition; |
17 |
| -varhints=hintsShown(task,hintPosition); |
18 |
| -return(React.createElement("div",{className:'cr-task-hints'},hints ?hints.map(function(hint,index){returnReact.createElement(exports.TaskHint,{hint:hint,index:index});}) :null)); |
19 |
| -}; |
| 26 | +default_1.prototype.render=function(){ |
| 27 | +var_a=this.props,task=_a.task,hintPosition=_a.hintPosition,nextHint=_a.nextHint,prevHint=_a.prevHint; |
| 28 | +varhints=task&&task.hints ?task.hints :null; |
| 29 | +console.log(hintPosition); |
| 30 | +if(hintPosition<0||!hints||!hints.length){ |
| 31 | +returnReact.createElement("div",null); |
| 32 | +} |
| 33 | +else{ |
| 34 | +varhint=hints[hintPosition]; |
| 35 | +return(React.createElement(material_ui_1.Card,{className:'cr-task-hints'}, |
| 36 | +React.createElement(material_ui_1.CardHeader,{title:'Hints',actAsExpander:true,showExpandableButton:true}), |
| 37 | +React.createElement(material_ui_1.CardText,{className:'cr-task-hint',expandable:true}, |
| 38 | +React.createElement(_components_1.MarkdownText,{text:hint}) |
| 39 | +), |
| 40 | +React.createElement(material_ui_1.CardActions,{expandable:true}, |
| 41 | +hintPosition>0 ?React.createElement(material_ui_1.FlatButton,{label:'Previous',onClick:prevHint.bind(this,hintPosition-1)}) :null, |
| 42 | +hintPosition<task.hints.length-1 ?React.createElement(material_ui_1.FlatButton,{label:'Next',onClick:nextHint.bind(this,hintPosition+1)}) :null))); |
| 43 | +} |
| 44 | +}; |
| 45 | +default_1=__decorate([ |
| 46 | +react_redux_1.connect(null,function(dispatch,state){ |
| 47 | +return{ |
| 48 | +nextHint:function(position){returndispatch(Action.setHintPosition(position));}, |
| 49 | +prevHint:function(position){returndispatch(Action.setHintPosition(position));} |
| 50 | +}; |
| 51 | +}), |
| 52 | +__metadata('design:paramtypes',[]) |
| 53 | +],default_1); |
| 54 | +returndefault_1; |
| 55 | +}(React.Component)); |
| 56 | +Object.defineProperty(exports,"__esModule",{value:true}); |
| 57 | +exports.default=default_1; |