Add one operations at a time to PathViews

This commit is contained in:
Corey Johnson
2013-03-13 16:19:46 -07:00
committed by probablycorey
parent 014d5e7bb3
commit 6b3d527dda
2 changed files with 14 additions and 6 deletions

View File

@@ -14,7 +14,7 @@ class PathView extends View
@span outlet: 'description', class: 'path-match-number'
@ul outlet: 'matches', class: 'matches', =>
initialize: ({operations, @previewList}) ->
initialize: ({@previewList}) ->
@pathDetails.on 'mousedown', => @toggle(true)
@subscribe @previewList, 'command-panel:collapse-result', =>
@collapse(true) if @isSelected()
@@ -25,8 +25,6 @@ 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})")

View File

@@ -11,6 +11,7 @@ class PreviewList extends ScrollView
@ol class: 'preview-list', tabindex: -1
operations: null
viewsForPath: null
initialize: ->
super
@@ -36,14 +37,23 @@ class PreviewList extends ScrollView
@destroyOperations() if @operations
@operations = operations
@empty()
@viewsForPath = {}
operationsByPath = _.groupBy(operations, (operation) -> operation.getPath())
for path, operations of operationsByPath
@append new PathView({path, operations, previewList: this})
for operation in operations
pathView = @pathViewForPath(operation.getPath())
pathView.addOperation(operation)
@show()
@find('.operation:first').addClass('selected')
pathViewForPath: (path) ->
pathView = @viewsForPath[path]
if not pathView
pathView = new PathView({path: path, previewList: this})
@viewsForPath[path] = pathView
@append(pathView)
pathView
selectNextOperation: ->
selectedView = @find('.selected').view()
nextView = selectedView.next().view()