File tree Expand file tree Collapse file tree 3 files changed +37
-33693
lines changed
rest_framework_docs/static/rest_framework_docs/js Expand file tree Collapse file tree 3 files changed +37
-33693
lines changed Original file line number Diff line number Diff line change @@ -30,8 +30,21 @@ var Request = React.createClass({
3030 } ) ;
3131 } ,
3232
33- addField : function ( field ) {
34- console . log ( 'Adding field: ' , field ) ;
33+ addField : function ( fieldName ) {
34+ var endpoint = this . state . endpoint ;
35+ var fields = endpoint . fields ;
36+
37+ fields . push ( {
38+ name : fieldName ,
39+ required : false ,
40+ type : 'Added Field'
41+ } ) ;
42+
43+ endpoint . fields = fields ;
44+
45+ this . setState ( {
46+ endpoint : endpoint
47+ } ) ;
3548 } ,
3649
3750 setSelectedMethod : function ( method ) {
Original file line number Diff line number Diff line change @@ -12,6 +12,16 @@ var AddFieldsForm = React.createClass({
1212
1313 addField : function ( ) {
1414 this . props . onAdd ( this . state . fieldName ) ;
15+ this . setState ( {
16+ fieldName : ''
17+ } ) ;
18+ } ,
19+
20+ handleKeyPress : function ( event ) {
21+ if ( event . key === 'Enter' ) {
22+ event . preventDefault ( ) ;
23+ this . addField ( ) ;
24+ }
1525 } ,
1626
1727 handleChange : function ( event ) {
@@ -32,6 +42,7 @@ var AddFieldsForm = React.createClass({
3242 type = 'text'
3343 className = 'form-control input-sm'
3444 placeholder = 'Field Name (ie. email_address)'
45+ onKeyPress = { this . handleKeyPress }
3546 onChange = { this . handleChange }
3647 value = { this . state . fieldName } />
3748 </ div >
You can’t perform that action at this time.
0 commit comments