overleaf/services/web/public/coffee/track-changes/models/Change.coffee

26 lines
695 B
CoffeeScript
Raw Normal View History

define [
2014-03-07 11:24:11 +00:00
"models/User"
"libs/backbone"
2014-03-07 11:24:11 +00:00
], (User)->
Change = Backbone.Model.extend
parse: (change) ->
2014-03-11 12:13:46 +00:00
model = {
start_ts: change.meta.start_ts
end_ts: change.meta.end_ts
2014-03-11 12:13:46 +00:00
}
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)
2014-03-11 12:13:46 +00:00
return model