|
1 | 1 | "use strict"; |
| 2 | +var __extends = (this && this.__extends) || function (d, b) { |
| 3 | + for (var p in b) 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 | + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; |
| 9 | + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); |
| 10 | + else for (var i = 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 | + return c > 3 && r && Object.defineProperty(target, key, r), r; |
| 12 | +}; |
| 13 | +var __metadata = (this && this.__metadata) || function (k, v) { |
| 14 | + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); |
| 15 | +}; |
2 | 16 | var React = require('react'); |
| 17 | +var react_redux_1 = require('react-redux'); |
| 18 | +var Action = require('../../actions/actions'); |
3 | 19 | var material_ui_1 = require('material-ui'); |
4 | 20 | var _components_1 = require('../_components'); |
5 | | -function hintsShown(task, hintPosition) { |
6 | | - if (hintPosition > -1 && task.hints && task.hints.length > 0) { |
7 | | - return task.hints.slice(0, hintPosition + 1); |
| 21 | +var default_1 = (function (_super) { |
| 22 | + __extends(default_1, _super); |
| 23 | + function default_1() { |
| 24 | + _super.apply(this, arguments); |
8 | 25 | } |
9 | | - return null; |
10 | | -} |
11 | | -exports.TaskHint = function (_a) { |
12 | | - var hint = _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 | | - var task = _a.task, hintPosition = _a.hintPosition; |
17 | | - var hints = hintsShown(task, hintPosition); |
18 | | - return (React.createElement("div", {className: 'cr-task-hints'}, hints ? hints.map(function (hint, index) { return React.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 | + var hints = task && task.hints ? task.hints : null; |
| 29 | + console.log(hintPosition); |
| 30 | + if (hintPosition < 0 || !hints || !hints.length) { |
| 31 | + return React.createElement("div", null); |
| 32 | + } |
| 33 | + else { |
| 34 | + var hint = 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) { return dispatch(Action.setHintPosition(position)); }, |
| 49 | + prevHint: function (position) { return dispatch(Action.setHintPosition(position)); } |
| 50 | + }; |
| 51 | + }), |
| 52 | + __metadata('design:paramtypes', []) |
| 53 | + ], default_1); |
| 54 | + return default_1; |
| 55 | +}(React.Component)); |
| 56 | +Object.defineProperty(exports, "__esModule", { value: true }); |
| 57 | +exports.default = default_1; |
0 commit comments