From ec686c9452b3e27e6de3b84f1f45214182d0894b Mon Sep 17 00:00:00 2001 From: Rokt33r Date: Thu, 16 Jul 2015 17:02:46 +0900 Subject: [PATCH] extract BlueprintForm from LaunchModal & add Tag search --- browser/main/Components/BlueprintForm.jsx | 93 +++++++++++++++++++++++ browser/main/Components/LaunchModal.jsx | 73 +----------------- browser/main/Components/SnippetForm.jsx | 38 ++++++--- browser/styles/shared/modal.styl | 1 + 4 files changed, 122 insertions(+), 83 deletions(-) create mode 100644 browser/main/Components/BlueprintForm.jsx diff --git a/browser/main/Components/BlueprintForm.jsx b/browser/main/Components/BlueprintForm.jsx new file mode 100644 index 00000000..a054b61f --- /dev/null +++ b/browser/main/Components/BlueprintForm.jsx @@ -0,0 +1,93 @@ +var React = require('react/addons') +var ReactRouter = require('react-router') +var CodeEditor = require('./CodeEditor') +var Catalyst = require('../Mixins/Catalyst') +var Select = require('react-select') +var request = require('superagent') + +var getOptions = function (input, callback) { + request + .get('http://localhost:8000/tags/search') + .query({name: input}) + .send() + .end(function (err, res) { + if (err) { + callback(err) + return + } + callback(null, { + options: res.body.map(function (tag) { + return { + label: tag.name, + value: tag.name + } + }), + complete: true + }) + }) +} + +var BlueprintForm = React.createClass({ + mixins: [Catalyst.LinkedStateMixin, ReactRouter.State], + propTypes: { + close: React.PropTypes.func + }, + getInitialState: function () { + return { + blueprint: { + title: '', + content: '', + Tags: [] + } + } + }, + componentDidMount: function () { + React.findDOMNode(this.refs.title).focus() + }, + handleTagsChange: function (selected, all) { + var blueprint = this.state.blueprint + blueprint.Tags = all + this.setState({blueprint: blueprint}) + }, + handleContentChange: function (e, value) { + var blueprint = this.state.blueprint + blueprint.content = value + this.setState({blueprint: blueprint}) + }, + submit: function () { + console.log(this.state.blueprint) + }, + render: function () { + return ( +
+
+
+ +
+
+ +
+
+ -
-
- -
-
-
- +