diff --git a/apps/api/documents/api.js b/apps/api/documents/api.js
index d462c2a94..07a5204f0 100644
--- a/apps/api/documents/api.js
+++ b/apps/api/documents/api.js
@@ -216,6 +216,7 @@
extend(_config, DocsAPI.DocEditor.defaultConfig);
_config.editorConfig.canUseHistory = _config.events && !!_config.events.onRequestHistory;
_config.editorConfig.canHistoryClose = _config.events && !!_config.events.onRequestHistoryClose;
+ _config.editorConfig.canHistoryRestore = _config.events && !!_config.events.onRequestRestore;
_config.editorConfig.canSendEmailAddresses = _config.events && !!_config.events.onRequestEmailAddresses;
_config.editorConfig.canRequestEditRights = _config.events && !!_config.events.onRequestEditRights;
diff --git a/apps/common/Gateway.js b/apps/common/Gateway.js
index 8e79aa80a..b46785fa4 100644
--- a/apps/common/Gateway.js
+++ b/apps/common/Gateway.js
@@ -162,6 +162,13 @@ Common.Gateway = new(function() {
});
},
+ requestRestore: function(revision) {
+ _postMessage({
+ event: 'onRequestRestore',
+ data: revision
+ });
+ },
+
requestEmailAddresses: function() {
_postMessage({ event: 'onRequestEmailAddresses' });
},
diff --git a/apps/common/main/lib/controller/History.js b/apps/common/main/lib/controller/History.js
index 334ccab31..ebf163707 100644
--- a/apps/common/main/lib/controller/History.js
+++ b/apps/common/main/lib/controller/History.js
@@ -87,7 +87,18 @@ define([
historyView.btnBackToDocument.on('click', _.bind(this.onClickBackToDocument, this));
},
- onSelectRevision: function(picker, item, record) {
+ onSelectRevision: function(picker, item, record, e) {
+ if (e) {
+ var btn = $(e.target);
+ if (btn && btn.hasClass('revision-restore')) {
+ Common.Gateway.requestRestore(record.get('revision'));
+ return;
+ }
+ }
+
+ if (!picker && record)
+ this.panelHistory.viewHistoryList.scrollToRecord(record);
+
var url = record.get('url'),
rev = record.get('revision'),
urlGetTime = new Date();
diff --git a/apps/common/main/lib/model/HistoryVersion.js b/apps/common/main/lib/model/HistoryVersion.js
index 2b3fff5aa..2007f459b 100644
--- a/apps/common/main/lib/model/HistoryVersion.js
+++ b/apps/common/main/lib/model/HistoryVersion.js
@@ -65,7 +65,8 @@ define([
docId: '',
docIdPrev: '',
arrColors: [], // array of user colors for all changes of current version
- markedAsVersion: false
+ markedAsVersion: false,
+ canRestore: false
}
}
});
diff --git a/apps/common/main/lib/view/History.js b/apps/common/main/lib/view/History.js
index 698bb7b11..79dee0894 100644
--- a/apps/common/main/lib/view/History.js
+++ b/apps/common/main/lib/view/History.js
@@ -81,6 +81,9 @@ define([
'<% if (markedAsVersion) { %>',
'
ver.<%=version%>
',
'<% } %>',
+ '<% if (canRestore && selected) { %>',
+ '',
+ '<% } %>',
'',
'
',
'
<%= Common.Utils.String.htmlEncode(username) %>',
diff --git a/apps/common/main/resources/less/history.less b/apps/common/main/resources/less/history.less
index 65f39d50e..477a3df1d 100644
--- a/apps/common/main/resources/less/history.less
+++ b/apps/common/main/resources/less/history.less
@@ -102,5 +102,15 @@
margin: 0 5px 3px 0;
vertical-align: middle;
}
+
+ .revision-restore {
+ width: 16px;
+ height: 16px;
+ background-position: -22px -272px;
+ margin: 0 12px;
+ display: inline-block;
+ position: absolute;
+ right: 0;
+ }
}
}
diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js
index 1d4fc664d..4bf6cbecd 100644
--- a/apps/documenteditor/main/app/controller/Main.js
+++ b/apps/documenteditor/main/app/controller/Main.js
@@ -344,7 +344,13 @@ define([
onRefreshHistory: function(opts) {
this.loadMask && this.loadMask.hide();
if (opts.data.error || !opts.data.history) {
- var config = {
+ var historyStore = this.getApplication().getCollection('Common.Collections.HistoryVersions');
+ if (historyStore && historyStore.size()>0) {
+ historyStore.each(function(item){
+ item.set('canRestore', false);
+ });
+ }
+ Common.UI.alert({
closable: false,
title: this.notcriticalErrorTitle,
msg: (opts.data.error) ? opts.data.error : this.txtErrorLoadHistory,
@@ -353,8 +359,7 @@ define([
callback: _.bind(function(btn){
this.onEditComplete();
}, this)
- };
- Common.UI.alert(config);
+ });
} else {
this.api.asc_coAuthoringDisconnect();
this.getApplication().getController('LeftMenu').getView('LeftMenu').showHistory();
@@ -393,7 +398,8 @@ define([
created: version.created,
docId: version.key,
markedAsVersion: (group!==version.versionGroup),
- selected: (opts.data.currentVersion == version.version)
+ selected: (opts.data.currentVersion == version.version),
+ canRestore: this.appOptions.canHistoryRestore
}));
if (opts.data.currentVersion == version.version) {
currentVersion = arrVersions[arrVersions.length-1];
@@ -453,7 +459,7 @@ define([
}
arrColors = [];
}
- historyStore[historyStore.size() > 0 ? 'add' : 'reset'](arrVersions);
+ historyStore.reset(arrVersions);
if (currentVersion===null && historyStore.size()>0) {
currentVersion = historyStore.at(0);
currentVersion.set('selected', true);
@@ -948,8 +954,9 @@ define([
(!this.appOptions.isReviewOnly || this.appOptions.canLicense); // if isReviewOnly==true -> canLicense must be true
this.appOptions.isEdit = this.appOptions.canLicense && this.appOptions.canEdit && this.editorConfig.mode !== 'view';
this.appOptions.canReview = this.appOptions.canLicense && this.appOptions.isEdit && (this.permissions.review===true);
- this.appOptions.canUseHistory = this.appOptions.canLicense && !this.appOptions.isLightVersion && this.editorConfig.canUseHistory && (this.permissions.edit !== false) && this.appOptions.canCoAuthoring && !this.appOptions.isDesktopApp;
+ this.appOptions.canUseHistory = this.appOptions.canLicense && !this.appOptions.isLightVersion && this.editorConfig.canUseHistory && this.appOptions.canCoAuthoring && !this.appOptions.isDesktopApp;
this.appOptions.canHistoryClose = this.editorConfig.canHistoryClose;
+ this.appOptions.canHistoryRestore= this.editorConfig.canHistoryRestore && !!this.permissions.changeHistory;
this.appOptions.canUseMailMerge= this.appOptions.canLicense && this.appOptions.canEdit && !this.appOptions.isDesktopApp;
this.appOptions.canSendEmailAddresses = this.appOptions.canLicense && this.editorConfig.canSendEmailAddresses && this.appOptions.canEdit && this.appOptions.canCoAuthoring;
this.appOptions.canComments = this.appOptions.canLicense && !((typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.comments===false);