Skip to content

Commit 11bc1fe

Browse files
committed
Fix JS data binding
1 parent ed38371 commit 11bc1fe

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

rest_framework/static/rest_framework/docs/js/api.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@ var responseDisplay = 'data'
22
var coreapi = window.coreapi
33
var schema = window.schema
44

5+
function normalizeKeys (arr) {
6+
var _normarr = [];
7+
for (var i = 0; i < arr.length; i++) {
8+
_normarr = _normarr.concat(arr[i].split(' > '));
9+
}
10+
return _normarr;
11+
}
12+
513
function normalizeHTTPHeader (str) {
614
// Capitalize HTTP headers for display.
715
return (str.charAt(0).toUpperCase() + str.substring(1))
@@ -94,7 +102,7 @@ $(function () {
94102
var $requestAwaiting = $form.find('.request-awaiting')
95103
var $responseRaw = $form.find('.response-raw')
96104
var $responseData = $form.find('.response-data')
97-
var key = $form.data('key')
105+
var key = normalizeKeys($form.data('key'))
98106
var params = {}
99107
var entries = formEntries($form.get()[0])
100108

@@ -212,7 +220,6 @@ $(function () {
212220
}
213221

214222
var client = new coreapi.Client(options)
215-
216223
client.action(schema, key, params).then(function (data) {
217224
var response = JSON.stringify(data, null, 2)
218225
$requestAwaiting.addClass('hide')

rest_framework/templates/rest_framework/docs/interact.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{% load rest_framework %}
22

33
<!-- Modal -->
4-
<div class="modal fade api-modal" id="{{ section_key }}_{{ link_key }}_modal" tabindex="-1" role="dialog" aria-labelledby="api explorer modal">
4+
<div class="modal fade api-modal" id="{{ section_key }}_{{ link_key|slugify }}_modal" tabindex="-1" role="dialog" aria-labelledby="api explorer modal">
55
<div class="modal-dialog modal-lg" role="document">
66
<div class="modal-content">
77
<div class="modal-header">

rest_framework/templates/rest_framework/docs/link.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
class="btn btn-sm btn-success"
77
style="float: right; margin-top: 20px"
88
data-toggle="modal"
9-
data-target="#{{ section_key }}_{{ link_key }}_modal">
9+
data-target="#{{ section_key }}_{{ link_key|slugify }}_modal">
1010
<i class="fa fa-exchange"></i> Interact
1111
</button>
1212

13-
<h3 id="{{ section_key }}-{{ link_key }}" class="coredocs-link-title">{{ link.title|default:link_key }} <a href="#{{ section_key }}-{{ link_key }}"><i class="fa fa-link" aria-hidden="true"></i>
13+
<h3 id="{{ section_key }}-{{ link_key|slugify }}" class="coredocs-link-title">{{ link.title|default:link_key }} <a href="#{{ section_key }}-{{ link_key|slugify }}"><i class="fa fa-link" aria-hidden="true"></i>
1414
</a></h3>
1515

1616
<div class="meta">

rest_framework/templates/rest_framework/docs/sidebar.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ <h3 class="brand"><a href="#">{{ document.title }}</a></h3>
1111
<a><i class="fa fa-dot-circle-o fa-lg"></i> {% if section_key %}{{ section_key }}{% else %}API Endpoints{% endif %} <span class="arrow"></span></a>
1212
<ul class="sub-menu {% if section_key %}collapse{% endif %}" id="{{ section_key }}-dropdown">
1313
{% for link_key, link in section|schema_links|items %}
14-
<li><a href="#{{ section_key }}-{{ link_key }}">{{ link.title|default:link_key }}</a></li>
14+
<li><a href="#{{ section_key }}-{{ link_key|slugify }}">{{ link.title|default:link_key }}</a></li>
1515
{% endfor %}
1616
</ul>
1717
</li>

0 commit comments

Comments
 (0)