no_view_ok
This commit is contained in:
parent
6354b8d849
commit
b3873e7fca
@ -36,6 +36,7 @@ interface Member {
|
|||||||
name: string;
|
name: string;
|
||||||
email?: string;
|
email?: string;
|
||||||
avatar?: string;
|
avatar?: string;
|
||||||
|
processRoles?: Array<{ processId: number | string; role: string }>;
|
||||||
}
|
}
|
||||||
|
|
||||||
let currentUser: Member = membersMock[0];
|
let currentUser: Member = membersMock[0];
|
||||||
@ -564,7 +565,6 @@ function showProcessDetails(group: Group, groupId: number) {
|
|||||||
// Ajouter le bouton de signature pour tous les documents non vierges en mode dev
|
// Ajouter le bouton de signature pour tous les documents non vierges en mode dev
|
||||||
const signButton = !isVierge ? `
|
const signButton = !isVierge ? `
|
||||||
${totalSignatures > 0 && signedCount < totalSignatures &&
|
${totalSignatures > 0 && signedCount < totalSignatures &&
|
||||||
document.signatures.some((sig: DocumentSignature) => sig.member.name === currentUser.name) &&
|
|
||||||
!document.signatures.find((sig: DocumentSignature) => sig.member.name === currentUser.name && sig.signed) ? `
|
!document.signatures.find((sig: DocumentSignature) => sig.member.name === currentUser.name && sig.signed) ? `
|
||||||
<button class="sign-button" onclick="signDocument(${document.id}, ${groupId}, true)">
|
<button class="sign-button" onclick="signDocument(${document.id}, ${groupId}, true)">
|
||||||
Signer le document
|
Signer le document
|
||||||
@ -622,21 +622,24 @@ function showProcessDetails(group: Group, groupId: number) {
|
|||||||
</div>
|
</div>
|
||||||
<div class="details-section">
|
<div class="details-section">
|
||||||
<h3>Roles and Documents</h3>
|
<h3>Roles and Documents</h3>
|
||||||
${displayGroup.roles.map((role: { name: string; documents?: any[] }) => `
|
${displayGroup.roles.map((role: { name: string; documents?: any[] }) => {
|
||||||
<div class="role-section">
|
// Filtrer les documents selon les droits d'accès
|
||||||
<h4>${role.name}</h4>
|
const accessibleDocuments = (role.documents || []).filter(doc =>
|
||||||
<div class="documents-grid">
|
canUserAccessDocument(doc, role.name, currentUser.processRoles?.[0]?.role || '')
|
||||||
${(role.documents || []).length > 0 ?
|
);
|
||||||
(role.documents || []).map(document => {
|
|
||||||
|
return `
|
||||||
|
<div class="role-section">
|
||||||
|
<h4>${role.name}</h4>
|
||||||
|
<div class="documents-grid">
|
||||||
|
${accessibleDocuments.map(document => {
|
||||||
const isVierge = !document.createdAt ||
|
const isVierge = !document.createdAt ||
|
||||||
!document.deadline ||
|
!document.deadline ||
|
||||||
document.signatures.length === 0;
|
document.signatures.length === 0;
|
||||||
|
|
||||||
// Ajouter le bouton de signature pour tous les documents non vierges en mode dev
|
|
||||||
const signButton = !isVierge ? `
|
const signButton = !isVierge ? `
|
||||||
${document.signatures.length > 0 &&
|
${document.signatures.length > 0 &&
|
||||||
document.signatures.filter((sig: DocumentSignature) => sig.signed).length < document.signatures.length &&
|
document.signatures.filter((sig: DocumentSignature) => sig.signed).length < document.signatures.length &&
|
||||||
document.signatures.some((sig: DocumentSignature) => sig.member.name === currentUser.name) &&
|
|
||||||
!document.signatures.find((sig: DocumentSignature) => sig.member.name === currentUser.name && sig.signed) ? `
|
!document.signatures.find((sig: DocumentSignature) => sig.member.name === currentUser.name && sig.signed) ? `
|
||||||
<button class="sign-button" onclick="signDocument(${document.id}, ${groupId}, false)">
|
<button class="sign-button" onclick="signDocument(${document.id}, ${groupId}, false)">
|
||||||
Signer le document
|
Signer le document
|
||||||
@ -681,11 +684,11 @@ function showProcessDetails(group: Group, groupId: number) {
|
|||||||
${signButton}
|
${signButton}
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
}).join('')
|
}).join('')}
|
||||||
: '<p class="no-documents">No documents available for this role</p>'}
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
`;
|
||||||
`).join('')}
|
}).join('')}
|
||||||
</div>
|
</div>
|
||||||
<div class="details-section">
|
<div class="details-section">
|
||||||
<h3>Members by Role</h3>
|
<h3>Members by Role</h3>
|
||||||
@ -1582,7 +1585,7 @@ function signDocument(documentId: number, processId: number, isCommonDocument: b
|
|||||||
${Array.isArray(targetDoc.files) && targetDoc.files.length > 0 ?
|
${Array.isArray(targetDoc.files) && targetDoc.files.length > 0 ?
|
||||||
targetDoc.files.map((file: any) => `
|
targetDoc.files.map((file: any) => `
|
||||||
<div class="file-item">
|
<div class="file-item">
|
||||||
<span class="file-icon">📄</span>
|
<span class="file-icon"><EFBFBD><EFBFBD><EFBFBD></span>
|
||||||
<span class="file-name">${file.name}</span>
|
<span class="file-name">${file.name}</span>
|
||||||
<a href="${file.url}" class="download-link" download="${file.name}">
|
<a href="${file.url}" class="download-link" download="${file.name}">
|
||||||
<span class="download-icon">⬇</span>
|
<span class="download-icon">⬇</span>
|
||||||
@ -1749,3 +1752,13 @@ if (typeof window !== 'undefined') {
|
|||||||
(window as any).signDocument = signDocument;
|
(window as any).signDocument = signDocument;
|
||||||
(window as any).confirmSignature = confirmSignature;
|
(window as any).confirmSignature = confirmSignature;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ajouter cette fonction helper
|
||||||
|
function canUserAccessDocument(document: any, roleId: string, currentUserRole: string): boolean {
|
||||||
|
// Si l'utilisateur a le même rôle, il peut voir tous les documents
|
||||||
|
if (roleId === currentUserRole) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// Sinon, il ne peut voir que les documents publics
|
||||||
|
return document.visibility === 'public';
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user