Merge pull request #19499 from owncloud/files-versions-properlyreloadafterrevert

Reload versions list after revert
This commit is contained in:
Thomas Müller 2015-10-02 12:16:10 +02:00
commit 2912d0e3e3
2 changed files with 13 additions and 2 deletions

View File

@ -67,6 +67,11 @@
return this.fetch({remove: false});
},
reset: function() {
this._currentIndex = 0;
OC.Backbone.Collection.prototype.reset.apply(this, arguments);
},
parse: function(result) {
var results = _.map(result.data.versions, function(version) {
var revision = parseInt(version.version, 10);

View File

@ -85,12 +85,18 @@
ev.preventDefault();
revision = $target.attr('data-revision');
this.$el.find('.versions, .showMoreVersions').addClass('hidden');
var versionModel = this.collection.get(revision);
versionModel.revert({
success: function() {
// reset and re-fetch the updated collection
self.$versionsContainer.empty();
self.collection.setFileInfo(fileInfoModel);
self.collection.fetch();
self.collection.reset([], {silent: true});
self.collection.fetchNext();
self.$el.find('.versions').removeClass('hidden');
// update original model
fileInfoModel.trigger('busy', fileInfoModel, false);
@ -157,7 +163,7 @@
if (fileInfo) {
this.render();
this.collection.setFileInfo(fileInfo);
this.collection.reset({silent: true});
this.collection.reset([], {silent: true});
this.nextPage();
} else {
this.render();