mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-11 10:34:06 +00:00
Load entire project history into change list view
This commit is contained in:
parent
04bdde4d0d
commit
c0686b6592
7 changed files with 45 additions and 14 deletions
|
@ -124,7 +124,7 @@ module.exports = class Router
|
|||
app.get '/Project/:Project_id/version', SecutiryManager.requestCanAccessProject, versioningController.listVersions
|
||||
app.get '/Project/:Project_id/version/:Version_id', SecutiryManager.requestCanAccessProject, versioningController.getVersion
|
||||
|
||||
app.get "/project/:Project_id/doc/:doc_id/updates", SecutiryManager.requestCanAccessProject, TrackChangesController.proxyToTrackChangesApi
|
||||
app.get "/project/:Project_id/updates", SecutiryManager.requestCanAccessProject, TrackChangesController.proxyToTrackChangesApi
|
||||
app.get "/project/:Project_id/doc/:doc_id/diff", SecutiryManager.requestCanAccessProject, TrackChangesController.proxyToTrackChangesApi
|
||||
app.post "/project/:Project_id/doc/:doc_id/version/:version_id/restore", SecutiryManager.requestCanAccessProject, TrackChangesController.proxyToTrackChangesApi
|
||||
|
||||
|
|
|
@ -443,7 +443,8 @@
|
|||
input(type="radio",name="toVersion").change-selector-to
|
||||
|
||||
div(class='change-description')
|
||||
div(class='change-date') {{date}}
|
||||
div.changed-docs {{docs}}
|
||||
div.change-date {{date}}
|
||||
div {{{users}}}
|
||||
|
||||
div(class='restore')
|
||||
|
|
|
@ -131,12 +131,12 @@ define [
|
|||
callback(error)
|
||||
success: (collection, response) =>
|
||||
@hideLoading()
|
||||
if response.updates.length == @collection.batchSize
|
||||
@loadUntilFull(callback)
|
||||
else
|
||||
if @collection.isAtEnd()
|
||||
@atEndOfCollection = true
|
||||
@showEmptyMessageIfCollectionEmpty()
|
||||
callback()
|
||||
else
|
||||
@loadUntilFull(callback)
|
||||
|
||||
else
|
||||
callback() if callback?
|
||||
|
@ -189,9 +189,16 @@ define [
|
|||
hue: user.hue()
|
||||
name: user.name()
|
||||
}
|
||||
docNames = []
|
||||
for doc in @model.get("docs")
|
||||
if doc.entity?
|
||||
docNames.push doc.entity.get("name")
|
||||
else
|
||||
docNames.push "deleted"
|
||||
data = {
|
||||
date: moment(parseInt(@model.get("end_ts"), 10)).calendar()
|
||||
users: userHtml.join("")
|
||||
docs: docNames.join(", ")
|
||||
}
|
||||
|
||||
@$el.html Mustache.to_html(@templates.item, data)
|
||||
|
|
|
@ -39,7 +39,7 @@ define [
|
|||
show: (@doc_id) ->
|
||||
@ide.fileTreeManager.selectEntity(@doc_id)
|
||||
|
||||
@changes = new ChangeList([], doc_id: @doc_id, project_id: @project_id)
|
||||
@changes = new ChangeList([], project_id: @project_id, ide: @ide)
|
||||
|
||||
@changeListView = new ChangeListView(
|
||||
collection : @changes,
|
||||
|
|
|
@ -7,12 +7,20 @@ define [
|
|||
model = {
|
||||
start_ts: change.meta.start_ts
|
||||
end_ts: change.meta.end_ts
|
||||
fromVersion: change.fromV
|
||||
toVersion: change.toV
|
||||
}
|
||||
model.users = []
|
||||
for user in change.meta.users or []
|
||||
model.users.push User.findOrBuild(user.id, user)
|
||||
if model.users.length == 0
|
||||
model.users.push User.getAnonymousUser()
|
||||
model.docs = []
|
||||
for doc_id, data of change.docs
|
||||
model.docs.push
|
||||
id: doc_id
|
||||
fromV: data.fromV
|
||||
toV: data.toV
|
||||
# TODO: We should not use a global reference here, but
|
||||
# it's hard to get @ide into Backbone at this point.
|
||||
entity: ide.fileTreeManager.getEntity(doc_id)
|
||||
|
||||
return model
|
|
@ -4,21 +4,29 @@ define [
|
|||
], (Change)->
|
||||
ChangeList = Backbone.Collection.extend
|
||||
model: Change
|
||||
batchSize: 25
|
||||
batchSize: 10
|
||||
|
||||
initialize: (models, @options) ->
|
||||
@ide = @options.ide
|
||||
@atEnd = false
|
||||
|
||||
url: () ->
|
||||
url = "/project/#{@options.project_id}/doc/#{@options.doc_id}/updates?limit=#{@batchSize}"
|
||||
if @models.length > 0
|
||||
last = @models[@models.length - 1]
|
||||
url += "&to=#{last.get("fromVersion") - 1}"
|
||||
url = "/project/#{@options.project_id}/updates?min_count=#{@batchSize}"
|
||||
if @nextBeforeTimestamp?
|
||||
url += "&before=#{@nextBeforeTimestamp}"
|
||||
return url
|
||||
|
||||
isAtEnd: () -> @atEnd
|
||||
|
||||
parse: (json) ->
|
||||
@nextBeforeTimestamp = json.nextBeforeTimestamp
|
||||
@atEnd = !@nextBeforeTimestamp
|
||||
return json.updates
|
||||
|
||||
fetchNextBatch: (options = {}) ->
|
||||
if @isAtEnd()
|
||||
options.success?(@)
|
||||
return
|
||||
options.add = true
|
||||
@fetch options
|
||||
|
||||
|
|
|
@ -126,10 +126,14 @@
|
|||
min-height: 38px;
|
||||
}
|
||||
.change-name {
|
||||
font-size: 0.9em;
|
||||
font-size: 11px;
|
||||
color: #666;
|
||||
text-transform: capitalize;
|
||||
}
|
||||
.change-date {
|
||||
margin-top: 2px;
|
||||
font-size: 12px;
|
||||
}
|
||||
.color-square {
|
||||
display: inline-block;
|
||||
height: 10px;
|
||||
|
@ -137,6 +141,9 @@
|
|||
margin-right: 4px;
|
||||
margin-bottom: -1px;
|
||||
}
|
||||
.changed-docs {
|
||||
font-weight: bold;
|
||||
}
|
||||
.restore {
|
||||
a {
|
||||
display: block;
|
||||
|
|
Loading…
Add table
Reference in a new issue