Skip to content

Commit b53de84

Browse files
author
Emmanouil Konstantinidis
committed
Fix form submit on 'enter'
1 parent 252527e commit b53de84

File tree

4 files changed

+16
-11
lines changed

4 files changed

+16
-11
lines changed

rest_framework_docs/static/.eslintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"rules": {
3-
"max-len": [1, 100, 2],
3+
"max-len": [1, 120, 2],
44
"no-undef": 2,
55
"no-unreachable": 2,
66
"no-unused-vars": 2,

rest_framework_docs/static/rest_framework_docs/js/components/liveapi.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ var LiveAPIEndpoints = React.createClass({
4040
render: function () {
4141

4242
return (
43-
<form className="form-horizontal">
43+
<form className="form-horizontal" onSubmit={this.makeRequest}>
4444
<div className="modal-body">
4545
<div className="row">
4646
<div className="col-md-6 request">
@@ -53,7 +53,7 @@ var LiveAPIEndpoints = React.createClass({
5353
</div>
5454
<div className="modal-footer">
5555
<button type="button" className="btn btn-default" data-dismiss="modal">Close</button>
56-
<button type="submit" onClick={this.makeRequest} className="btn btn-primary">Send</button>
56+
<button type="submit" className="btn btn-primary">Send</button>
5757
</div>
5858
</form>
5959
);

rest_framework_docs/static/rest_framework_docs/js/components/response.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ var Response = React.createClass({
2121
}
2222

2323
var responseJSON = JSONpp.prettyPrint(this.props.payload.body);
24+
var hasToken = this.props.payload.body.hasOwnProperty('token');
2425
var statusText = this.props.payload.statusText.toLowerCase();
2526
var statusCodeFirstChar = String(this.props.payload.status).charAt(0);
2627
var statusCodeClass = 'label status-code pull-right status-code-' + statusCodeFirstChar;
@@ -31,10 +32,13 @@ var Response = React.createClass({
3132

3233
<div><strong>Status</strong>: <span className='status-text'>{statusText}</span></div>
3334
<pre><code dangerouslySetInnerHTML={{__html: responseJSON}}></code></pre>
34-
<div className='well well-default text-center'>
35-
<button className='btn btn-sm btn-info'><i className='fa fa-key'></i> Save Token</button>
36-
<h6>Your token will be lost when you refresh the page.</h6>
37-
</div>
35+
36+
{hasToken ? (
37+
<div className='well well-default text-center'>
38+
<button className='btn btn-sm btn-info'><i className='fa fa-key'></i> Save Token</button>
39+
<h6>Your token will be lost when you refresh the page.</h6>
40+
</div>
41+
) : null}
3842
</div>
3943
);
4044
}

rest_framework_docs/static/rest_framework_docs/js/dist.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30865,7 +30865,7 @@ var LiveAPIEndpoints = React.createClass({
3086530865

3086630866
return React.createElement(
3086730867
'form',
30868-
{ className: 'form-horizontal' },
30868+
{ className: 'form-horizontal', onSubmit: this.makeRequest },
3086930869
React.createElement(
3087030870
'div',
3087130871
{ className: 'modal-body' },
@@ -30894,7 +30894,7 @@ var LiveAPIEndpoints = React.createClass({
3089430894
),
3089530895
React.createElement(
3089630896
'button',
30897-
{ type: 'submit', onClick: this.makeRequest, className: 'btn btn-primary' },
30897+
{ type: 'submit', className: 'btn btn-primary' },
3089830898
'Send'
3089930899
)
3090030900
)
@@ -31148,6 +31148,7 @@ var Response = React.createClass({
3114831148
}
3114931149

3115031150
var responseJSON = JSONpp.prettyPrint(this.props.payload.body);
31151+
var hasToken = this.props.payload.body.hasOwnProperty('token');
3115131152
var statusText = this.props.payload.statusText.toLowerCase();
3115231153
var statusCodeFirstChar = String(this.props.payload.status).charAt(0);
3115331154
var statusCodeClass = 'label status-code pull-right status-code-' + statusCodeFirstChar;
@@ -31185,7 +31186,7 @@ var Response = React.createClass({
3118531186
null,
3118631187
React.createElement('code', { dangerouslySetInnerHTML: { __html: responseJSON } })
3118731188
),
31188-
React.createElement(
31189+
hasToken ? React.createElement(
3118931190
'div',
3119031191
{ className: 'well well-default text-center' },
3119131192
React.createElement(
@@ -31199,7 +31200,7 @@ var Response = React.createClass({
3119931200
null,
3120031201
'Your token will be lost when you refresh the page.'
3120131202
)
31202-
)
31203+
) : null
3120331204
);
3120431205
}
3120531206
});

0 commit comments

Comments
 (0)