manual merge of #304

This commit is contained in:
Tony Tam
2013-09-05 10:16:10 -07:00
parent 046e534d03
commit 8a9eedfdf3
4 changed files with 91 additions and 31 deletions

88
dist/swagger-ui.js vendored
View File

@@ -598,43 +598,64 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
function program1(depth0,data) { function program1(depth0,data) {
return "\n "; return " multiple='multiple'";
} }
function program3(depth0,data) { function program3(depth0,data) {
return "\n ";
}
function program5(depth0,data) {
var buffer = "", stack1; var buffer = "", stack1;
buffer += "\n "; buffer += "\n ";
stack1 = helpers['if'].call(depth0, depth0.defaultValue, {hash:{},inverse:self.program(6, program6, data),fn:self.program(4, program4, data),data:data}); stack1 = helpers['if'].call(depth0, depth0.defaultValue, {hash:{},inverse:self.program(8, program8, data),fn:self.program(6, program6, data),data:data});
if(stack1 || stack1 === 0) { buffer += stack1; } if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += "\n "; buffer += "\n ";
return buffer; return buffer;
} }
function program4(depth0,data) { function program6(depth0,data) {
return "\n "; return "\n ";
} }
function program6(depth0,data) {
return "\n <option selected=\"\" value=''></option>\n ";
}
function program8(depth0,data) { function program8(depth0,data) {
var buffer = "", stack1; var buffer = "", stack1;
buffer += "\n "; buffer += "\n ";
stack1 = helpers['if'].call(depth0, depth0.isDefault, {hash:{},inverse:self.program(11, program11, data),fn:self.program(9, program9, data),data:data}); stack1 = helpers['if'].call(depth0, depth0.allowMultiple, {hash:{},inverse:self.program(11, program11, data),fn:self.program(9, program9, data),data:data});
if(stack1 || stack1 === 0) { buffer += stack1; } if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += "\n "; buffer += "\n ";
return buffer; return buffer;
} }
function program9(depth0,data) { function program9(depth0,data) {
return "\n ";
}
function program11(depth0,data) {
return "\n <option selected=\"\" value=''></option>\n ";
}
function program13(depth0,data) {
var buffer = "", stack1; var buffer = "", stack1;
buffer += "\n <option selected=\"\" value='"; buffer += "\n ";
stack1 = helpers['if'].call(depth0, depth0.isDefault, {hash:{},inverse:self.program(16, program16, data),fn:self.program(14, program14, data),data:data});
if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += "\n ";
return buffer;
}
function program14(depth0,data) {
var buffer = "", stack1;
buffer += "\n <option value='";
if (stack1 = helpers.value) { stack1 = stack1.call(depth0, {hash:{},data:data}); } if (stack1 = helpers.value) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.value; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } else { stack1 = depth0.value; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1) buffer += escapeExpression(stack1)
@@ -646,7 +667,7 @@ function program9(depth0,data) {
return buffer; return buffer;
} }
function program11(depth0,data) { function program16(depth0,data) {
var buffer = "", stack1; var buffer = "", stack1;
buffer += "\n <option value='"; buffer += "\n <option value='";
@@ -665,15 +686,18 @@ function program11(depth0,data) {
if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); } if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1) buffer += escapeExpression(stack1)
+ "</td>\n<td>\n <select class='parameter' name='"; + "</td>\n<td>\n <select ";
stack1 = helpers['if'].call(depth0, depth0.allowMultiple, {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += " class='parameter' name='";
if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); } if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1) buffer += escapeExpression(stack1)
+ "'>\n "; + "'>\n ";
stack1 = helpers['if'].call(depth0, depth0.required, {hash:{},inverse:self.program(3, program3, data),fn:self.program(1, program1, data),data:data}); stack1 = helpers['if'].call(depth0, depth0.required, {hash:{},inverse:self.program(5, program5, data),fn:self.program(3, program3, data),data:data});
if(stack1 || stack1 === 0) { buffer += stack1; } if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += "\n "; buffer += "\n ";
stack2 = helpers.each.call(depth0, ((stack1 = depth0.allowableValues),stack1 == null || stack1 === false ? stack1 : stack1.descriptiveValues), {hash:{},inverse:self.noop,fn:self.program(8, program8, data),data:data}); stack2 = helpers.each.call(depth0, ((stack1 = depth0.allowableValues),stack1 == null || stack1 === false ? stack1 : stack1.descriptiveValues), {hash:{},inverse:self.noop,fn:self.program(13, program13, data),data:data});
if(stack2 || stack2 === 0) { buffer += stack2; } if(stack2 || stack2 === 0) { buffer += stack2; }
buffer += "\n </select>\n</td>\n<td>"; buffer += "\n </select>\n</td>\n<td>";
if (stack2 = helpers.description) { stack2 = stack2.call(depth0, {hash:{},data:data}); } if (stack2 = helpers.description) { stack2 = stack2.call(depth0, {hash:{},data:data}); }
@@ -683,7 +707,7 @@ function program11(depth0,data) {
if (stack2 = helpers.paramType) { stack2 = stack2.call(depth0, {hash:{},data:data}); } if (stack2 = helpers.paramType) { stack2 = stack2.call(depth0, {hash:{},data:data}); }
else { stack2 = depth0.paramType; stack2 = typeof stack2 === functionType ? stack2.apply(depth0) : stack2; } else { stack2 = depth0.paramType; stack2 = typeof stack2 === functionType ? stack2.apply(depth0) : stack2; }
if(stack2 || stack2 === 0) { buffer += stack2; } if(stack2 || stack2 === 0) { buffer += stack2; }
buffer += "</td>\n<td><span class=\"model-signature\"></span></td>\n"; buffer += "</td>\n<td><span class=\"model-signature\"></span></td>";
return buffer; return buffer;
}); });
})(); })();
@@ -1515,7 +1539,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
}; };
OperationView.prototype.submitOperation = function(e) { OperationView.prototype.submitOperation = function(e) {
var error_free, form, map, o, opts, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2; var error_free, form, map, o, opts, val, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2;
if (e != null) { if (e != null) {
e.preventDefault(); e.preventDefault();
} }
@@ -1556,8 +1580,9 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
_ref2 = form.find("select"); _ref2 = form.find("select");
for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) { for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
o = _ref2[_k]; o = _ref2[_k];
if ((o.value != null) && jQuery.trim(o.value).length > 0) { val = this.getSelectedValue(o);
map[o.name] = o.value; if ((val != null) && jQuery.trim(val).length > 0) {
map[o.name] = val;
} }
} }
opts.responseContentType = $("div select[name=responseContentType]", $(this.el)).val(); opts.responseContentType = $("div select[name=responseContentType]", $(this.el)).val();
@@ -1571,6 +1596,27 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
return parent.showCompleteStatus(response); return parent.showCompleteStatus(response);
}; };
OperationView.prototype.getSelectedValue = function(select) {
var opt, options, _i, _len, _ref;
if (!select.multiple) {
return select.value;
} else {
options = [];
_ref = select.options;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
opt = _ref[_i];
if (opt.selected) {
options.push(opt.value);
}
}
if (options.length > 0) {
return options.join(",");
} else {
return null;
}
}
};
OperationView.prototype.hideResponse = function(e) { OperationView.prototype.hideResponse = function(e) {
if (e != null) { if (e != null) {
e.preventDefault(); e.preventDefault();

File diff suppressed because one or more lines are too long

View File

@@ -89,9 +89,10 @@ class OperationView extends Backbone.View
if(o.value? && jQuery.trim(o.value).length > 0) if(o.value? && jQuery.trim(o.value).length > 0)
map["body"] = o.value map["body"] = o.value
for o in form.find("select") for o in form.find("select")
if(o.value? && jQuery.trim(o.value).length > 0) val = this.getSelectedValue o
map[o.name] = o.value if(val? && jQuery.trim(val).length > 0)
map[o.name] = val
opts.responseContentType = $("div select[name=responseContentType]", $(@el)).val() opts.responseContentType = $("div select[name=responseContentType]", $(@el)).val()
opts.requestContentType = $("div select[name=parameterContentType]", $(@el)).val() opts.requestContentType = $("div select[name=parameterContentType]", $(@el)).val()
@@ -102,7 +103,17 @@ class OperationView extends Backbone.View
success: (response, parent) -> success: (response, parent) ->
parent.showCompleteStatus response parent.showCompleteStatus response
getSelectedValue: (select) ->
if !select.multiple
select.value
else
options = []
options.push opt.value for opt in select.options when opt.selected
if options.length > 0
options.join ","
else
null
# handler for hide response link # handler for hide response link
hideResponse: (e) -> hideResponse: (e) ->
@@ -220,4 +231,4 @@ class OperationView extends Backbone.View
toggleOperationContent: -> toggleOperationContent: ->
elem = $('#' + Docs.escapeResourceName(@model.resourceName) + "_" + @model.nickname + "_" + @model.method + "_" + @model.number + "_content") elem = $('#' + Docs.escapeResourceName(@model.resourceName) + "_" + @model.nickname + "_" + @model.method + "_" + @model.number + "_content")
if elem.is(':visible') then Docs.collapseOperation(elem) else Docs.expandOperation(elem) if elem.is(':visible') then Docs.collapseOperation(elem) else Docs.expandOperation(elem)

View File

@@ -1,16 +1,19 @@
<td class='code'>{{name}}</td> <td class='code'>{{name}}</td>
<td> <td>
<select class='parameter' name='{{name}}'> <select {{#if allowMultiple}} multiple='multiple'{{/if}} class='parameter' name='{{name}}'>
{{#if required}} {{#if required}}
{{else}} {{else}}
{{#if defaultValue}} {{#if defaultValue}}
{{else}} {{else}}
<option selected="" value=''></option> {{#if allowMultiple}}
{{else}}
<option selected="" value=''></option>
{{/if}}
{{/if}} {{/if}}
{{/if}} {{/if}}
{{#each allowableValues.descriptiveValues}} {{#each allowableValues.descriptiveValues}}
{{#if isDefault}} {{#if isDefault}}
<option selected="" value='{{value}}'>{{value}} (default)</option> <option value='{{value}}'>{{value}} (default)</option>
{{else}} {{else}}
<option value='{{value}}'>{{value}}</option> <option value='{{value}}'>{{value}}</option>
{{/if}} {{/if}}
@@ -19,4 +22,4 @@
</td> </td>
<td>{{{description}}}</td> <td>{{{description}}}</td>
<td>{{{paramType}}}</td> <td>{{{paramType}}}</td>
<td><span class="model-signature"></span></td> <td><span class="model-signature"></span></td>