Commit 4dc23c41 authored by Julia Radzhabova's avatar Julia Radzhabova

[DE] Added the ability to restore version in versions history (need event...

[DE] Added the ability to restore version in versions history (need event onRequestRestore and permissions.changeHistory = true in editor config).
parent 02951be6
......@@ -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;
......
......@@ -162,6 +162,13 @@ Common.Gateway = new(function() {
});
},
requestRestore: function(revision) {
_postMessage({
event: 'onRequestRestore',
data: revision
});
},
requestEmailAddresses: function() {
_postMessage({ event: 'onRequestEmailAddresses' });
},
......
......@@ -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();
......
......@@ -65,7 +65,8 @@ define([
docId: '',
docIdPrev: '',
arrColors: [], // array of user colors for all changes of current version
markedAsVersion: false
markedAsVersion: false,
canRestore: false
}
}
});
......
......@@ -81,6 +81,9 @@ define([
'<% if (markedAsVersion) { %>',
'<div class="user-version">ver.<%=version%></div>',
'<% } %>',
'<% if (canRestore && selected) { %>',
'<div class="revision-restore img-commonctrl"></div>',
'<% } %>',
'<div class="user-name">',
'<div class="color" style="display: inline-block; background-color:' + '<%=usercolor%>;' + '" >',
'</div><%= Common.Utils.String.htmlEncode(username) %>',
......
......@@ -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;
}
}
}
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment