@@ -8,6 +8,8 @@ var PlanetActions = require('../Actions/PlanetActions')
88
99var apiUrl = require ( '../../../config' ) . apiUrl
1010
11+ var aceModes = require ( '../../../modules/ace-modes' )
12+
1113var getOptions = function ( input , callback ) {
1214 request
1315 . get ( apiUrl + 'tags/search' )
@@ -39,7 +41,7 @@ var SnippetForm = React.createClass({
3941 getInitialState : function ( ) {
4042 var snippet = Object . assign ( {
4143 description : '' ,
42- mode : 'javascript ' ,
44+ mode : '' ,
4345 content : '' ,
4446 callSign : '' ,
4547 Tags : [ ]
@@ -57,6 +59,12 @@ var SnippetForm = React.createClass({
5759 componentDidMount : function ( ) {
5860 React . findDOMNode ( this . refs . description ) . focus ( )
5961 } ,
62+ handleModeChange : function ( selected ) {
63+ var snippet = this . state . snippet
64+ snippet . mode = selected
65+ console . log ( selected , 'selected' )
66+ this . setState ( { snippet : snippet } )
67+ } ,
6068 handleTagsChange : function ( selected , all ) {
6169 var snippet = this . state . snippet
6270 snippet . Tags = all
@@ -92,6 +100,12 @@ var SnippetForm = React.createClass({
92100 }
93101 } ,
94102 render : function ( ) {
103+ var modeOptions = aceModes . map ( function ( mode ) {
104+ return {
105+ label : mode ,
106+ value : mode
107+ }
108+ } )
95109 return (
96110 < div onKeyDown = { this . handleKeyDown } className = 'SnippetForm' >
97111 < div className = 'modal-body' >
@@ -100,11 +114,13 @@ var SnippetForm = React.createClass({
100114 </ div >
101115 < div className = 'form-group' >
102116 < input className = 'inline-input' valueLink = { this . linkState ( 'snippet.callSign' ) } type = 'text' placeholder = 'Callsign' />
103- < select className = 'inline-input' valueLink = { this . linkState ( 'snippet.mode' ) } >
104- < option value = 'javascript' > Javascript</ option >
105- < option value = 'html' > HTML</ option >
106- < option value = 'css' > CSS</ option >
107- </ select >
117+ < Select
118+ name = 'mode'
119+ className = 'modeSelect'
120+ value = { this . state . snippet . mode }
121+ placeholder = 'Select Language'
122+ options = { modeOptions }
123+ onChange = { this . handleModeChange } />
108124 </ div >
109125 < div className = 'form-group' >
110126 < CodeEditor onChange = { this . handleContentChange } code = { this . state . snippet . content } mode = { this . state . snippet . mode } />
0 commit comments