Change aggregated change model: the main change is now the insertion, deletion is stored in metadata.

This commit is contained in:
Paulo Reis 2017-06-01 15:03:37 +01:00
parent 11c0644490
commit 1490ea7b04
2 changed files with 18 additions and 11 deletions

View file

@ -261,9 +261,9 @@ script(type='text/ng-template', id='aggregateChangeEntryTemplate')
.rp-entry-details
.rp-entry-description
| Changed
del.rp-content-highlight {{ entry.content }}
del.rp-content-highlight {{ entry.metadata.agg_op.content }}
| for
ins.rp-content-highlight {{ entry.metadata.agg_op.content }}
ins.rp-content-highlight {{ entry.content }}
a.rp-collapse-toggle(
href
ng-if="needsCollapsing"

View file

@ -26,7 +26,12 @@ define [
resolvedThreadIds: {}
rendererData: {}
loadingThreads: false
selectedEntryIds: []
# All selected changes. If a aggregated change (insertion + deletion) is selection, the two ids
# will be present. The length of this array will differ from the count below (see explanation).
selectedEntryIds: []
# A count of user-facing selected changes. An aggregated change (insertion + deletion) will count
# as only one.
nVisibleSelectedChanges: 0
window.addEventListener "beforeunload", () ->
collapsedStates = {}
@ -254,13 +259,12 @@ define [
}
if aggregate_entry
new_entry.type = "agg-change"
new_entry.metadata.agg_op = entries[prev_insertion.id]
new_entry.metadata.agg_op_id = prev_insertion.id
delete entries[prev_insertion.id]
for key, value of new_entry
entries[change.id][key] = value
entries[prev_insertion.id].type = "agg-change"
entries[prev_insertion.id].metadata.agg_op = new_entry
entries[prev_insertion.id].metadata.agg_op_id = change.id
else
for key, value of new_entry
entries[change.id][key] = value
if change.op.i
potential_aggregate = true
@ -314,8 +318,11 @@ define [
$scope.$on "editor:focus:changed", (e, selection_offset_start, selection_offset_end, selection) ->
doc_id = $scope.editor.open_doc_id
entries = getDocEntries(doc_id)
# All selected changes will be added to this array.
$scope.reviewPanel.selectedEntryIds = []
# Count of user-visible changes, i.e. an aggregated change will count as one.
$scope.nVisibleSelectedChanges = 0
console.log selection_offset_start, selection_offset_end
delete entries["add-comment"]
delete entries["bulk-actions"]