Adding JSON sample UI to response
This commit is contained in:
@@ -14,6 +14,18 @@ class OperationView extends Backbone.View
|
||||
|
||||
$(@el).html(Handlebars.templates.operation(@model))
|
||||
|
||||
if @model.responseClassSignature and @model.responseClassSignature != 'string'
|
||||
signatureModel =
|
||||
sampleJSON: @model.responseSampleJSON
|
||||
isParam: false
|
||||
signature: @model.responseClassSignature
|
||||
|
||||
responseSignatureView = new SignatureView({model: signatureModel, tagName: 'div'})
|
||||
$('.model-signature', $(@el)).append responseSignatureView.render().el
|
||||
else
|
||||
$('.model-signature', $(@el)).html(@model.responseClass)
|
||||
|
||||
|
||||
# Render each parameter
|
||||
@addParameter param for param in @model.parameters
|
||||
|
||||
|
||||
@@ -8,8 +8,13 @@ class ParameterView extends Backbone.View
|
||||
template = @template()
|
||||
$(@el).html(template(@model))
|
||||
|
||||
signatureModel =
|
||||
sampleJSON: @model.sampleJSON
|
||||
isParam: true
|
||||
signature: @model.signature
|
||||
|
||||
if @model.sampleJSON
|
||||
signatureView = new SignatureView({model: @model, tagName: 'div'})
|
||||
signatureView = new SignatureView({model: signatureModel, tagName: 'div'})
|
||||
$('.model-signature', $(@el)).append signatureView.render().el
|
||||
else
|
||||
$('.model-signature', $(@el)).html(@model.signature)
|
||||
|
||||
@@ -13,6 +13,11 @@ class SignatureView extends Backbone.View
|
||||
|
||||
@switchToDescription()
|
||||
|
||||
@isParam = @model.isParam
|
||||
|
||||
if @isParam
|
||||
$('.notice', $(@el)).text('Click to set as parameter value')
|
||||
|
||||
@
|
||||
|
||||
template: ->
|
||||
@@ -36,8 +41,11 @@ class SignatureView extends Backbone.View
|
||||
|
||||
# handler for snippet to text area
|
||||
snippetToTextArea: (e) ->
|
||||
e?.preventDefault()
|
||||
textArea = $('textarea', $(@el.parentNode.parentNode.parentNode))
|
||||
if $.trim(textArea.val()) == ''
|
||||
if @isParam
|
||||
e?.preventDefault()
|
||||
textArea = $('textarea', $(@el.parentNode.parentNode.parentNode))
|
||||
if $.trim(textArea.val()) == ''
|
||||
textArea.val(@model.sampleJSON)
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user