Keep files ordered in overview panel in the same was as the file tree

This commit is contained in:
James Allen 2016-12-09 16:17:28 +00:00
parent 293ba1fc4c
commit 0a6a6c3c28
5 changed files with 22 additions and 13 deletions

View file

@ -52,13 +52,15 @@
.rp-overview-loading(ng-if="reviewPanel.overview.loading")
i.fa.fa-spinner.fa-spin
.rp-overview-file(
ng-repeat="(doc_id, entries) in reviewPanel.entries"
ng-repeat="doc in docs"
ng-if="!reviewPanel.overview.loading"
)
.rp-overview-file-header
| {{ getFileName(doc_id) }}
.rp-overview-file-header(
ng-if="reviewPanel.entries[doc.doc.id] | notEmpty"
)
| {{ doc.path }}
.rp-entry-wrapper(
ng-repeat="(entry_id, entry) in entries | orderOverviewEntries"
ng-repeat="(entry_id, entry) in reviewPanel.entries[doc.doc.id] | orderOverviewEntries"
)
div(ng-if="entry.type === 'insert' || entry.type === 'delete'")
change-entry(

View file

@ -275,6 +275,16 @@ define [
doc: entity
path: path
}
# Keep list ordered by folders, then name
@$scope.docs.sort (a,b) ->
aDepth = (a.path.match(/\//g) || []).length
bDepth = (b.path.match(/\//g) || []).length
if aDepth - bDepth != 0
return -(aDepth - bDepth) # Deeper path == folder first
else if a.path < b.path
return -1
else
return 1
getEntityPath: (entity) ->
@_getEntityPathInFolder @$scope.rootFolder, entity

View file

@ -5,5 +5,6 @@ define [
"ide/review-panel/directives/changeEntry"
"ide/review-panel/directives/commentEntry"
"ide/review-panel/directives/addCommentEntry"
"ide/review-panel/filters/notEmpty"
"ide/review-panel/filters/orderOverviewEntries"
], () ->

View file

@ -354,15 +354,6 @@ define [
$scope.gotoEntry = (doc_id, entry) ->
ide.editorManager.openDocId(doc_id, { gotoOffset: entry.offset })
DOC_ID_NAMES = {}
$scope.getFileName = (doc_id) ->
# This is called a lot and is relatively expensive, so cache the result
if !DOC_ID_NAMES[doc_id]?
entity = ide.fileTreeManager.findEntityById(doc_id)
return if !entity?
DOC_ID_NAMES[doc_id] = ide.fileTreeManager.getEntityPath(entity)
return DOC_ID_NAMES[doc_id]
# TODO: Eventually we need to get this from the server, and update it
# when we get an id we don't know. This'll do for client side testing
refreshUsers = () ->

View file

@ -0,0 +1,5 @@
define [
"base"
], (App) ->
app.filter 'notEmpty', () ->
(object) -> !angular.equals({}, object)