Don't count DOM elements for operations count

The number of DOM elements rendered is fluid and using this
number displays inaccurate results as new operations are rendered.

Instead just set the operation count when creating the PathView
based on considering all the operations available.

Closes #502
This commit is contained in:
Kevin Sawicki 2013-04-24 10:30:51 -07:00
parent 946f908ab7
commit 09967db742
2 changed files with 7 additions and 3 deletions

View File

@ -14,7 +14,7 @@ class PathView extends View
@span outlet: 'description', class: 'path-match-number'
@ul outlet: 'matches', class: 'matches', =>
initialize: ({@previewList}) ->
initialize: ({@previewList, operationCount}) ->
@pathDetails.on 'mousedown', => @toggle(true)
@subscribe @previewList, 'command-panel:collapse-result', =>
if @isSelected()
@ -27,9 +27,10 @@ class PathView extends View
@toggle(true)
false
@description.text("(#{operationCount})")
addOperation: (operation) ->
@matches.append new OperationView({operation, @previewList})
@description.text("(#{@matches.find('li').length})")
isSelected: ->
@hasClass('selected') or @find('.selected').length

View File

@ -60,7 +60,7 @@ class PreviewList extends ScrollView
pathViewForPath: (path) ->
pathView = @viewsForPath[path]
if not pathView
pathView = new PathView({path: path, previewList: this})
pathView = new PathView({path: path, previewList: this, operationCount: @getPathOperationCount(path)})
@viewsForPath[path] = pathView
@append(pathView)
pathView
@ -97,6 +97,9 @@ class PreviewList extends ScrollView
getPathCount: ->
_.keys(_.groupBy(@operations, (operation) -> operation.getPath())).length
getPathOperationCount: (path) ->
@operations.filter((operation) -> path is operation.getPath()).length
getOperations: ->
new Array(@operations...)