This commit is contained in:
Pascal 2024-12-18 14:55:49 +01:00 committed by Sosthene
parent 6652354b33
commit b64adb3a9a
2 changed files with 63 additions and 63 deletions

View File

@ -50,25 +50,6 @@ let isAddingRow = false;
let currentRow: HTMLTableRowElement | null = null;
let currentMode: keyof typeof STORAGE_KEYS = 'pairing';
export function showAlert(message: string): void {
// Créer la popup si elle n'existe pas
let alertPopup = document.querySelector('.alert-popup');
if (!alertPopup) {
alertPopup = document.createElement('div');
alertPopup.className = 'alert-popup';
document.body.appendChild(alertPopup);
}
// Définir le message et afficher la popup
alertPopup.textContent = message;
(alertPopup as HTMLElement).style.display = 'block';
// Cacher la popup après 3 secondes
setTimeout(() => {
(alertPopup as HTMLElement).style.display = 'none';
}, 3000);
}
class AccountElement extends HTMLElement {
private dom: Node;
@ -249,6 +230,25 @@ class AccountElement extends HTMLElement {
this.updateNavbarLastName(savedLastName);
}
}
private showAlert(message: string): void {
// Créer la popup si elle n'existe pas
let alertPopup = this.shadowRoot?.querySelector('.alert-popup');
if (!alertPopup) {
alertPopup = document.createElement('div');
alertPopup.className = 'alert-popup';
this.shadowRoot?.appendChild(alertPopup);
}
// Définir le message et afficher la popup
alertPopup.textContent = message;
(alertPopup as HTMLElement).style.display = 'block';
// Cacher la popup après 3 secondes
setTimeout(() => {
(alertPopup as HTMLElement).style.display = 'none';
}, 3000);
}
// Fonctions de gestion des comptes et de l'interface utilisateur
@ -573,13 +573,13 @@ private confirmRow(): void {
// Vérification des champs vides
if (values.some(value => value === '')) {
showAlert('Please fill in all fields');
this.showAlert('Please fill in all fields');
return;
}
// Vérification de la longueur de l'adresse SP
if (values[0].length !== 118) {
showAlert('SP Address must be exactly 118 characters long');
this.showAlert('SP Address must be exactly 118 characters long');
return;
}
@ -630,7 +630,7 @@ private deleteRow(button: HTMLButtonElement): void {
// Vérifier le nombre de lignes restantes
const remainingRows = table.getElementsByTagName('tr').length;
if (remainingRows <= 2) {
showAlert('You must keep at least 2 devices paired');
this.showAlert('You must keep at least 2 devices paired');
return;
}
@ -1090,7 +1090,7 @@ private confirmWalletRow(): void {
currentRow = null;
this.showWallet();
} else {
showAlert('Please complete all fields before confirming.');
this.showAlert('Please complete all fields before confirming.');
}
}

View File

@ -40,25 +40,6 @@ interface LocalNotification {
time: string;
}
export function showAlert(message: string): void {
// Créer la popup si elle n'existe pas
let alertPopup = document.querySelector('.alert-popup');
if (!alertPopup) {
alertPopup = document.createElement('div');
alertPopup.className = 'alert-popup';
document.body.appendChild(alertPopup);
}
// Définir le message et afficher la popup
alertPopup.textContent = message;
(alertPopup as HTMLElement).style.display = 'block';
// Cacher la popup après 3 secondes
setTimeout(() => {
(alertPopup as HTMLElement).style.display = 'none';
}, 3000);
}
class SignatureElement extends HTMLElement {
private selectedMemberId: string | null = null;
@ -75,6 +56,25 @@ class SignatureElement extends HTMLElement {
roleName: 'Default Role'
}));
private showAlert(message: string): void {
// Créer la popup si elle n'existe pas
let alertPopup = this.shadowRoot?.querySelector('.alert-popup');
if (!alertPopup) {
alertPopup = document.createElement('div');
alertPopup.className = 'alert-popup';
this.shadowRoot?.appendChild(alertPopup);
}
// Définir le message et afficher la popup
alertPopup.textContent = message;
(alertPopup as HTMLElement).style.display = 'block';
// Cacher la popup après 3 secondes
setTimeout(() => {
(alertPopup as HTMLElement).style.display = 'none';
}, 3000);
}
private signDocument(documentId: number, processId: number, isCommonDocument: boolean = false): void {
try {
if (typeof window === 'undefined' || typeof document === 'undefined') {
@ -112,7 +112,7 @@ class SignatureElement extends HTMLElement {
this.canUserSignDocument(targetDoc, currentUser?.name, currentUser);
if (!canSign) {
showAlert("You do not have the necessary rights to sign this document.");
this.showAlert("You do not have the necessary rights to sign this document.");
return;
}
@ -263,7 +263,7 @@ class SignatureElement extends HTMLElement {
} catch (error) {
console.error('Error displaying modal:', error);
showAlert(error instanceof Error ? error.message : 'Error displaying modal');
this.showAlert(error instanceof Error ? error.message : 'Error displaying modal');
}
}
@ -1220,7 +1220,7 @@ class SignatureElement extends HTMLElement {
// Add parameter validation
if (!params || !params.processId) {
console.error('Paramètres invalides:', params);
showAlert('Invalid parameters for new request');
this.showAlert('Invalid parameters for new request');
return;
}
@ -1231,7 +1231,7 @@ class SignatureElement extends HTMLElement {
const process = groupsMock.find(g => g.id === params.processId);
if (!process) {
console.error('Processus non trouvé:', params.processId);
showAlert('Process not found');
this.showAlert('Process not found');
return;
}
@ -1257,7 +1257,7 @@ class SignatureElement extends HTMLElement {
}
} catch (error) {
console.error('Error retrieving members:', error);
showAlert('Error retrieving members');
this.showAlert('Error retrieving members');
return;
}
@ -1401,7 +1401,7 @@ class SignatureElement extends HTMLElement {
const form = document.getElementById('newDocumentForm') as HTMLFormElement;
if (!form) {
showAlert('Form not found');
this.showAlert('Form not found');
return;
}
@ -1425,7 +1425,7 @@ class SignatureElement extends HTMLElement {
// Validation
if (!documentName || !description || !deadline) {
showAlert('Please fill in all required fields');
this.showAlert('Please fill in all required fields');
return;
}
@ -1435,7 +1435,7 @@ class SignatureElement extends HTMLElement {
const group = groups.find((g: Group) => g.id === processId);
if (!group) {
showAlert('Process not found');
this.showAlert('Process not found');
return;
}
@ -1444,7 +1444,7 @@ class SignatureElement extends HTMLElement {
);
if (!role) {
showAlert('Role not found');
this.showAlert('Role not found');
return;
}
@ -1496,11 +1496,11 @@ class SignatureElement extends HTMLElement {
// Reload the documents view with the updated data
this.showRoleDocuments(role, group);
showAlert('Document updated successfully!');
this.showAlert('Document updated successfully!');
} catch (error) {
console.error('Error saving:', error);
showAlert('An error occurred while saving');
this.showAlert('An error occurred while saving');
}
}
@ -1509,7 +1509,7 @@ class SignatureElement extends HTMLElement {
const form = document.getElementById('newDocumentForm') as HTMLFormElement;
if (!form) {
showAlert('Form not found');
this.showAlert('Form not found');
return;
}
@ -1521,7 +1521,7 @@ class SignatureElement extends HTMLElement {
const visibility = (form.querySelector('#visibility') as HTMLSelectElement)?.value;
if (!documentName || !description || !deadline) {
showAlert('Please fill in all required fields');
this.showAlert('Please fill in all required fields');
return;
}
@ -1530,7 +1530,7 @@ class SignatureElement extends HTMLElement {
const group = groups.find((g: Group) => g.id === processId);
if (!group) {
showAlert('Process not found');
this.showAlert('Process not found');
return;
}
@ -1577,18 +1577,18 @@ class SignatureElement extends HTMLElement {
}
this.showProcessDetails(group, group.id);
showAlert('Document common updated successfully!');
this.showAlert('Document common updated successfully!');
} catch (error) {
console.error('Error saving:', error);
showAlert('An error occurred while saving');
this.showAlert('An error occurred while saving');
}
}
private submitRequest() {
showAlert("Request submitted!");
this.showAlert("Request submitted!");
}
private closeNewRequest() {
@ -1610,7 +1610,7 @@ class SignatureElement extends HTMLElement {
).map(checkbox => (checkbox as HTMLInputElement).value);
if (!createdAt || !deadline || selectedMembers.length === 0) {
showAlert('Please fill in all required fields and select at least one member.');
this.showAlert('Please fill in all required fields and select at least one member.');
return;
}
@ -1623,7 +1623,7 @@ class SignatureElement extends HTMLElement {
selectedMembers
});
showAlert('Document request submitted successfully!');
this.showAlert('Document request submitted successfully!');
this.closeNewRequest();
}
@ -1687,11 +1687,11 @@ class SignatureElement extends HTMLElement {
}
}
showAlert('Document signed successfully!');
this.showAlert('Document signed successfully!');
} catch (error) {
console.error('Error signing document:', error);
showAlert(error instanceof Error ? error.message : 'Error signing document');
this.showAlert(error instanceof Error ? error.message : 'Error signing document');
}
}