Commit 1393fd51 authored by Samir Sadyhov's avatar Samir Sadyhov 🤔

fix openDocument & DocumentAttachments - проерка прав на загрузку приложения

parent c26e0ba3
......@@ -31,9 +31,26 @@ const canEditFile = async (documentID) => {
});
}
const filterAgrProcesses = processes => {
const procCode = ['APPROVAL_ITEM', 'AGREEMENT_ITEM', 'ACQUAINTANCE_ITEM'];
const result = [];
function search(p) {
p.forEach(function(process) {
if (!process.finished && procCode.includes(process.typeID)) {
result.push(process);
}
if (process.subProcesses.length > 0) search(process.subProcesses);
});
}
search(processes);
return result;
}
this.DocumentAttachments = class {
constructor(documentID, container, notEditable = false){
this.documentID = documentID;
constructor(_doc, container, notEditable = false){
this.documentID = typeof _doc == "string" ? _doc : _doc.documentID;
this._doc = typeof _doc == "string" ? null : _doc;
this.container = container;
this.notEditable = notEditable;
this.attachmentFilesCount = 0;
......@@ -244,7 +261,7 @@ this.DocumentAttachments = class {
this.tabContainer.append(this.addFileButton, this.workflowTabs);
}
if(this.canEdit == "false") this.addFileButton.addClass('uk-disabled');
if(!this.canEdit) this.addFileButton.addClass('uk-disabled');
this.rootContainer.append(this.tabContainer, this.filesContainer);
......@@ -268,7 +285,7 @@ this.DocumentAttachments = class {
this.filesWorkContainer.removeClass('active');
this.tabWorkContainer.removeClass('active');
this.path = "ase:attachmentContainer";
if(this.canEdit == "false") {
if(!this.canEdit) {
this.addFileButton.addClass('uk-disabled');
} else {
this.addFileButton.removeClass('uk-disabled');
......@@ -341,9 +358,40 @@ this.DocumentAttachments = class {
return ul;
}
async canEdit() {
if(this._doc) {
const {process, docInfo, workInfo, formPlayer, registryInfo} = this._doc;
const acqAgrProc = filterAgrProcesses(process);
if(!formPlayer) return false;
if(!docInfo) return false;
if(docInfo.registered == "true") return false;
if(registryInfo.rr_edit != "Y") return false;
if(this._doc.canEdit == "false") return false;
if(workInfo) {
const {actionID, has_subprocesses, parent_process} = workInfo;
const procCode = ['approval-single', 'agreement-single', 'acquaintance-single'];
if(procCode.includes(parent_process)) return false;
if(has_subprocesses == "true") {
const subworks = await appAPI.getSubworks(actionID);
const filtered = subworks.filter(x => procCode.includes(x.parent_process));
if(filtered.length) return false;
}
}
return true;
} else {
if(this.canEditFile == "false") return false;
return true;
}
}
async init(){
const res = await appAPI.getDocumentAttachments(this.documentID);
this.canEdit = await canEditFile(this.documentID);
this.canEditFile = await canEditFile(this.documentID);
this.canEdit = await this.canEdit();
this.renderApp();
......
......@@ -569,30 +569,31 @@ const finishWork = async (_doc) => {
}
const openDialogSelectSignType = handler => {
const dialog = $('<div class="uk-flex-top" uk-modal>');
const body = $('<div>', {class: 'uk-modal-dialog uk-modal-body'});
const header = $(`<h2 class="uk-modal-title">${i18n.tr('Выберите способ подписания')}</h2>`);
const buttonEgov = $(`<button class="uk-button uk-button-default uk-width-1-1 uk-margin-small-bottom">${i18n.tr('Подписать через eGov mobile')}</button>`);
const buttonNcaLayer = $(`<button class="uk-button uk-button-default uk-width-1-1 uk-margin-small-bottom">${i18n.tr('Подписать через NCALayer')}</button>`);
dialog.append(body);
body.append(header, buttonEgov, buttonNcaLayer);
buttonEgov.on('click', e => {
handler('egov');
UIkit.modal(dialog).hide();
});
buttonNcaLayer.on('click', e => {
handler('ncalayer');
UIkit.modal(dialog).hide();
});
UIkit.modal(dialog).show();
dialog.on('hidden', () => {
dialog.remove();
});
// const dialog = $('<div class="uk-flex-top" uk-modal>');
// const body = $('<div>', {class: 'uk-modal-dialog uk-modal-body'});
// const header = $(`<h2 class="uk-modal-title">${i18n.tr('Выберите способ подписания')}</h2>`);
// const buttonEgov = $(`<button class="uk-button uk-button-default uk-width-1-1 uk-margin-small-bottom">${i18n.tr('Подписать через eGov mobile')}</button>`);
// const buttonNcaLayer = $(`<button class="uk-button uk-button-default uk-width-1-1 uk-margin-small-bottom">${i18n.tr('Подписать через NCALayer')}</button>`);
// dialog.append(body);
// body.append(header, buttonEgov, buttonNcaLayer);
// buttonEgov.on('click', e => {
// handler('egov');
// UIkit.modal(dialog).hide();
// });
// buttonNcaLayer.on('click', e => {
// handler('ncalayer');
// UIkit.modal(dialog).hide();
// });
// UIkit.modal(dialog).show();
// dialog.on('hidden', () => {
// dialog.remove();
// });
}
const signDocument = async (_doc, signButton) => {
......@@ -1979,7 +1980,7 @@ class ARMDocument {
new DocumentComments(this._doc.documentID, null, this._doc.panels.commentsContainer);
}
new DocumentAttachments(this._doc.documentID, this._doc.panels.attachmentContainer);
new DocumentAttachments(this._doc, this._doc.panels.attachmentContainer);
this.addAttacmentListener();
}
......
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