From 488611a4ff9a6fbfbc777ba310a582c9298315f1 Mon Sep 17 00:00:00 2001 From: Joe Wolf Date: Fri, 15 May 2015 11:16:50 -0400 Subject: [PATCH] 508 Fixes Addresses #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) --- src/main/javascript/helpers/handlebars.js | 12 ++++++++---- src/main/javascript/view/ContentTypeView.js | 4 +--- src/main/javascript/view/ParameterContentTypeView.js | 4 +--- src/main/javascript/view/ParameterView.js | 3 ++- src/main/javascript/view/ResponseContentTypeView.js | 4 +--- src/main/template/apikey_button_view.handlebars | 6 +++--- src/main/template/basic_auth_button_view.handlebars | 4 ++-- src/main/template/content_type.handlebars | 4 ++-- src/main/template/param.handlebars | 10 +++++----- src/main/template/param_list.handlebars | 8 ++------ src/main/template/param_readonly.handlebars | 4 ++-- src/main/template/param_readonly_required.handlebars | 4 ++-- src/main/template/param_required.handlebars | 10 +++++----- src/main/template/parameter_content_type.handlebars | 4 ++-- src/main/template/response_content_type.handlebars | 4 ++-- 15 files changed, 40 insertions(+), 45 deletions(-) diff --git a/src/main/javascript/helpers/handlebars.js b/src/main/javascript/helpers/handlebars.js index 226acc30..e596e4c3 100644 --- a/src/main/javascript/helpers/handlebars.js +++ b/src/main/javascript/helpers/handlebars.js @@ -7,7 +7,7 @@ Handlebars.registerHelper('sanitize', function(html) { }); Handlebars.registerHelper('renderTextParam', function(param) { - var result, type = 'text'; + var result, type = 'text', idAtt = ''; var isArray = param.type.toLowerCase() === 'array' || param.allowMultiple; var defaultValue = isArray && Array.isArray(param.default) ? param.default.join('\n') : param.default; @@ -16,11 +16,15 @@ Handlebars.registerHelper('renderTextParam', function(param) { } if(param.format && param.format === 'password') { - type = 'password'; + type = 'password'; + } + + if(param.valueId) { + idAtt = ' id=\'' + param.valueId + '\''; } if(isArray) { - result = ''; } else { @@ -29,7 +33,7 @@ Handlebars.registerHelper('renderTextParam', function(param) { parameterClass += ' required'; } result = ''; } return new Handlebars.SafeString(result); diff --git a/src/main/javascript/view/ContentTypeView.js b/src/main/javascript/view/ContentTypeView.js index 5a9b49cb..bad7ca7b 100644 --- a/src/main/javascript/view/ContentTypeView.js +++ b/src/main/javascript/view/ContentTypeView.js @@ -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; } }); \ No newline at end of file diff --git a/src/main/javascript/view/ParameterContentTypeView.js b/src/main/javascript/view/ParameterContentTypeView.js index cf33b3ba..31a192a9 100644 --- a/src/main/javascript/view/ParameterContentTypeView.js +++ b/src/main/javascript/view/ParameterContentTypeView.js @@ -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; } diff --git a/src/main/javascript/view/ParameterView.js b/src/main/javascript/view/ParameterView.js index ea7baa12..b5079c48 100644 --- a/src/main/javascript/view/ParameterView.js +++ b/src/main/javascript/view/ParameterView.js @@ -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; @@ -98,4 +99,4 @@ SwaggerUi.Views.ParameterView = Backbone.View.extend({ } } } -}); +}); \ No newline at end of file diff --git a/src/main/javascript/view/ResponseContentTypeView.js b/src/main/javascript/view/ResponseContentTypeView.js index e391cb19..41948ab6 100644 --- a/src/main/javascript/view/ResponseContentTypeView.js +++ b/src/main/javascript/view/ResponseContentTypeView.js @@ -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; } }); \ No newline at end of file diff --git a/src/main/template/apikey_button_view.handlebars b/src/main/template/apikey_button_view.handlebars index 756f3707..998f911a 100644 --- a/src/main/template/apikey_button_view.handlebars +++ b/src/main/template/apikey_button_view.handlebars @@ -1,9 +1,9 @@
-
{{keyName}}
- - +
+ +
diff --git a/src/main/template/basic_auth_button_view.handlebars b/src/main/template/basic_auth_button_view.handlebars index 6b828714..13497b88 100644 --- a/src/main/template/basic_auth_button_view.handlebars +++ b/src/main/template/basic_auth_button_view.handlebars @@ -1,9 +1,9 @@
-
Username
+
-
Password
+
diff --git a/src/main/template/content_type.handlebars b/src/main/template/content_type.handlebars index 063f6a6e..c3376a55 100644 --- a/src/main/template/content_type.handlebars +++ b/src/main/template/content_type.handlebars @@ -1,5 +1,5 @@ - - {{#if produces}} {{#each produces}} diff --git a/src/main/template/param.handlebars b/src/main/template/param.handlebars index ebc327d1..f1739a82 100644 --- a/src/main/template/param.handlebars +++ b/src/main/template/param.handlebars @@ -1,24 +1,24 @@ -{{name}} + {{#if isBody}} {{#if isFile}} - +
{{else}} {{#if default}} - +
{{else}} - +
{{/if}} {{/if}} {{else}} {{#if isFile}} - +
{{else}} {{#renderTextParam this}} diff --git a/src/main/template/param_list.handlebars b/src/main/template/param_list.handlebars index 6957122f..69a70b4b 100644 --- a/src/main/template/param_list.handlebars +++ b/src/main/template/param_list.handlebars @@ -1,10 +1,6 @@ -{{#if required}} -{{name}} -{{else}} -{{name}} -{{/if}} +