Improve email button UX with loading indicator
- Show '⏳ Email voorbereiden...' immediately when clicked
- Disable button during processing
- Use setTimeout to allow UI update before heavy processing
- Restore button state after mailto opens
This commit is contained in:
1 parent
16f4cc7bc8
commit
46fca0ccdf
5 files changed
+76
-8
No files matched your search
@@ -612,7 +612,7 @@ input.invalid, select.invalid, textarea.invalid {
|
|||||||
|
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<button type="button" class="btn btn-primary" onclick="exportCSV()">📥 Exporteer CSV</button>
|
<button type="button" class="btn btn-primary" onclick="exportCSV()">📥 Exporteer CSV</button>
|
||||||
<button type="button" class="btn btn-success" onclick="sendEmail()">📧 Verstuur per Email</button>
|
<button type="button" class="btn btn-success" onclick="sendEmail(this)">📧 Verstuur per Email</button>
|
||||||
<button type="button" class="btn btn-danger" onclick="clearForm()">🗑️ Formulier Wissen</button>
|
<button type="button" class="btn btn-danger" onclick="clearForm()">🗑️ Formulier Wissen</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -980,12 +980,22 @@ input.invalid, select.invalid, textarea.invalid {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Send email
|
// Send email
|
||||||
window.sendEmail = function() {
|
window.sendEmail = function(btn) {
|
||||||
if (!validateAll()) {
|
if (!validateAll()) {
|
||||||
showToast('Vul eerst alle verplichte velden in', 'error');
|
showToast('Vul eerst alle verplichte velden in', 'error');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Show loading state immediately
|
||||||
|
const button = btn || document.querySelector('[onclick*="sendEmail"]');
|
||||||
|
const originalText = button ? button.innerHTML : '';
|
||||||
|
if (button) {
|
||||||
|
button.innerHTML = '⏳ Email voorbereiden...';
|
||||||
|
button.disabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use setTimeout to allow UI to update before heavy processing
|
||||||
|
setTimeout(function() {
|
||||||
const data = getFormData();
|
const data = getFormData();
|
||||||
|
|
||||||
// Build subject
|
// Build subject
|
||||||
@@ -1023,7 +1033,14 @@ input.invalid, select.invalid, textarea.invalid {
|
|||||||
'?subject=' + encodeURIComponent(subject) +
|
'?subject=' + encodeURIComponent(subject) +
|
||||||
'&body=' + encodeURIComponent(body);
|
'&body=' + encodeURIComponent(body);
|
||||||
|
|
||||||
|
// Restore button state
|
||||||
|
if (button) {
|
||||||
|
button.innerHTML = originalText;
|
||||||
|
button.disabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
window.location.href = mailto;
|
window.location.href = mailto;
|
||||||
|
}, 50);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Clear form
|
// Clear form
|
||||||
|
|||||||
@@ -643,7 +643,7 @@ select {
|
|||||||
|
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<button type="button" class="btn btn-primary" onclick="exportCSV()">📥 Exporteer CSV</button>
|
<button type="button" class="btn btn-primary" onclick="exportCSV()">📥 Exporteer CSV</button>
|
||||||
<button type="button" class="btn btn-success" onclick="sendEmail()">📧 Verstuur per Email</button>
|
<button type="button" class="btn btn-success" onclick="sendEmail(this)">📧 Verstuur per Email</button>
|
||||||
<button type="button" class="btn btn-danger" onclick="clearForm()">🗑️ Formulier Wissen</button>
|
<button type="button" class="btn btn-danger" onclick="clearForm()">🗑️ Formulier Wissen</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -1011,12 +1011,22 @@ select {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Send email
|
// Send email
|
||||||
window.sendEmail = function() {
|
window.sendEmail = function(btn) {
|
||||||
if (!validateAll()) {
|
if (!validateAll()) {
|
||||||
showToast('Vul eerst alle verplichte velden in', 'error');
|
showToast('Vul eerst alle verplichte velden in', 'error');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Show loading state immediately
|
||||||
|
const button = btn || document.querySelector('[onclick*="sendEmail"]');
|
||||||
|
const originalText = button ? button.innerHTML : '';
|
||||||
|
if (button) {
|
||||||
|
button.innerHTML = '⏳ Email voorbereiden...';
|
||||||
|
button.disabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use setTimeout to allow UI to update before heavy processing
|
||||||
|
setTimeout(function() {
|
||||||
const data = getFormData();
|
const data = getFormData();
|
||||||
|
|
||||||
// Build subject
|
// Build subject
|
||||||
@@ -1054,7 +1064,14 @@ select {
|
|||||||
'?subject=' + encodeURIComponent(subject) +
|
'?subject=' + encodeURIComponent(subject) +
|
||||||
'&body=' + encodeURIComponent(body);
|
'&body=' + encodeURIComponent(body);
|
||||||
|
|
||||||
|
// Restore button state
|
||||||
|
if (button) {
|
||||||
|
button.innerHTML = originalText;
|
||||||
|
button.disabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
window.location.href = mailto;
|
window.location.href = mailto;
|
||||||
|
}, 50);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Clear form
|
// Clear form
|
||||||
|
|||||||
@@ -674,7 +674,7 @@ input.invalid, select.invalid, textarea.invalid {
|
|||||||
|
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<button type="button" class="btn btn-primary" onclick="exportCSV()">📥 Exporteer CSV</button>
|
<button type="button" class="btn btn-primary" onclick="exportCSV()">📥 Exporteer CSV</button>
|
||||||
<button type="button" class="btn btn-success" onclick="sendEmail()">📧 Verstuur per Email</button>
|
<button type="button" class="btn btn-success" onclick="sendEmail(this)">📧 Verstuur per Email</button>
|
||||||
<button type="button" class="btn btn-danger" onclick="clearForm()">🗑️ Formulier Wissen</button>
|
<button type="button" class="btn btn-danger" onclick="clearForm()">🗑️ Formulier Wissen</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -1042,12 +1042,22 @@ input.invalid, select.invalid, textarea.invalid {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Send email
|
// Send email
|
||||||
window.sendEmail = function() {
|
window.sendEmail = function(btn) {
|
||||||
if (!validateAll()) {
|
if (!validateAll()) {
|
||||||
showToast('Vul eerst alle verplichte velden in', 'error');
|
showToast('Vul eerst alle verplichte velden in', 'error');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Show loading state immediately
|
||||||
|
const button = btn || document.querySelector('[onclick*="sendEmail"]');
|
||||||
|
const originalText = button ? button.innerHTML : '';
|
||||||
|
if (button) {
|
||||||
|
button.innerHTML = '⏳ Email voorbereiden...';
|
||||||
|
button.disabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use setTimeout to allow UI to update before heavy processing
|
||||||
|
setTimeout(function() {
|
||||||
const data = getFormData();
|
const data = getFormData();
|
||||||
|
|
||||||
// Build subject
|
// Build subject
|
||||||
@@ -1085,7 +1095,14 @@ input.invalid, select.invalid, textarea.invalid {
|
|||||||
'?subject=' + encodeURIComponent(subject) +
|
'?subject=' + encodeURIComponent(subject) +
|
||||||
'&body=' + encodeURIComponent(body);
|
'&body=' + encodeURIComponent(body);
|
||||||
|
|
||||||
|
// Restore button state
|
||||||
|
if (button) {
|
||||||
|
button.innerHTML = originalText;
|
||||||
|
button.disabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
window.location.href = mailto;
|
window.location.href = mailto;
|
||||||
|
}, 50);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Clear form
|
// Clear form
|
||||||
|
|||||||
+1
-1
@@ -153,7 +153,7 @@ def generate_html(config: InventoryConfig) -> str:
|
|||||||
if config.export.csv.enabled:
|
if config.export.csv.enabled:
|
||||||
actions_html += ' <button type="button" class="btn btn-primary" onclick="exportCSV()">📥 Exporteer CSV</button>\n'
|
actions_html += ' <button type="button" class="btn btn-primary" onclick="exportCSV()">📥 Exporteer CSV</button>\n'
|
||||||
if config.export.mailto.enabled:
|
if config.export.mailto.enabled:
|
||||||
actions_html += ' <button type="button" class="btn btn-success" onclick="sendEmail()">📧 Verstuur per Email</button>\n'
|
actions_html += ' <button type="button" class="btn btn-success" onclick="sendEmail(this)">📧 Verstuur per Email</button>\n'
|
||||||
actions_html += ' <button type="button" class="btn btn-danger" onclick="clearForm()">🗑️ Formulier Wissen</button>\n'
|
actions_html += ' <button type="button" class="btn btn-danger" onclick="clearForm()">🗑️ Formulier Wissen</button>\n'
|
||||||
actions_html += '</div>\n'
|
actions_html += '</div>\n'
|
||||||
|
|
||||||
|
|||||||
+18
-1
@@ -1291,12 +1291,22 @@ JAVASCRIPT = """
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Send email
|
// Send email
|
||||||
window.sendEmail = function() {
|
window.sendEmail = function(btn) {
|
||||||
if (!validateAll()) {
|
if (!validateAll()) {
|
||||||
showToast('Vul eerst alle verplichte velden in', 'error');
|
showToast('Vul eerst alle verplichte velden in', 'error');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Show loading state immediately
|
||||||
|
const button = btn || document.querySelector('[onclick*="sendEmail"]');
|
||||||
|
const originalText = button ? button.innerHTML : '';
|
||||||
|
if (button) {
|
||||||
|
button.innerHTML = '⏳ Email voorbereiden...';
|
||||||
|
button.disabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use setTimeout to allow UI to update before heavy processing
|
||||||
|
setTimeout(function() {
|
||||||
const data = getFormData();
|
const data = getFormData();
|
||||||
|
|
||||||
// Build subject
|
// Build subject
|
||||||
@@ -1334,7 +1344,14 @@ JAVASCRIPT = """
|
|||||||
'?subject=' + encodeURIComponent(subject) +
|
'?subject=' + encodeURIComponent(subject) +
|
||||||
'&body=' + encodeURIComponent(body);
|
'&body=' + encodeURIComponent(body);
|
||||||
|
|
||||||
|
// Restore button state
|
||||||
|
if (button) {
|
||||||
|
button.innerHTML = originalText;
|
||||||
|
button.disabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
window.location.href = mailto;
|
window.location.href = mailto;
|
||||||
|
}, 50);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Clear form
|
// Clear form
|
||||||
|
|||||||
Reference in new issue
Block a user