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

openDocument - открыте реглинков

parent 1393fd51
...@@ -69,25 +69,31 @@ const canEditFile = async (documentID) => { ...@@ -69,25 +69,31 @@ const canEditFile = async (documentID) => {
}); });
} }
const getFileModels = player => { const filteredModels = player => {
const result = []; const fileModels = [];
const reglinkModels = [];
player.model.models[0].modelBlocks[0].forEach(block => { player.model.models[0].modelBlocks[0].forEach(block => {
if(block.asfProperty.type === "file") result.push(block); if(block.asfProperty.type === "file") fileModels.push(block);
if(block.asfProperty.type === "reglink") reglinkModels.push(block);
if(block.asfProperty.type === "table") { if(block.asfProperty.type === "table") {
if(block.modelBlocks.length > 0) { if(block.modelBlocks.length > 0) {
block.modelBlocks.forEach(row => { block.modelBlocks.forEach(row => {
row.forEach(tableBlock => { row.forEach(tableBlock => {
if(tableBlock.asfProperty.type === "file") result.push(tableBlock); if(tableBlock.asfProperty.type === "file") fileModels.push(tableBlock);
if(tableBlock.asfProperty.type === "reglink") reglinkModels.push(tableBlock);
}); });
}); });
} }
} }
}); });
return result;
return {fileModels, reglinkModels};
} }
const initOpenFilesInForm = player => { const overrideComponentMethods = player => {
const fileModels = getFileModels(player); const {fileModels, reglinkModels} = filteredModels(player);
fileModels.forEach(fileModel => { fileModels.forEach(fileModel => {
const props = fileModel.asfProperty; const props = fileModel.asfProperty;
...@@ -111,7 +117,33 @@ const initOpenFilesInForm = player => { ...@@ -111,7 +117,33 @@ const initOpenFilesInForm = player => {
file.open(); file.open();
}); });
} }
});
reglinkModels.forEach(reglinkModel => {
const props = reglinkModel.asfProperty;
const tmpView = player.view.getViewWithId(props.id, props.ownerTableId, props.tableBlockIndex);
//отключаем все стандартные события
setTimeout(() => {
player.view.container.find(`[data-asformid="reglink.label.${props.id}"]`).off();
reglinkModel.on('valueChange', () => {
player.view.container.find(`[data-asformid="reglink.label.${props.id}"]`).off();
return null;
});
}, 100);
//вешаем свое событие
if(tmpView) {
tmpView.container.off().on('click', () => {
if(!reglinkModel.value || reglinkModel.value == '') return;
const eventParam = {
type: 'document',
documentID: reglinkModel.value,
editable: false
};
$('#root-panel').trigger({type: 'custom_open_document', eventParam});
});
}
}); });
} }
...@@ -1294,6 +1326,8 @@ class ARMDocumentButtons { ...@@ -1294,6 +1326,8 @@ class ARMDocumentButtons {
this._doc.editable = !this._doc.editable; this._doc.editable = !this._doc.editable;
this._doc.formPlayer.view.setEditable(this._doc.editable); this._doc.formPlayer.view.setEditable(this._doc.editable);
this.changcheButtons(); this.changcheButtons();
overrideComponentMethods(this._doc.formPlayer);
} }
save(e){ save(e){
...@@ -1765,7 +1799,7 @@ class ARMDocument { ...@@ -1765,7 +1799,7 @@ class ARMDocument {
formPanel.append(playerContainer, footer); formPanel.append(playerContainer, footer);
setTimeout(() => { setTimeout(() => {
initOpenFilesInForm(this._doc.formPlayer); overrideComponentMethods(this._doc.formPlayer);
if(this._doc.matchingParam) initMatching(this._doc); if(this._doc.matchingParam) initMatching(this._doc);
}, 1000); }, 1000);
......
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