Merge remote-tracking branch 'remotes/origin/develop' into refactoring/java-spring-dto

This commit is contained in:
Aleksandr Fedorov
2023-09-07 10:26:03 +03:00
12 changed files with 465 additions and 203 deletions

View File

@ -172,6 +172,36 @@
}
};
var onRequestHistory = function () {
var xhr = new XMLHttpRequest();
xhr.open("GET", "history?fileName=" + config.document.title, false);
xhr.send();
if (xhr.status == 200) {
var historyInfo = JSON.parse(xhr.responseText);
docEditor.refreshHistory(historyInfo);
}
};
var onRequestHistoryData = function (event) {
var version = event.data;
var historyDataUri = "historydata?fileName=" + config.document.title
+ "&version=" + version
+ "&directUrl=" + !!config.document.directUrl;
var xhr = new XMLHttpRequest();
xhr.open("GET", historyDataUri, false);
xhr.send();
if (xhr.status == 200) {
var historyData = JSON.parse(xhr.responseText);
docEditor.setHistoryData(historyData);
}
};
var onRequestHistoryClose = function() {
document.location.reload();
};
function onRequestRestore(event) {
const query = new URLSearchParams(window.location.search)
const payload = {
@ -183,12 +213,20 @@
request.setRequestHeader('Content-Type', 'application/json')
request.send(JSON.stringify(payload))
request.onload = function () {
if (request.status != 200) {
response = JSON.parse(request.response)
innerAlert(response.error)
return
const response = JSON.parse(request.responseText);
if (response.success && !response.error) {
var historyInfoUri = "history?fileName=" + config.document.title;
var xhr = new XMLHttpRequest();
xhr.open("GET", historyInfoUri, false);
xhr.send();
if (xhr.status == 200) {
var historyInfo = JSON.parse(xhr.responseText);
docEditor.refreshHistory(historyInfo);
}
} else {
innerAlert(response.error);
}
document.location.reload()
}
}
@ -204,31 +242,15 @@
"onRequestInsertImage": onRequestInsertImage,
"onRequestCompareFile": onRequestCompareFile,
"onRequestMailMergeRecipients": onRequestMailMergeRecipients,
"onRequestRestore": onRequestRestore
"onRequestRestore": onRequestRestore,
"onRequestHistory": onRequestHistory,
"onRequestHistoryData": onRequestHistoryData,
"onRequestHistoryClose": onRequestHistoryClose
};
var histArray = [[${fileHistory}]];
var hist = histArray[0];
var historyData = histArray[1];
var usersForMentions = [[${usersForMentions}]];
if (config.editorConfig.user.id != 4) {
if (hist && historyData) {
// the user is trying to show the document version history
config.events['onRequestHistory'] = function () {
docEditor.refreshHistory(JSON.parse(hist)); // show the document version history
};
// the user is trying to click the specific document version in the document version history
config.events['onRequestHistoryData'] = function (event) {
var ver = event.data;
var histData = historyData;
docEditor.setHistoryData(JSON.parse(histData)[ver - 1]); // send the link to the document for viewing the version history
};
// the user is trying to go back to the document from viewing the document version history
config.events['onRequestHistoryClose'] = function () {
document.location.reload();
};
}
// add mentions for not anonymous users
config.events['onRequestUsers'] = function () {
docEditor.setUsers({ // set a list of users to mention in the comments