|
@@ -22,8 +22,7 @@ define [
|
|
|
|
|
|
|
|
@$scope.$on "entity:selected", (event, entity) =>
|
|
@$scope.$on "entity:selected", (event, entity) =>
|
|
|
if (@$scope.ui.view == "history") and (entity.type == "doc")
|
|
if (@$scope.ui.view == "history") and (entity.type == "doc")
|
|
|
- # TODO: Set selection.pathname to entity path name
|
|
|
|
|
- # @$scope.history.selection.doc = entity
|
|
|
|
|
|
|
+ @$scope.history.selection.pathname = _ide.fileTreeManager.getEntityPath(entity)
|
|
|
@reloadDiff()
|
|
@reloadDiff()
|
|
|
|
|
|
|
|
show: () ->
|
|
show: () ->
|
|
@@ -43,7 +42,7 @@ define [
|
|
|
atEnd: false
|
|
atEnd: false
|
|
|
selection: {
|
|
selection: {
|
|
|
updates: []
|
|
updates: []
|
|
|
- doc: null
|
|
|
|
|
|
|
+ pathname: null
|
|
|
range: {
|
|
range: {
|
|
|
fromV: null
|
|
fromV: null
|
|
|
toV: null
|
|
toV: null
|
|
@@ -52,6 +51,7 @@ define [
|
|
|
diff: null
|
|
diff: null
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ MAX_RECENT_UPDATES_TO_SELECT: 2
|
|
|
autoSelectRecentUpdates: () ->
|
|
autoSelectRecentUpdates: () ->
|
|
|
return if @$scope.history.updates.length == 0
|
|
return if @$scope.history.updates.length == 0
|
|
|
|
|
|
|
@@ -59,7 +59,7 @@ define [
|
|
|
|
|
|
|
|
indexOfLastUpdateNotByMe = 0
|
|
indexOfLastUpdateNotByMe = 0
|
|
|
for update, i in @$scope.history.updates
|
|
for update, i in @$scope.history.updates
|
|
|
- if @_updateContainsUserId(update, @$scope.user.id)
|
|
|
|
|
|
|
+ if @_updateContainsUserId(update, @$scope.user.id) or i > @MAX_RECENT_UPDATES_TO_SELECT
|
|
|
break
|
|
break
|
|
|
indexOfLastUpdateNotByMe = i
|
|
indexOfLastUpdateNotByMe = i
|
|
|
|
|
|
|
@@ -75,7 +75,6 @@ define [
|
|
|
.get(url)
|
|
.get(url)
|
|
|
.then (response) =>
|
|
.then (response) =>
|
|
|
{ data } = response
|
|
{ data } = response
|
|
|
- console.log "fetchNextBatchOfUpdates", data.updates
|
|
|
|
|
@_loadUpdates(data.updates)
|
|
@_loadUpdates(data.updates)
|
|
|
@$scope.history.nextBeforeTimestamp = data.nextBeforeTimestamp
|
|
@$scope.history.nextBeforeTimestamp = data.nextBeforeTimestamp
|
|
|
if !data.nextBeforeTimestamp?
|
|
if !data.nextBeforeTimestamp?
|
|
@@ -86,10 +85,10 @@ define [
|
|
|
diff = @$scope.history.diff
|
|
diff = @$scope.history.diff
|
|
|
{updates} = @$scope.history.selection
|
|
{updates} = @$scope.history.selection
|
|
|
{fromV, toV, pathname} = @_calculateDiffDataFromSelection()
|
|
{fromV, toV, pathname} = @_calculateDiffDataFromSelection()
|
|
|
- console.log "[reloadDiff] current diff", diff
|
|
|
|
|
- console.log "[reloadDiff] new diff data", {fromV, toV, pathname}
|
|
|
|
|
|
|
|
|
|
- return if !pathname?
|
|
|
|
|
|
|
+ if !pathname?
|
|
|
|
|
+ @$scope.history.diff = null
|
|
|
|
|
+ return
|
|
|
|
|
|
|
|
return if diff? and
|
|
return if diff? and
|
|
|
diff.pathname == pathname and
|
|
diff.pathname == pathname and
|
|
@@ -103,32 +102,24 @@ define [
|
|
|
error: false
|
|
error: false
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- # TODO: How do we track deleted files now? We can probably show the diffs easily
|
|
|
|
|
- # with the new system!
|
|
|
|
|
- if true # !doc.deleted
|
|
|
|
|
- diff.loading = true
|
|
|
|
|
- url = "/project/#{@$scope.project_id}/diff"
|
|
|
|
|
- query = ["pathname=#{encodeURIComponent(pathname)}"]
|
|
|
|
|
- if diff.fromV? and diff.toV?
|
|
|
|
|
- query.push "from=#{diff.fromV}", "to=#{diff.toV}"
|
|
|
|
|
- url += "?" + query.join("&")
|
|
|
|
|
-
|
|
|
|
|
- @ide.$http
|
|
|
|
|
- .get(url)
|
|
|
|
|
- .then (response) =>
|
|
|
|
|
- { data } = response
|
|
|
|
|
- diff.loading = false
|
|
|
|
|
- {text, highlights} = @_parseDiff(data)
|
|
|
|
|
- diff.text = text
|
|
|
|
|
- diff.highlights = highlights
|
|
|
|
|
- .catch () ->
|
|
|
|
|
- diff.loading = false
|
|
|
|
|
- diff.error = true
|
|
|
|
|
- else
|
|
|
|
|
- diff.deleted = true
|
|
|
|
|
- diff.restoreInProgress = false
|
|
|
|
|
- diff.restoreDeletedSuccess = false
|
|
|
|
|
- diff.restoredDocNewId = null
|
|
|
|
|
|
|
+ diff.loading = true
|
|
|
|
|
+ url = "/project/#{@$scope.project_id}/diff"
|
|
|
|
|
+ query = ["pathname=#{encodeURIComponent(pathname)}"]
|
|
|
|
|
+ if diff.fromV? and diff.toV?
|
|
|
|
|
+ query.push "from=#{diff.fromV}", "to=#{diff.toV}"
|
|
|
|
|
+ url += "?" + query.join("&")
|
|
|
|
|
+
|
|
|
|
|
+ @ide.$http
|
|
|
|
|
+ .get(url)
|
|
|
|
|
+ .then (response) =>
|
|
|
|
|
+ { data } = response
|
|
|
|
|
+ diff.loading = false
|
|
|
|
|
+ {text, highlights} = @_parseDiff(data)
|
|
|
|
|
+ diff.text = text
|
|
|
|
|
+ diff.highlights = highlights
|
|
|
|
|
+ .catch () ->
|
|
|
|
|
+ diff.loading = false
|
|
|
|
|
+ diff.error = true
|
|
|
|
|
|
|
|
_parseDiff: (diff) ->
|
|
_parseDiff: (diff) ->
|
|
|
row = 0
|
|
row = 0
|
|
@@ -255,14 +246,12 @@ define [
|
|
|
|
|
|
|
|
selected_pathname = @$scope.history.selection.pathname
|
|
selected_pathname = @$scope.history.selection.pathname
|
|
|
|
|
|
|
|
- console.log "[_calculateDiffDataFromSelection]", @$scope.history.selection.updates
|
|
|
|
|
for pathname, doc of @_perDocSummaryOfUpdates(@$scope.history.selection.updates)
|
|
for pathname, doc of @_perDocSummaryOfUpdates(@$scope.history.selection.updates)
|
|
|
- console.log "[_calculateDiffDataFromSelection] doc:", pathname, doc
|
|
|
|
|
if pathname == selected_pathname
|
|
if pathname == selected_pathname
|
|
|
{fromV, toV} = doc
|
|
{fromV, toV} = doc
|
|
|
- break
|
|
|
|
|
|
|
+ return {fromV, toV, pathname}
|
|
|
|
|
|
|
|
- return {fromV, toV, pathname}
|
|
|
|
|
|
|
+ return {}
|
|
|
|
|
|
|
|
# Set the track changes selected doc to one of the docs in the range
|
|
# Set the track changes selected doc to one of the docs in the range
|
|
|
# of currently selected updates. If we already have a selected doc
|
|
# of currently selected updates. If we already have a selected doc
|