Skip to content

Commit

Permalink
508 Fixes (swagger-api#1021)
Browse files Browse the repository at this point in the history
Addresses swagger-api#1021 mostly by adding label tags, generating unique element
ids as needed.

In the process, moved the label text that gets set in the
___ContentTypeView.js files to the respective handlebar templates; the
text was static as far as I could tell.

There are additional minor 508 improvements that can be made with the
tables (scope tags, header attributes)
  • Loading branch information
bdkosher committed May 9, 2015
1 parent 1ea7786 commit f35fa55
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 36 deletions.
4 changes: 1 addition & 3 deletions src/main/javascript/view/ContentTypeView.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ SwaggerUi.Views.ContentTypeView = Backbone.View.extend({
initialize: function() {},

render: function(){
this.model.contentTypeId = 'ct' + Math.random();
$(this.el).html(Handlebars.templates.content_type(this.model));

$('label[for=contentType]', $(this.el)).text('Response Content Type');

return this;
}
});
4 changes: 1 addition & 3 deletions src/main/javascript/view/ParameterContentTypeView.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ SwaggerUi.Views.ParameterContentTypeView = Backbone.View.extend({
initialize: function () {},

render: function(){
this.model.parameterContentTypeId = 'pct' + Math.random();
$(this.el).html(Handlebars.templates.parameter_content_type(this.model));

$('label[for=parameterContentType]', $(this.el)).text('Parameter content type:');

return this;
}

Expand Down
1 change: 1 addition & 0 deletions src/main/javascript/view/ParameterView.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ SwaggerUi.Views.ParameterView = Backbone.View.extend({
this.model.isBody = this.model.paramType === 'body' || this.model.in === 'body';
this.model.isFile = type && type.toLowerCase() === 'file';
this.model.default = (this.model.default || this.model.defaultValue);
this.model.valueId = 'm' + this.model.name + Math.random();

if (this.model.allowableValues) {
this.model.isList = true;
Expand Down
4 changes: 1 addition & 3 deletions src/main/javascript/view/ResponseContentTypeView.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ SwaggerUi.Views.ResponseContentTypeView = Backbone.View.extend({
initialize: function(){},

render: function(){
this.model.responseContentTypeId = 'rct' + Math.random();
$(this.el).html(Handlebars.templates.response_content_type(this.model));

$('label[for=responseContentType]', $(this.el)).text('Response Content Type');

return this;
}
});
4 changes: 2 additions & 2 deletions src/main/template/content_type.handlebars
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<label for="contentType"></label>
<select name="contentType">
<label for="{{contentTypeId}}">Response Content Type</label>
<select name="contentType" id="{{contentTypeId}}">
{{#if produces}}
{{#each produces}}
<option value="{{{this}}}">{{{this}}}</option>
Expand Down
14 changes: 7 additions & 7 deletions src/main/template/param.handlebars
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
<td class='code'>{{name}}</td>
<td class='code'><label for='{{valueId}}'>{{name}}</label></td>
<td>

{{#if isBody}}
{{#if isFile}}
<input type="file" name='{{name}}'/>
<input type="file" name='{{name}}' id='{{valueId}}'/>
<div class="parameter-content-type" />
{{else}}
{{#if default}}
<textarea class='body-textarea' name='{{name}}'>{{default}}</textarea>
<textarea class='body-textarea' name='{{name}}' id='{{valueId}}'>{{default}}</textarea>
<br />
<div class="parameter-content-type" />
{{else}}
<textarea class='body-textarea' name='{{name}}'></textarea>
<textarea class='body-textarea' name='{{name}}' id='{{valueId}}'></textarea>
<br />
<div class="parameter-content-type" />
{{/if}}
{{/if}}
{{else}}
{{#if isFile}}
<input type="file" name='{{name}}'/>
<input type="file" name='{{name}}' id='{{valueId}}'/>
<div class="parameter-content-type" />
{{else}}
{{#if default}}
<input class='parameter' minlength='0' name='{{name}}' placeholder='' type='text' value='{{default}}'/>
<input class='parameter' minlength='0' id='{{valueId}}' name='{{name}}' placeholder='' type='text' value='{{default}}'/>
{{else}}
<input class='parameter' minlength='0' name='{{name}}' placeholder='' type='text' value=''/>
<input class='parameter' minlength='0' id='{{valueId}}' name='{{name}}' placeholder='' type='text' value=''/>
{{/if}}
{{/if}}
{{/if}}
Expand Down
6 changes: 3 additions & 3 deletions src/main/template/param_list.handlebars
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{{#if required}}
<td class='code required'>{{name}}</td>
<td class='code required'><label for='{{valueId}}'>{{name}}</label></td>
{{/if}}
<td class='code'>{{name}}</td>
<td class='code'><label for='{{valueId}}'>{{name}}</label></td>
<td>
<select {{#isArray this}} multiple='multiple'{{/isArray}} class='parameter' name='{{name}}'>
<select {{#isArray this}} multiple='multiple'{{/isArray}} class='parameter' name='{{name}}' id='{{valueId}}'>
{{#if required}}
{{else}}
{{#if default}}
Expand Down
4 changes: 2 additions & 2 deletions src/main/template/param_readonly.handlebars
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<td class='code'>{{name}}</td>
<td class='code'><label for='{{valueId}}'>{{name}}</label></td>
<td>
{{#if isBody}}
<textarea class='body-textarea' readonly='readonly' name='{{name}}'>{{default}}</textarea>
<textarea class='body-textarea' readonly='readonly' name='{{name}}' id='{{valueId}}'>{{default}}</textarea>
{{else}}
{{#if default}}
{{default}}
Expand Down
4 changes: 2 additions & 2 deletions src/main/template/param_readonly_required.handlebars
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<td class='code required'>{{name}}</td>
<td class='code required'><label for='{{valueId}}'>{{name}}</label></td>
<td>
{{#if isBody}}
<textarea class='body-textarea' readonly='readonly' placeholder='(required)' name='{{name}}'>{{default}}</textarea>
<textarea class='body-textarea' readonly='readonly' placeholder='(required)' name='{{name}}' id='{{valueId}}'>{{default}}</textarea>
{{else}}
{{#if default}}
{{default}}
Expand Down
14 changes: 7 additions & 7 deletions src/main/template/param_required.handlebars
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
<td class='code required'>{{name}}</td>
<td class='code required'><label for='{{valueId}}'>{{name}}</label></td>
<td>
{{#if isBody}}
{{#if isFile}}
<input type="file" name='{{name}}'/>
<input type="file" name='{{name}}' id='{{valueId}}'/>
{{else}}
{{#if default}}
<textarea class='body-textarea required' placeholder='(required)' name='{{name}}'>{{default}}</textarea>
<textarea class='body-textarea required' placeholder='(required)' name='{{name}}' id="{{valueId}}">{{default}}</textarea>
<br />
<div class="parameter-content-type" />
{{else}}
<textarea class='body-textarea required' placeholder='(required)' name='{{name}}'></textarea>
<textarea class='body-textarea required' placeholder='(required)' name='{{name}}' id='{{valueId}}'></textarea>
<br />
<div class="parameter-content-type" />
{{/if}}
{{/if}}
{{else}}
{{#if isFile}}
<input class='parameter' class='required' type='file' name='{{name}}'/>
<input class='parameter' class='required' type='file' name='{{name}}' id='{{valueId}}'/>
{{else}}
{{#if default}}
<input class='parameter required' minlength='1' name='{{name}}' placeholder='(required)' type='text' value='{{default}}'/>
<input class='parameter required' minlength='1' name='{{name}}' id='{{valueId}}' placeholder='(required)' type='text' value='{{default}}'/>
{{else}}
<input class='parameter required' minlength='1' name='{{name}}' placeholder='(required)' type='text' value=''/>
<input class='parameter required' minlength='1' name='{{name}}' id='{{valueId}}' placeholder='(required)' type='text' value=''/>
{{/if}}
{{/if}}
{{/if}}
Expand Down
4 changes: 2 additions & 2 deletions src/main/template/parameter_content_type.handlebars
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<label for="parameterContentType"></label>
<select name="parameterContentType">
<label for="{{parameterContentTypeId}}">Parameter content type:</label>
<select name="parameterContentType" id="{{parameterContentTypeId}}">
{{#if consumes}}
{{#each consumes}}
<option value="{{{this}}}">{{{this}}}</option>
Expand Down
4 changes: 2 additions & 2 deletions src/main/template/response_content_type.handlebars
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<label for="responseContentType"></label>
<select name="responseContentType">
<label for="{{responseContentTypeId}}">Response Content Type</label>
<select name="responseContentType" id="{{responseContentTypeId}}">
{{#if produces}}
{{#each produces}}
<option value="{{{this}}}">{{{this}}}</option>
Expand Down

0 comments on commit f35fa55

Please sign in to comment.