@@ -5,92 +5,15 @@ var Catalyst = require('../Mixins/Catalyst')
55
66var Select = require ( 'react-select' )
77
8- var PlanetActions = require ( '../Actions/PlanetActions' )
98var PlanetStore = require ( '../Stores/PlanetStore' )
109
11- // TODO: remove
10+ var SnippetForm = require ( './SnippetForm' )
11+
1212var options = [
1313 { value : 'one' , label : 'One' } ,
1414 { value : 'two' , label : 'Two' }
1515]
1616
17- var SnippetForm = React . createClass ( {
18- mixins : [ Catalyst . LinkedStateMixin , ReactRouter . State ] ,
19- propTypes : {
20- close : React . PropTypes . func
21- } ,
22- getInitialState : function ( ) {
23- return {
24- snippet : {
25- description : '' ,
26- mode : 'javascript' ,
27- content : '' ,
28- callSign : '' ,
29- Tags : [ ]
30- }
31- }
32- } ,
33- handleSnippetTagsChange : function ( selected , all ) {
34- var snippet = this . state . snippet
35- snippet . Tags = all
36- this . setState ( { snippet : snippet } )
37- } ,
38- handleSnippetContentChange : function ( e , value ) {
39- var snippet = this . state . snippet
40- snippet . content = value
41- this . setState ( { snippet : snippet } )
42- } ,
43- submit : function ( ) {
44- var params = this . getParams ( )
45- var userName = params . userName
46- var planetName = params . planetName
47- var snippet = Object . assign ( { } , this . state . snippet )
48- snippet . Tags = snippet . Tags . map ( function ( tag ) {
49- return tag . value
50- } )
51- PlanetActions . createSnippet ( userName + '/' + planetName , snippet )
52- } ,
53- render : function ( ) {
54- return (
55- < div className = 'SnippetForm' >
56- < div className = 'modal-body' >
57- < div className = 'form-group' >
58- < textarea className = 'snippetDescription block-input' valueLink = { this . linkState ( 'snippet.description' ) } placeholder = 'Description' />
59- </ div >
60- < div className = 'form-group' >
61- < input className = 'inline-input' valueLink = { this . linkState ( 'snippet.callSign' ) } type = 'text' placeholder = 'Callsign' />
62- < select className = 'inline-input' valueLink = { this . linkState ( 'snippet.mode' ) } >
63- < option value = 'javascript' > Javascript</ option >
64- < option value = 'html' > HTML</ option >
65- < option value = 'css' > CSS</ option >
66- </ select >
67- </ div >
68- < div className = 'form-group' >
69- < CodeEditor onChange = { this . handleSnippetContentChange } code = { this . state . snippet . content } mode = { this . state . snippet . mode } />
70- </ div >
71- < div className = 'form-group' >
72- < Select
73- name = 'Tags'
74- multi = { true }
75- allowCreate = { true }
76- value = { this . state . snippet . Tags }
77- placeholder = 'Tags...'
78- options = { options }
79- onChange = { this . handleSnippetTagsChange }
80- />
81- </ div >
82- </ div >
83- < div className = 'modal-footer' >
84- < div className = 'modal-control' >
85- < button onClick = { this . props . close } className = 'btn-default' > Cancle</ button >
86- < button onClick = { this . submit } className = 'btn-primary' > Launch</ button >
87- </ div >
88- </ div >
89- </ div >
90- )
91- }
92- } )
93-
9417var BlueprintForm = React . createClass ( {
9518 mixins : [ Catalyst . LinkedStateMixin , ReactRouter . State ] ,
9619 propTypes : {
@@ -105,6 +28,9 @@ var BlueprintForm = React.createClass({
10528 }
10629 }
10730 } ,
31+ componentDidMount : function ( ) {
32+ React . findDOMNode ( this . refs . title ) . focus ( )
33+ } ,
10834 handleBlueprintTagsChange : function ( selected , all ) {
10935 var blueprint = this . state . blueprint
11036 blueprint . Tags = all
@@ -123,7 +49,7 @@ var BlueprintForm = React.createClass({
12349 < div className = 'BlueprintForm' >
12450 < div className = 'modal-body' >
12551 < div className = 'form-group' >
126- < input className = 'block-input' valueLink = { this . linkState ( 'blueprint.title' ) } placeholder = 'Title' />
52+ < input ref = 'title' className = 'block-input' valueLink = { this . linkState ( 'blueprint.title' ) } placeholder = 'Title' />
12753 </ div >
12854 < div className = 'form-group' >
12955 < CodeEditor onChange = { this . handleBlueprintContentChange } code = { this . state . blueprint . content } mode = { 'markdown' } />
0 commit comments