2014-03-05 12:55:47 -05:00
|
|
|
define [
|
|
|
|
"track-changes/models/Change"
|
|
|
|
"libs/backbone"
|
|
|
|
], (Change)->
|
|
|
|
ChangeList = Backbone.Collection.extend
|
|
|
|
model: Change
|
2014-03-07 08:31:30 -05:00
|
|
|
batchSize: 25
|
2014-03-05 12:55:47 -05:00
|
|
|
|
|
|
|
initialize: (models, @options) ->
|
|
|
|
|
|
|
|
url: () ->
|
|
|
|
url = "/project/#{@options.project_id}/doc/#{@options.doc_id}/updates?limit=#{@batchSize}"
|
|
|
|
if @models.length > 0
|
|
|
|
last = @models[@models.length - 1]
|
2014-03-06 09:08:12 -05:00
|
|
|
url += "&to=#{last.get("version") - 1}"
|
2014-03-05 12:55:47 -05:00
|
|
|
return url
|
|
|
|
|
|
|
|
parse: (json) ->
|
|
|
|
return json.updates
|
|
|
|
|
|
|
|
fetchNextBatch: (options = {}) ->
|
|
|
|
options.add = true
|
|
|
|
@fetch options
|
|
|
|
|
|
|
|
|