Skip to content

Commit a4a8ef0

Browse files
author
Emmanouil Konstantinidis
committed
Init Add Extra Field
1 parent 3ce7947 commit a4a8ef0

File tree

3 files changed

+33750
-10
lines changed

3 files changed

+33750
-10
lines changed

rest_framework_docs/static/rest_framework_docs/js/components/request.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
var React = require('react');
22

3+
var AddFieldsForm = require('./request/add-fields');
34
var Header = require('./helpers/header');
45
var Headers = require('./request/headers');
56
var FieldsData = require('./request/fields-data');
@@ -29,6 +30,10 @@ var Request = React.createClass({
2930
});
3031
},
3132

33+
addField: function (field) {
34+
console.log('Adding field: ', field);
35+
},
36+
3237
setSelectedMethod: function (method) {
3338
this.setState({
3439
selectedMethod: method
@@ -88,6 +93,8 @@ var Request = React.createClass({
8893
fields={endpoint.fields}
8994
data={this.state.data}
9095
onChange={this.handleDataFieldChange} />
96+
97+
<AddFieldsForm onAdd={this.addField} />
9198
</div>
9299
)}
93100
</div>
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
var React = require('react');
2+
3+
var Header = require('../helpers/header');
4+
5+
var AddFieldsForm = React.createClass({
6+
7+
getInitialState: function() {
8+
return {
9+
fieldName: ''
10+
};
11+
},
12+
13+
addField: function () {
14+
this.props.onAdd(this.state.fieldName);
15+
},
16+
17+
handleChange: function (event) {
18+
this.setState({
19+
fieldName: event.target.value
20+
});
21+
},
22+
23+
render: function () {
24+
return (
25+
<div>
26+
<Header title='Add Extra Fields' />
27+
28+
<div className='form-group'>
29+
<label className='col-sm-4 control-label'>Add Field</label>
30+
<div className="col-sm-6">
31+
<input
32+
type='text'
33+
className='form-control input-sm'
34+
placeholder='Field Name (ie. email_address)'
35+
onChange={this.handleChange}
36+
value={this.state.fieldName} />
37+
</div>
38+
<div className="col-sm-2">
39+
<button
40+
type="button"
41+
className='btn btn-sm btn-block btn-primary'
42+
onClick={this.addField}>
43+
Add
44+
</button>
45+
</div>
46+
</div>
47+
</div>
48+
);
49+
}
50+
});
51+
52+
module.exports = AddFieldsForm;

0 commit comments

Comments
 (0)