mirror of
https://github.com/atom/atom.git
synced 2026-01-24 22:38:20 -05:00
Improve UX
Properly compress all results to one heading Merge Expand/Collapse Button into one
This commit is contained in:
@@ -6,6 +6,7 @@ PreviewList = require './preview-list'
|
||||
Editor = require 'editor'
|
||||
{SyntaxError} = require('pegjs').parser
|
||||
_ = require 'underscore'
|
||||
$ = require 'jquery'
|
||||
|
||||
module.exports =
|
||||
class CommandPanelView extends View
|
||||
@@ -14,7 +15,6 @@ class CommandPanelView extends View
|
||||
@div class: 'header', outlet: 'previewHeader', =>
|
||||
@span outlet: 'searchLoadingMessage', class: 'loading', 'Searching...'
|
||||
@ul outlet: 'expandCollapse', class: 'expand-collapse', =>
|
||||
@li class: 'expand', 'Expand All'
|
||||
@li class: 'collapse', 'Collapse All'
|
||||
@span outlet: 'previewCount', class: 'preview-count'
|
||||
|
||||
@@ -54,6 +54,7 @@ class CommandPanelView extends View
|
||||
@previewHeader.hide()
|
||||
@errorMessages.hide()
|
||||
@searchLoadingMessage.hide()
|
||||
@expandCollapse.hide()
|
||||
@prompt.iconSize(@miniEditor.getFontSize())
|
||||
|
||||
@history = state.history ? []
|
||||
@@ -92,11 +93,17 @@ class CommandPanelView extends View
|
||||
@miniEditor.focus()
|
||||
|
||||
onExpandAll: (event) =>
|
||||
@previewList.expandAllPaths()
|
||||
elButton = $(event.currentTarget)
|
||||
@previewList.expandAllPaths()
|
||||
elButton.removeClass("expand").addClass("collapse")
|
||||
elButton.text("Collapse All")
|
||||
@previewList.focus()
|
||||
|
||||
onCollapseAll: (event) =>
|
||||
elButton = $(event.currentTarget)
|
||||
@previewList.collapseAllPaths()
|
||||
elButton.removeClass("collapse").addClass("expand")
|
||||
elButton.text("Expand All")
|
||||
@previewList.focus()
|
||||
|
||||
attach: (text='', options={}) ->
|
||||
@@ -123,10 +130,11 @@ class CommandPanelView extends View
|
||||
@searchLoadingMessage.show()
|
||||
@errorMessages.empty()
|
||||
project.previewList = @previewList
|
||||
|
||||
|
||||
try
|
||||
@commandInterpreter.eval(command, rootView.getActivePaneItem()).done ({operationsToPreview, errorMessages}) =>
|
||||
@searchLoadingMessage.hide()
|
||||
@expandCollapse.show()
|
||||
@history.push(command)
|
||||
@historyIndex = @history.length
|
||||
|
||||
|
||||
@@ -19,8 +19,6 @@ class PreviewList extends ScrollView
|
||||
|
||||
@on 'core:move-down', => @selectNextOperation(); false
|
||||
@on 'core:move-up', => @selectPreviousOperation(); false
|
||||
@on 'scroll', =>
|
||||
@renderOperations() if @scrollBottom() >= (@prop('scrollHeight'))
|
||||
|
||||
@command 'command-panel:collapse-all', => @collapseAllPaths()
|
||||
@command 'command-panel:expand-all', => @expandAllPaths()
|
||||
@@ -29,7 +27,6 @@ class PreviewList extends ScrollView
|
||||
@children().each (index, element) -> $(element).view().expand()
|
||||
|
||||
collapseAllPaths: ->
|
||||
@renderOperations(renderAll: true)
|
||||
@children().each (index, element) -> $(element).view().collapse()
|
||||
|
||||
destroy: ->
|
||||
@@ -50,7 +47,7 @@ class PreviewList extends ScrollView
|
||||
@find('.operation:first').addClass('selected')
|
||||
|
||||
populateSingle: (operation) ->
|
||||
@viewsForPath = {}
|
||||
@viewsForPath ||= {}
|
||||
|
||||
@show()
|
||||
@renderOperation(operation)
|
||||
@@ -66,14 +63,14 @@ class PreviewList extends ScrollView
|
||||
@lastRenderedOperationIndex++
|
||||
break if not renderAll and @prop('scrollHeight') >= startingScrollHeight + @pixelOverdraw and @prop('scrollHeight') > @height() + @pixelOverdraw
|
||||
|
||||
renderOperation: (operation, {renderAll}={}) ->
|
||||
renderAll ?= false
|
||||
renderOperation: (operation) ->
|
||||
startingScrollHeight = @prop('scrollHeight')
|
||||
pathView = @pathViewForPath(operation.getPath())
|
||||
pathView.addOperation(operation)
|
||||
|
||||
pathViewForPath: (path) ->
|
||||
pathView = @viewsForPath[path]
|
||||
console.log(path)
|
||||
if not pathView
|
||||
pathView = new PathView({path: path, previewList: this})
|
||||
@viewsForPath[path] = pathView
|
||||
|
||||
Reference in New Issue
Block a user