[DE] Added the ability to restore version in versions history (need event onRequestRestore and permissions.changeHistory = true in editor config).
This commit is contained in:
parent
02951be6c1
commit
4dc23c41ee
|
@ -216,6 +216,7 @@
|
||||||
extend(_config, DocsAPI.DocEditor.defaultConfig);
|
extend(_config, DocsAPI.DocEditor.defaultConfig);
|
||||||
_config.editorConfig.canUseHistory = _config.events && !!_config.events.onRequestHistory;
|
_config.editorConfig.canUseHistory = _config.events && !!_config.events.onRequestHistory;
|
||||||
_config.editorConfig.canHistoryClose = _config.events && !!_config.events.onRequestHistoryClose;
|
_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.canSendEmailAddresses = _config.events && !!_config.events.onRequestEmailAddresses;
|
||||||
_config.editorConfig.canRequestEditRights = _config.events && !!_config.events.onRequestEditRights;
|
_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() {
|
requestEmailAddresses: function() {
|
||||||
_postMessage({ event: 'onRequestEmailAddresses' });
|
_postMessage({ event: 'onRequestEmailAddresses' });
|
||||||
},
|
},
|
||||||
|
|
|
@ -87,7 +87,18 @@ define([
|
||||||
historyView.btnBackToDocument.on('click', _.bind(this.onClickBackToDocument, this));
|
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'),
|
var url = record.get('url'),
|
||||||
rev = record.get('revision'),
|
rev = record.get('revision'),
|
||||||
urlGetTime = new Date();
|
urlGetTime = new Date();
|
||||||
|
|
|
@ -65,7 +65,8 @@ define([
|
||||||
docId: '',
|
docId: '',
|
||||||
docIdPrev: '',
|
docIdPrev: '',
|
||||||
arrColors: [], // array of user colors for all changes of current version
|
arrColors: [], // array of user colors for all changes of current version
|
||||||
markedAsVersion: false
|
markedAsVersion: false,
|
||||||
|
canRestore: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -81,6 +81,9 @@ define([
|
||||||
'<% if (markedAsVersion) { %>',
|
'<% if (markedAsVersion) { %>',
|
||||||
'<div class="user-version">ver.<%=version%></div>',
|
'<div class="user-version">ver.<%=version%></div>',
|
||||||
'<% } %>',
|
'<% } %>',
|
||||||
|
'<% if (canRestore && selected) { %>',
|
||||||
|
'<div class="revision-restore img-commonctrl"></div>',
|
||||||
|
'<% } %>',
|
||||||
'<div class="user-name">',
|
'<div class="user-name">',
|
||||||
'<div class="color" style="display: inline-block; background-color:' + '<%=usercolor%>;' + '" >',
|
'<div class="color" style="display: inline-block; background-color:' + '<%=usercolor%>;' + '" >',
|
||||||
'</div><%= Common.Utils.String.htmlEncode(username) %>',
|
'</div><%= Common.Utils.String.htmlEncode(username) %>',
|
||||||
|
|
|
@ -102,5 +102,15 @@
|
||||||
margin: 0 5px 3px 0;
|
margin: 0 5px 3px 0;
|
||||||
vertical-align: middle;
|
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) {
|
onRefreshHistory: function(opts) {
|
||||||
this.loadMask && this.loadMask.hide();
|
this.loadMask && this.loadMask.hide();
|
||||||
if (opts.data.error || !opts.data.history) {
|
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,
|
closable: false,
|
||||||
title: this.notcriticalErrorTitle,
|
title: this.notcriticalErrorTitle,
|
||||||
msg: (opts.data.error) ? opts.data.error : this.txtErrorLoadHistory,
|
msg: (opts.data.error) ? opts.data.error : this.txtErrorLoadHistory,
|
||||||
|
@ -353,8 +359,7 @@ define([
|
||||||
callback: _.bind(function(btn){
|
callback: _.bind(function(btn){
|
||||||
this.onEditComplete();
|
this.onEditComplete();
|
||||||
}, this)
|
}, this)
|
||||||
};
|
});
|
||||||
Common.UI.alert(config);
|
|
||||||
} else {
|
} else {
|
||||||
this.api.asc_coAuthoringDisconnect();
|
this.api.asc_coAuthoringDisconnect();
|
||||||
this.getApplication().getController('LeftMenu').getView('LeftMenu').showHistory();
|
this.getApplication().getController('LeftMenu').getView('LeftMenu').showHistory();
|
||||||
|
@ -393,7 +398,8 @@ define([
|
||||||
created: version.created,
|
created: version.created,
|
||||||
docId: version.key,
|
docId: version.key,
|
||||||
markedAsVersion: (group!==version.versionGroup),
|
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) {
|
if (opts.data.currentVersion == version.version) {
|
||||||
currentVersion = arrVersions[arrVersions.length-1];
|
currentVersion = arrVersions[arrVersions.length-1];
|
||||||
|
@ -453,7 +459,7 @@ define([
|
||||||
}
|
}
|
||||||
arrColors = [];
|
arrColors = [];
|
||||||
}
|
}
|
||||||
historyStore[historyStore.size() > 0 ? 'add' : 'reset'](arrVersions);
|
historyStore.reset(arrVersions);
|
||||||
if (currentVersion===null && historyStore.size()>0) {
|
if (currentVersion===null && historyStore.size()>0) {
|
||||||
currentVersion = historyStore.at(0);
|
currentVersion = historyStore.at(0);
|
||||||
currentVersion.set('selected', true);
|
currentVersion.set('selected', true);
|
||||||
|
@ -948,8 +954,9 @@ define([
|
||||||
(!this.appOptions.isReviewOnly || this.appOptions.canLicense); // if isReviewOnly==true -> canLicense must be true
|
(!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.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.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.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.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.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);
|
this.appOptions.canComments = this.appOptions.canLicense && !((typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.comments===false);
|
||||||
|
|
Loading…
Reference in a new issue