[DE] Restore from changes in versions history.

This commit is contained in:
Julia Radzhabova 2016-09-19 10:41:02 +03:00
parent 4dc23c41ee
commit b33f00e0a7
4 changed files with 25 additions and 6 deletions

View file

@ -162,10 +162,11 @@ Common.Gateway = new(function() {
});
},
requestRestore: function(revision) {
requestRestore: function(revision, url) {
_postMessage({
event: 'onRequestRestore',
data: revision
data: revision,
url: url
});
},

View file

@ -72,6 +72,7 @@ define([
setApi: function(api) {
this.api = api;
this.api.asc_registerCallback('asc_onDownloadUrl', _.bind(this.onDownloadUrl, this));
return this;
},
@ -87,11 +88,22 @@ define([
historyView.btnBackToDocument.on('click', _.bind(this.onClickBackToDocument, this));
},
onDownloadUrl: function(url) {
if (this.isFromSelectRevision !== undefined)
Common.Gateway.requestRestore(this.isFromSelectRevision, url);
this.isFromSelectRevision = undefined;
},
onSelectRevision: function(picker, item, record, e) {
if (e) {
var btn = $(e.target);
if (btn && btn.hasClass('revision-restore')) {
Common.Gateway.requestRestore(record.get('revision'));
if (record.get('isRevision'))
Common.Gateway.requestRestore(record.get('revision'));
else {
this.isFromSelectRevision = record.get('revision');
this.api.asc_DownloadAs(Asc.c_oAscFileType.DOCX, true);
}
return;
}
}

View file

@ -66,7 +66,8 @@ define([
docIdPrev: '',
arrColors: [], // array of user colors for all changes of current version
markedAsVersion: false,
canRestore: false
canRestore: false,
isRevision: true
}
}
});

View file

@ -324,6 +324,7 @@ define([
},
onDownloadAs: function() {
this._state.isFromGatewayDownloadAs = true;
var type = /^(?:(pdf|djvu|xps))$/.exec(this.document.fileType);
(type && typeof type[1] === 'string') ? this.api.asc_DownloadOrigin(true) : this.api.asc_DownloadAs(Asc.c_oAscFileType.DOCX, true);
},
@ -443,7 +444,9 @@ define([
created: change.created,
docId: version.key,
docIdPrev: docIdPrev,
selected: false
selected: false,
canRestore: this.appOptions.canHistoryRestore,
isRevision: false
}));
arrColors.push(user.get('colorval'));
}
@ -1425,7 +1428,9 @@ define([
},
onDownloadUrl: function(url) {
Common.Gateway.downloadAs(url);
if (this._state.isFromGatewayDownloadAs)
Common.Gateway.downloadAs(url);
this._state.isFromGatewayDownloadAs = false;
},
onUpdateVersion: function(callback) {