Browse Source

re-merged #96

bubble
Tony Tam 11 years ago
parent
commit
7bc8109e88
2 changed files with 19 additions and 10 deletions
  1. +7
    -0
      src/main/coffeescript/view/ResourceView.coffee
  2. +12
    -10
      src/main/template/operation.handlebars

+ 7
- 0
src/main/coffeescript/view/ResourceView.coffee View File

@@ -4,11 +4,18 @@ class ResourceView extends Backbone.View
render: -> render: ->
$(@el).html(Handlebars.templates.resource(@model)) $(@el).html(Handlebars.templates.resource(@model))


@number = 0

# Render each operation # Render each operation
@addOperation operation for operation in @model.operationsArray @addOperation operation for operation in @model.operationsArray
@ @


addOperation: (operation) -> addOperation: (operation) ->

operation.number = @number

# Render an operation and add it to operations li # Render an operation and add it to operations li
operationView = new OperationView({model: operation, tagName: 'li', className: 'endpoint'}) operationView = new OperationView({model: operation, tagName: 'li', className: 'endpoint'})
$('.endpoints', $(@el)).append operationView.render().el $('.endpoints', $(@el)).append operationView.render().el

@number++

+ 12
- 10
src/main/template/operation.handlebars View File

@@ -1,32 +1,34 @@


<ul class='operations' > <ul class='operations' >
<li class='{{httpMethod}} operation' id='{{resourceName}}_{{nickname}}_{{httpMethod}}'>
<li class='{{httpMethod}} operation' id='{{resourceName}}_{{nickname}}_{{httpMethod}}_{{number}}'>
<div class='heading'> <div class='heading'>
<h3> <h3>
<span class='http_method'> <span class='http_method'>
<a href='#!/{{resourceName}}/{{nickname}}_{{httpMethod}}' class="toggleOperation">{{httpMethod}}</a>
<a href='#!/{{resourceName}}/{{nickname}}_{{httpMethod}}_{{number}}' class="toggleOperation">{{httpMethod}}</a>
</span> </span>
<span class='path'> <span class='path'>
<a href='#!/{{resourceName}}/{{nickname}}_{{httpMethod}}' class="toggleOperation">{{path}}</a>
<a href='#!/{{resourceName}}/{{nickname}}_{{httpMethod}}_{{number}}' class="toggleOperation">{{path}}</a>
</span> </span>
</h3> </h3>
<ul class='options'> <ul class='options'>
<li> <li>
<a href='#!/{{resourceName}}/{{nickname}}_{{httpMethod}}' class="toggleOperation">{{{summary}}}</a>
<a href='#!/{{resourceName}}/{{nickname}}_{{httpMethod}}_{{number}}' class="toggleOperation">{{{summary}}}</a>
</li> </li>
</ul> </ul>
</div> </div>
<div class='content' id='{{resourceName}}_{{nickname}}_{{httpMethod}}_content' style='display:none'>
<div class='content' id='{{resourceName}}_{{nickname}}_{{httpMethod}}_{{number}}_content' style='display:none'>
{{#if notes}} {{#if notes}}
<h4>Implementation Notes</h4> <h4>Implementation Notes</h4>
<p>{{{notes}}}</p> <p>{{{notes}}}</p>
{{/if}} {{/if}}
{{#if responseClass}} {{#if responseClass}}
<h4>Response Model</h4>
<span class="model-signature"></span>
<h4>Response Class</h4>
{{#if responseClassSignature}}
<p><span class="model-signature">{{{responseClassSignature}}}</span></p>
{{else}}
<p>{{{responseClass}}}</p>
{{/if}}
{{/if}} {{/if}}
<br/>
<div class="content-type" />
<form accept-charset='UTF-8' class='sandbox'> <form accept-charset='UTF-8' class='sandbox'>
<div style='margin:0;padding:0;display:inline'></div> <div style='margin:0;padding:0;display:inline'></div>
<h4>Parameters</h4> <h4>Parameters</h4>
@@ -79,4 +81,4 @@
</div> </div>
</div> </div>
</li> </li>
</ul>
</ul>

Loading…
Cancel
Save