mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Add one operations at a time to PathViews
This commit is contained in:
committed by
probablycorey
parent
014d5e7bb3
commit
6b3d527dda
@@ -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})")
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user