|
| 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 | +}; |
| 16 | +var React = require('react'); |
| 17 | +var react_redux_1 = require('react-redux'); |
| 18 | +var redux_form_1 = require('redux-form'); |
| 19 | +var Card_1 = require('material-ui/Card'); |
| 20 | +var RaisedButton_1 = require('material-ui/RaisedButton'); |
| 21 | +var actions_1 = require('../../actions'); |
| 22 | +var TopPanel_1 = require('../TopPanel'); |
| 23 | +var textField_1 = require('../Form/textField'); |
| 24 | +var validate_1 = require('./validate'); |
| 25 | +var styles = { |
| 26 | + card: { |
| 27 | + margin: '10px', |
| 28 | + padding: '30px 20px', |
| 29 | + textAlign: 'center', |
| 30 | + }, |
| 31 | + button: { |
| 32 | + margin: '30px 10px 20px 10px', |
| 33 | + }, |
| 34 | +}; |
| 35 | +var TutorialPublish = (function (_super) { |
| 36 | + __extends(TutorialPublish, _super); |
| 37 | + function TutorialPublish() { |
| 38 | + _super.apply(this, arguments); |
| 39 | + } |
| 40 | + TutorialPublish.prototype.componentWillMount = function () { |
| 41 | + this.props.initialize({ |
| 42 | + description: '', |
| 43 | + version: '0.1.0', |
| 44 | + keywords: '' |
| 45 | + }); |
| 46 | + }; |
| 47 | + TutorialPublish.prototype.componentDidMount = function () { |
| 48 | + TopPanel_1.topElement.toggle(false); |
| 49 | + document.getElementsByTagName('input')[0].focus(); |
| 50 | + }; |
| 51 | + TutorialPublish.prototype.shouldComponentUpdate = function () { |
| 52 | + if (document.activeElement && |
| 53 | + typeof document.activeElement.value === 'string') { |
| 54 | + return false; |
| 55 | + } |
| 56 | + }; |
| 57 | + TutorialPublish.prototype.onSubmit = function (values) { |
| 58 | + var description = values.description, version = values.version, keywords = values.keywords; |
| 59 | + this.props.save(Object.assign({}, this.props.packageJson, { |
| 60 | + description: description, version: version, |
| 61 | + keywords: ("coderoad, tutorial" + (keywords.length ? ', ' + keywords : '')).split(', ') |
| 62 | + })); |
| 63 | + }; |
| 64 | + TutorialPublish.prototype.render = function () { |
| 65 | + var _a = this.props, pristine = _a.pristine, submitting = _a.submitting, handleSubmit = _a.handleSubmit, invalid = _a.invalid; |
| 66 | + return (React.createElement(Card_1.Card, {style: styles.card}, |
| 67 | + React.createElement(Card_1.CardHeader, {title: 'Tutorial Info'}), |
| 68 | + React.createElement("form", {onSubmit: handleSubmit(this.onSubmit.bind(this))}, |
| 69 | + React.createElement(redux_form_1.Field, {name: 'description', component: textField_1.default.bind(null, { |
| 70 | + hintText: 'Tutorial description', |
| 71 | + floatingLabelText: 'Description', |
| 72 | + }), tabIndex: '1'}), |
| 73 | + React.createElement(redux_form_1.Field, {name: 'version', component: textField_1.default.bind(null, { |
| 74 | + hintText: '0.1.0', |
| 75 | + floatingLabelText: 'Version', |
| 76 | + disabled: true, |
| 77 | + }), tabIndex: '2'}), |
| 78 | + React.createElement(redux_form_1.Field, {name: 'keywords', component: textField_1.default.bind(null, { |
| 79 | + hintText: 'coderoad, react, js, etc', |
| 80 | + floatingLabelText: 'Keywords', |
| 81 | + }), tabIndex: '3'}), |
| 82 | + React.createElement(RaisedButton_1.default, {type: 'submit', style: styles.button, label: 'Save', primary: true, disabled: invalid}), |
| 83 | + React.createElement(RaisedButton_1.default, {style: styles.button, label: 'Publish', secondary: true, disabled: invalid, onTouchTap: function () { return alert('Publish not yet implemented'); }})))); |
| 84 | + }; |
| 85 | + TutorialPublish = __decorate([ |
| 86 | + react_redux_1.connect(function (state) { return ({ |
| 87 | + packageJson: state.packageJson, |
| 88 | + }); }, function (dispatch) { return ({ |
| 89 | + save: function (pj) { dispatch(actions_1.pjSave(pj)); }, |
| 90 | + routeToTutorial: function () { dispatch(actions_1.routeSet('page')); } |
| 91 | + }); }), |
| 92 | + __metadata('design:paramtypes', []) |
| 93 | + ], TutorialPublish); |
| 94 | + return TutorialPublish; |
| 95 | +}(React.Component)); |
| 96 | +Object.defineProperty(exports, "__esModule", { value: true }); |
| 97 | +exports.default = redux_form_1.reduxForm({ |
| 98 | + form: 'tutorialPublish', |
| 99 | + validate: validate_1.default, |
| 100 | +})(TutorialPublish); |
0 commit comments