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

fix DocumentAttachments.js

parent 709345c6
...@@ -14,6 +14,10 @@ ...@@ -14,6 +14,10 @@
align-items: center; align-items: center;
} }
#workflow_add_file_button.uk-disabled {
opacity: 0.4;
}
.workflow-context-menu { .workflow-context-menu {
position: absolute; position: absolute;
display: none; display: none;
......
...@@ -14,6 +14,23 @@ const getMenuCoordinates = (menu, pageX, pageY) => { ...@@ -14,6 +14,23 @@ const getMenuCoordinates = (menu, pageX, pageY) => {
return coordinates; return coordinates;
} }
const canEditFile = async (documentID) => {
return new Promise(async resolve => {
try {
const {login, password} = Cons.creds;
const auth = "Basic " + btoa(unescape(encodeURIComponent(`${login}:${password}`)));
const url = `../Synergy/rest/api/storage/canEditFile?documentId=${documentID}`;
const response = await fetch(url, {method: 'GET', headers: {"Authorization": auth}});
if(!response.ok) throw new Error(await response.text());
resolve(response.text());
} catch (err) {
console.log(`ERROR [ canEditFile ]: ${err.message}`);
resolve(false);
}
});
}
this.DocumentAttachments = class { this.DocumentAttachments = class {
constructor(documentID, container, notEditable = false){ constructor(documentID, container, notEditable = false){
this.documentID = documentID; this.documentID = documentID;
...@@ -227,6 +244,8 @@ this.DocumentAttachments = class { ...@@ -227,6 +244,8 @@ this.DocumentAttachments = class {
this.tabContainer.append(this.addFileButton, this.workflowTabs); this.tabContainer.append(this.addFileButton, this.workflowTabs);
} }
if(this.canEdit == "false") this.addFileButton.addClass('uk-disabled');
this.rootContainer.append(this.tabContainer, this.filesContainer); this.rootContainer.append(this.tabContainer, this.filesContainer);
this.container.append(this.rootContainer); this.container.append(this.rootContainer);
...@@ -249,6 +268,11 @@ this.DocumentAttachments = class { ...@@ -249,6 +268,11 @@ this.DocumentAttachments = class {
this.filesWorkContainer.removeClass('active'); this.filesWorkContainer.removeClass('active');
this.tabWorkContainer.removeClass('active'); this.tabWorkContainer.removeClass('active');
this.path = "ase:attachmentContainer"; this.path = "ase:attachmentContainer";
if(this.canEdit == "false") {
this.addFileButton.addClass('uk-disabled');
} else {
this.addFileButton.removeClass('uk-disabled');
}
}); });
this.tabWorkContainer.find('a').on('click', e => { this.tabWorkContainer.find('a').on('click', e => {
...@@ -259,6 +283,7 @@ this.DocumentAttachments = class { ...@@ -259,6 +283,7 @@ this.DocumentAttachments = class {
this.filesWorkContainer.addClass('active'); this.filesWorkContainer.addClass('active');
this.tabWorkContainer.addClass('active'); this.tabWorkContainer.addClass('active');
this.path = "ase:workContainer"; this.path = "ase:workContainer";
this.addFileButton.removeClass('uk-disabled');
}); });
} }
...@@ -318,6 +343,7 @@ this.DocumentAttachments = class { ...@@ -318,6 +343,7 @@ this.DocumentAttachments = class {
async init(){ async init(){
const res = await appAPI.getDocumentAttachments(this.documentID); const res = await appAPI.getDocumentAttachments(this.documentID);
this.canEdit = await canEditFile(this.documentID);
this.renderApp(); this.renderApp();
......
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