fix: affichage extension PJ (shortName), bouton transfert toujours visible
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -91,10 +91,14 @@ function showToast(msg, type = 'success') {
|
|||||||
|
|
||||||
function buildTransferDropdown(sourceId, currentUsername) {
|
function buildTransferDropdown(sourceId, currentUsername) {
|
||||||
const others = ALL_ACCOUNTS.filter(a => a.username !== currentUsername);
|
const others = ALL_ACCOUNTS.filter(a => a.username !== currentUsername);
|
||||||
if (!others.length) return '';
|
if (!others.length) {
|
||||||
|
return `<button class="btn btn-sm btn-outline-secondary" disabled title="Aucun autre compte disponible">
|
||||||
|
<i class="bi bi-share"></i>
|
||||||
|
</button>`;
|
||||||
|
}
|
||||||
const items = others.map(a =>
|
const items = others.map(a =>
|
||||||
`<li><a class="dropdown-item" href="#" onclick="doTransfer(event,${sourceId},${a.id},'${a.username}')">
|
`<li><a class="dropdown-item" href="#" onclick="doTransfer(event,${sourceId},${a.id},'${a.username}')">
|
||||||
<i class="bi bi-arrow-right-circle me-1 text-primary"></i>${a.username}${a.display_name ? ' <span class=text-muted>— '+a.display_name+'</span>' : ''}
|
<i class="bi bi-arrow-right-circle me-1 text-primary"></i>${escHtml(a.username)}${a.display_name ? ' <span class="text-muted">— '+escHtml(a.display_name)+'</span>' : ''}
|
||||||
</a></li>`
|
</a></li>`
|
||||||
).join('');
|
).join('');
|
||||||
return `<div class="btn-group">
|
return `<div class="btn-group">
|
||||||
@@ -151,11 +155,12 @@ function renderMails(rows) {
|
|||||||
});
|
});
|
||||||
let filesHtml = '<span class="text-muted small">Aucune pièce jointe</span>';
|
let filesHtml = '<span class="text-muted small">Aucune pièce jointe</span>';
|
||||||
if (r.files_list && r.files_list.length) {
|
if (r.files_list && r.files_list.length) {
|
||||||
filesHtml = r.files_list.map(f =>
|
filesHtml = r.files_list.map(f => {
|
||||||
f.exists
|
const label = shortName(f.name);
|
||||||
? `<a href="/mail/download.php?id=${f.id}" class="badge bg-info text-decoration-none me-1"><i class="bi bi-download me-1"></i>${escHtml(f.name.substring(0,22))}</a>`
|
return f.exists
|
||||||
: `<span class="badge bg-secondary me-1" title="Fichier introuvable">${escHtml(f.name.substring(0,22))}</span>`
|
? `<a href="/mail/download.php?id=${f.id}" class="badge bg-info text-decoration-none me-1" title="${escHtml(f.name)}"><i class="bi bi-download me-1"></i>${escHtml(label)}</a>`
|
||||||
).join('');
|
: `<span class="badge bg-secondary me-1" title="${escHtml(f.name)}">⚠ ${escHtml(label)}</span>`;
|
||||||
|
}).join('');
|
||||||
}
|
}
|
||||||
const transferBtn = buildTransferDropdown(r.id, r.username);
|
const transferBtn = buildTransferDropdown(r.id, r.username);
|
||||||
return `<tr id="row-${r.id}">
|
return `<tr id="row-${r.id}">
|
||||||
@@ -181,6 +186,14 @@ function escHtml(s) {
|
|||||||
return String(s).replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"');
|
return String(s).replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function shortName(name) {
|
||||||
|
const dot = name.lastIndexOf('.');
|
||||||
|
const ext = dot >= 0 ? name.substring(dot) : '';
|
||||||
|
const base = dot >= 0 ? name.substring(0, dot) : name;
|
||||||
|
if (name.length <= 24) return name;
|
||||||
|
return base.substring(0, 14) + '…' + ext;
|
||||||
|
}
|
||||||
|
|
||||||
function loadMails() {
|
function loadMails() {
|
||||||
fetch('/api/mails.php')
|
fetch('/api/mails.php')
|
||||||
.then(r => r.json())
|
.then(r => r.json())
|
||||||
|
|||||||
Reference in New Issue
Block a user