Allow operations to be added to a PathView

This commit is contained in:
Corey Johnson
2013-03-13 15:43:28 -07:00
committed by probablycorey
parent 44f53e5ed0
commit 919cee3e4a

View File

@@ -5,18 +5,16 @@ $ = require 'jquery'
module.exports =
class PathView extends View
@content: ({path, operations, previewList} = {}) ->
@content: ({path, previewList} = {}) ->
classes = ['path']
classes.push('readme') if fs.isReadmePath(path)
@li class: classes.join(' '), =>
@div outlet: 'pathDetails', class: 'path-details', =>
@span class: 'path-name', path
@span "(#{operations.length})", class: 'path-match-number'
@span outlet: 'description', class: 'path-match-number'
@ul outlet: 'matches', class: 'matches', =>
for operation in operations
@subview "operation#{operation.index}", new OperationView({operation, previewList})
initialize: ({@previewList}) ->
initialize: ({operations, @previewList}) ->
@pathDetails.on 'mousedown', => @toggle(true)
@subscribe @previewList, 'command-panel:collapse-result', =>
@collapse(true) if @isSelected()
@@ -27,6 +25,12 @@ class PathView extends View
@toggle(true)
false
@addOperation(operation) for operation in operations
addOperation: (operation) ->
@matches.append new OperationView({operation, @previewList})
@description.text("(#{@matches.find('li').length})")
isSelected: ->
@hasClass('selected') or @find('.selected').length