Commit dd9aa4db authored by Samir Sadyhov's avatar Samir Sadyhov 🤔

openDocument.js - добавлено просмотр и актуализация версии данных по форме

parent 097c4429
const getDialogParam = () => {
const minWidth = 500;
const minHeight = 200;
const maxWidth = $(document).width() * 0.9;
const maxHeight = $(document).height() * 0.9;
const width = $(document).width() * 0.8;
const height = $(document).height() * 0.8;
return {minWidth, minHeight, maxWidth, maxHeight, width, height};
}
const createDialog = (dialogTitle, body) => {
const {minWidth, minHeight, maxWidth, maxHeight, width, height} = getDialogParam();
const dialog = $('<div>');
dialog.dialog({
modal: true,
title: dialogTitle,
width: width,
height: height,
minWidth: minWidth,
minHeight: minHeight,
maxWidth: maxWidth,
maxHeight: maxHeight,
resizable: true,
show: {effect: 'fade', duration: 300},
hide: {effect: 'fade', duration: 300}
});
dialog.on('dialogclose', () => {
dialog.remove();
});
dialog.append(body);
return dialog;
}
const getFileModels = player => {
const result = [];
player.model.models[0].modelBlocks[0].forEach(block => {
......@@ -1393,15 +1431,58 @@ class ARMDocument {
const lastTd = $('<td>');
const buttonViewVersion = $('<button>', {class: 'uk-button uk-button-default uk-button-small button-switch pressed'});
const buttonDownloadVersion = $('<button>', {class: 'uk-button uk-button-default uk-button-small button-switch pressed'});
const buttonSetVersionCurrent = $('<button>', {class: 'uk-button uk-button-default uk-button-small button-switch pressed'});
buttonViewVersion.text(i18n.tr('Просмотр'));
buttonDownloadVersion.text(i18n.tr('Скачать'));
buttonSetVersionCurrent.text(i18n.tr('Сделать актуальной'));
buttonViewVersion.on('click', async e => {
e.preventDefault();
e.target.blur();
const versionAsfData = await appAPI.getFile(item.identifier, 'json');
const versionFormPlayer = UTILS.getSynergyPlayer(versionAsfData.uuid, false, versionAsfData.version);
createDialog(i18n.tr('Просмотр'), versionFormPlayer.view.container);
});
buttonDownloadVersion.on('click', e => {
e.preventDefault();
e.target.blur();
UTILS.fileDownload(`${fullName}.asfdocx`, item.identifier);
});
lastTd.append(buttonDownloadVersion);
buttonSetVersionCurrent.on('click', async e => {
e.preventDefault();
e.target.blur();
Cons.showLoader();
try {
const versionAsfData = await appAPI.getFile(item.identifier, 'json');
const newAsfData = versionAsfData.data.filter(x => x.type != 'label');
const mergeResult = await appAPI.mergeFormData({
uuid: this._doc.dataUUID,
data: newAsfData
});
if(!mergeResult) throw new Error('Произошла ошибка актуализации версии данных');
if(mergeResult.errorCode != 0 && mergeResult.hasOwnProperty('errorMessage')) throw new Error(mergeResult.errorMessage);
this._doc.formPlayer.showFormData(null, null, this._doc.dataUUID, null);
const table = await this.getFileVersions();
this._doc.panels.formVersionContent.empty().append(table);
Cons.hideLoader();
} catch (err) {
Cons.hideLoader();
UIkit.notification.closeAll();
showMessage(i18n.tr(err.message), 'error');
}
});
lastTd.append(buttonViewVersion, buttonDownloadVersion, buttonSetVersionCurrent);
tr.append(lastTd);
});
}
......@@ -1420,6 +1501,8 @@ class ARMDocument {
const table = await this.getFileVersions();
content.append(table);
this._doc.panels.formVersionContent = content;
return {container, button, content};
}
......
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