diff --git a/examples/inventory_corporate.html b/examples/inventory_corporate.html
index 67ad386..1c43870 100644
--- a/examples/inventory_corporate.html
+++ b/examples/inventory_corporate.html
@@ -612,7 +612,7 @@ input.invalid, select.invalid, textarea.invalid {
-
+
@@ -980,50 +980,67 @@ input.invalid, select.invalid, textarea.invalid {
};
// Send email
- window.sendEmail = function() {
+ window.sendEmail = function(btn) {
if (!validateAll()) {
showToast('Vul eerst alle verplichte velden in', 'error');
return;
}
- const data = getFormData();
-
- // Build subject
- let subject = CONFIG.export.mailto.subject_prefix;
- if (CONFIG.export.mailto.include_timestamp) {
- subject += ' - ' + formatDateTime(new Date());
+ // 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;
}
- CONFIG.export.mailto.subject_fields.forEach(fieldId => {
- if (data[fieldId]) {
- subject += ' - ' + data[fieldId];
- }
- });
-
- // Build body
- let body = 'INVENTARISATIE GEGEVENS\n';
- body += '========================\n\n';
- body += 'Formulier: ' + CONFIG.name + '\n';
- body += 'Versie: ' + CONFIG.version + '\n';
- body += 'Datum: ' + formatDateTime(new Date()) + '\n\n';
- Object.entries(data).forEach(([key, value]) => {
- if (value && value !== '' && !key.includes('foto') && !key.includes('photo')) {
- const label = document.querySelector(`label[for="${key}"]`);
- const labelText = label ? label.textContent.replace('*', '').trim() : key;
- const displayValue = Array.isArray(value) ? value.join(', ') : value;
- body += labelText + ': ' + displayValue + '\n';
+ // Use setTimeout to allow UI to update before heavy processing
+ setTimeout(function() {
+ const data = getFormData();
+
+ // Build subject
+ let subject = CONFIG.export.mailto.subject_prefix;
+ if (CONFIG.export.mailto.include_timestamp) {
+ subject += ' - ' + formatDateTime(new Date());
}
- });
-
- body += '\n========================\n';
- body += 'Let op: Foto\'s kunnen niet via mailto worden verzonden.\n';
- body += 'Gebruik CSV export voor complete data inclusief foto\'s.';
-
- const mailto = 'mailto:' + encodeURIComponent(CONFIG.export.mailto.to) +
- '?subject=' + encodeURIComponent(subject) +
- '&body=' + encodeURIComponent(body);
-
- window.location.href = mailto;
+ CONFIG.export.mailto.subject_fields.forEach(fieldId => {
+ if (data[fieldId]) {
+ subject += ' - ' + data[fieldId];
+ }
+ });
+
+ // Build body
+ let body = 'INVENTARISATIE GEGEVENS\n';
+ body += '========================\n\n';
+ body += 'Formulier: ' + CONFIG.name + '\n';
+ body += 'Versie: ' + CONFIG.version + '\n';
+ body += 'Datum: ' + formatDateTime(new Date()) + '\n\n';
+
+ Object.entries(data).forEach(([key, value]) => {
+ if (value && value !== '' && !key.includes('foto') && !key.includes('photo')) {
+ const label = document.querySelector(`label[for="${key}"]`);
+ const labelText = label ? label.textContent.replace('*', '').trim() : key;
+ const displayValue = Array.isArray(value) ? value.join(', ') : value;
+ body += labelText + ': ' + displayValue + '\n';
+ }
+ });
+
+ body += '\n========================\n';
+ body += 'Let op: Foto\'s kunnen niet via mailto worden verzonden.\n';
+ body += 'Gebruik CSV export voor complete data inclusief foto\'s.';
+
+ const mailto = 'mailto:' + encodeURIComponent(CONFIG.export.mailto.to) +
+ '?subject=' + encodeURIComponent(subject) +
+ '&body=' + encodeURIComponent(body);
+
+ // Restore button state
+ if (button) {
+ button.innerHTML = originalText;
+ button.disabled = false;
+ }
+
+ window.location.href = mailto;
+ }, 50);
};
// Clear form
diff --git a/examples/inventory_minimal.html b/examples/inventory_minimal.html
index fce1a92..cdd62e2 100644
--- a/examples/inventory_minimal.html
+++ b/examples/inventory_minimal.html
@@ -643,7 +643,7 @@ select {
-
+
@@ -1011,50 +1011,67 @@ select {
};
// Send email
- window.sendEmail = function() {
+ window.sendEmail = function(btn) {
if (!validateAll()) {
showToast('Vul eerst alle verplichte velden in', 'error');
return;
}
- const data = getFormData();
-
- // Build subject
- let subject = CONFIG.export.mailto.subject_prefix;
- if (CONFIG.export.mailto.include_timestamp) {
- subject += ' - ' + formatDateTime(new Date());
+ // 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;
}
- CONFIG.export.mailto.subject_fields.forEach(fieldId => {
- if (data[fieldId]) {
- subject += ' - ' + data[fieldId];
- }
- });
-
- // Build body
- let body = 'INVENTARISATIE GEGEVENS\n';
- body += '========================\n\n';
- body += 'Formulier: ' + CONFIG.name + '\n';
- body += 'Versie: ' + CONFIG.version + '\n';
- body += 'Datum: ' + formatDateTime(new Date()) + '\n\n';
- Object.entries(data).forEach(([key, value]) => {
- if (value && value !== '' && !key.includes('foto') && !key.includes('photo')) {
- const label = document.querySelector(`label[for="${key}"]`);
- const labelText = label ? label.textContent.replace('*', '').trim() : key;
- const displayValue = Array.isArray(value) ? value.join(', ') : value;
- body += labelText + ': ' + displayValue + '\n';
+ // Use setTimeout to allow UI to update before heavy processing
+ setTimeout(function() {
+ const data = getFormData();
+
+ // Build subject
+ let subject = CONFIG.export.mailto.subject_prefix;
+ if (CONFIG.export.mailto.include_timestamp) {
+ subject += ' - ' + formatDateTime(new Date());
}
- });
-
- body += '\n========================\n';
- body += 'Let op: Foto\'s kunnen niet via mailto worden verzonden.\n';
- body += 'Gebruik CSV export voor complete data inclusief foto\'s.';
-
- const mailto = 'mailto:' + encodeURIComponent(CONFIG.export.mailto.to) +
- '?subject=' + encodeURIComponent(subject) +
- '&body=' + encodeURIComponent(body);
-
- window.location.href = mailto;
+ CONFIG.export.mailto.subject_fields.forEach(fieldId => {
+ if (data[fieldId]) {
+ subject += ' - ' + data[fieldId];
+ }
+ });
+
+ // Build body
+ let body = 'INVENTARISATIE GEGEVENS\n';
+ body += '========================\n\n';
+ body += 'Formulier: ' + CONFIG.name + '\n';
+ body += 'Versie: ' + CONFIG.version + '\n';
+ body += 'Datum: ' + formatDateTime(new Date()) + '\n\n';
+
+ Object.entries(data).forEach(([key, value]) => {
+ if (value && value !== '' && !key.includes('foto') && !key.includes('photo')) {
+ const label = document.querySelector(`label[for="${key}"]`);
+ const labelText = label ? label.textContent.replace('*', '').trim() : key;
+ const displayValue = Array.isArray(value) ? value.join(', ') : value;
+ body += labelText + ': ' + displayValue + '\n';
+ }
+ });
+
+ body += '\n========================\n';
+ body += 'Let op: Foto\'s kunnen niet via mailto worden verzonden.\n';
+ body += 'Gebruik CSV export voor complete data inclusief foto\'s.';
+
+ const mailto = 'mailto:' + encodeURIComponent(CONFIG.export.mailto.to) +
+ '?subject=' + encodeURIComponent(subject) +
+ '&body=' + encodeURIComponent(body);
+
+ // Restore button state
+ if (button) {
+ button.innerHTML = originalText;
+ button.disabled = false;
+ }
+
+ window.location.href = mailto;
+ }, 50);
};
// Clear form
diff --git a/examples/inventory_modern.html b/examples/inventory_modern.html
index 6abc3c1..ac1c776 100644
--- a/examples/inventory_modern.html
+++ b/examples/inventory_modern.html
@@ -674,7 +674,7 @@ input.invalid, select.invalid, textarea.invalid {
-
+
@@ -1042,50 +1042,67 @@ input.invalid, select.invalid, textarea.invalid {
};
// Send email
- window.sendEmail = function() {
+ window.sendEmail = function(btn) {
if (!validateAll()) {
showToast('Vul eerst alle verplichte velden in', 'error');
return;
}
- const data = getFormData();
-
- // Build subject
- let subject = CONFIG.export.mailto.subject_prefix;
- if (CONFIG.export.mailto.include_timestamp) {
- subject += ' - ' + formatDateTime(new Date());
+ // 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;
}
- CONFIG.export.mailto.subject_fields.forEach(fieldId => {
- if (data[fieldId]) {
- subject += ' - ' + data[fieldId];
- }
- });
-
- // Build body
- let body = 'INVENTARISATIE GEGEVENS\n';
- body += '========================\n\n';
- body += 'Formulier: ' + CONFIG.name + '\n';
- body += 'Versie: ' + CONFIG.version + '\n';
- body += 'Datum: ' + formatDateTime(new Date()) + '\n\n';
- Object.entries(data).forEach(([key, value]) => {
- if (value && value !== '' && !key.includes('foto') && !key.includes('photo')) {
- const label = document.querySelector(`label[for="${key}"]`);
- const labelText = label ? label.textContent.replace('*', '').trim() : key;
- const displayValue = Array.isArray(value) ? value.join(', ') : value;
- body += labelText + ': ' + displayValue + '\n';
+ // Use setTimeout to allow UI to update before heavy processing
+ setTimeout(function() {
+ const data = getFormData();
+
+ // Build subject
+ let subject = CONFIG.export.mailto.subject_prefix;
+ if (CONFIG.export.mailto.include_timestamp) {
+ subject += ' - ' + formatDateTime(new Date());
}
- });
-
- body += '\n========================\n';
- body += 'Let op: Foto\'s kunnen niet via mailto worden verzonden.\n';
- body += 'Gebruik CSV export voor complete data inclusief foto\'s.';
-
- const mailto = 'mailto:' + encodeURIComponent(CONFIG.export.mailto.to) +
- '?subject=' + encodeURIComponent(subject) +
- '&body=' + encodeURIComponent(body);
-
- window.location.href = mailto;
+ CONFIG.export.mailto.subject_fields.forEach(fieldId => {
+ if (data[fieldId]) {
+ subject += ' - ' + data[fieldId];
+ }
+ });
+
+ // Build body
+ let body = 'INVENTARISATIE GEGEVENS\n';
+ body += '========================\n\n';
+ body += 'Formulier: ' + CONFIG.name + '\n';
+ body += 'Versie: ' + CONFIG.version + '\n';
+ body += 'Datum: ' + formatDateTime(new Date()) + '\n\n';
+
+ Object.entries(data).forEach(([key, value]) => {
+ if (value && value !== '' && !key.includes('foto') && !key.includes('photo')) {
+ const label = document.querySelector(`label[for="${key}"]`);
+ const labelText = label ? label.textContent.replace('*', '').trim() : key;
+ const displayValue = Array.isArray(value) ? value.join(', ') : value;
+ body += labelText + ': ' + displayValue + '\n';
+ }
+ });
+
+ body += '\n========================\n';
+ body += 'Let op: Foto\'s kunnen niet via mailto worden verzonden.\n';
+ body += 'Gebruik CSV export voor complete data inclusief foto\'s.';
+
+ const mailto = 'mailto:' + encodeURIComponent(CONFIG.export.mailto.to) +
+ '?subject=' + encodeURIComponent(subject) +
+ '&body=' + encodeURIComponent(body);
+
+ // Restore button state
+ if (button) {
+ button.innerHTML = originalText;
+ button.disabled = false;
+ }
+
+ window.location.href = mailto;
+ }, 50);
};
// Clear form
diff --git a/src/generator.py b/src/generator.py
index 426aa1b..964bfc7 100644
--- a/src/generator.py
+++ b/src/generator.py
@@ -153,7 +153,7 @@ def generate_html(config: InventoryConfig) -> str:
if config.export.csv.enabled:
actions_html += ' \n'
if config.export.mailto.enabled:
- actions_html += ' \n'
+ actions_html += ' \n'
actions_html += ' \n'
actions_html += '\n'
diff --git a/src/templates.py b/src/templates.py
index 2eb5ecd..13f2e67 100644
--- a/src/templates.py
+++ b/src/templates.py
@@ -1291,50 +1291,67 @@ JAVASCRIPT = """
};
// Send email
- window.sendEmail = function() {
+ window.sendEmail = function(btn) {
if (!validateAll()) {
showToast('Vul eerst alle verplichte velden in', 'error');
return;
}
- const data = getFormData();
-
- // Build subject
- let subject = CONFIG.export.mailto.subject_prefix;
- if (CONFIG.export.mailto.include_timestamp) {
- subject += ' - ' + formatDateTime(new Date());
+ // 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;
}
- CONFIG.export.mailto.subject_fields.forEach(fieldId => {
- if (data[fieldId]) {
- subject += ' - ' + data[fieldId];
- }
- });
-
- // Build body
- let body = 'INVENTARISATIE GEGEVENS\\n';
- body += '========================\\n\\n';
- body += 'Formulier: ' + CONFIG.name + '\\n';
- body += 'Versie: ' + CONFIG.version + '\\n';
- body += 'Datum: ' + formatDateTime(new Date()) + '\\n\\n';
- Object.entries(data).forEach(([key, value]) => {
- if (value && value !== '' && !key.includes('foto') && !key.includes('photo')) {
- const label = document.querySelector(`label[for="${key}"]`);
- const labelText = label ? label.textContent.replace('*', '').trim() : key;
- const displayValue = Array.isArray(value) ? value.join(', ') : value;
- body += labelText + ': ' + displayValue + '\\n';
+ // Use setTimeout to allow UI to update before heavy processing
+ setTimeout(function() {
+ const data = getFormData();
+
+ // Build subject
+ let subject = CONFIG.export.mailto.subject_prefix;
+ if (CONFIG.export.mailto.include_timestamp) {
+ subject += ' - ' + formatDateTime(new Date());
}
- });
-
- body += '\\n========================\\n';
- body += 'Let op: Foto\\'s kunnen niet via mailto worden verzonden.\\n';
- body += 'Gebruik CSV export voor complete data inclusief foto\\'s.';
-
- const mailto = 'mailto:' + encodeURIComponent(CONFIG.export.mailto.to) +
- '?subject=' + encodeURIComponent(subject) +
- '&body=' + encodeURIComponent(body);
-
- window.location.href = mailto;
+ CONFIG.export.mailto.subject_fields.forEach(fieldId => {
+ if (data[fieldId]) {
+ subject += ' - ' + data[fieldId];
+ }
+ });
+
+ // Build body
+ let body = 'INVENTARISATIE GEGEVENS\\n';
+ body += '========================\\n\\n';
+ body += 'Formulier: ' + CONFIG.name + '\\n';
+ body += 'Versie: ' + CONFIG.version + '\\n';
+ body += 'Datum: ' + formatDateTime(new Date()) + '\\n\\n';
+
+ Object.entries(data).forEach(([key, value]) => {
+ if (value && value !== '' && !key.includes('foto') && !key.includes('photo')) {
+ const label = document.querySelector(`label[for="${key}"]`);
+ const labelText = label ? label.textContent.replace('*', '').trim() : key;
+ const displayValue = Array.isArray(value) ? value.join(', ') : value;
+ body += labelText + ': ' + displayValue + '\\n';
+ }
+ });
+
+ body += '\\n========================\\n';
+ body += 'Let op: Foto\\'s kunnen niet via mailto worden verzonden.\\n';
+ body += 'Gebruik CSV export voor complete data inclusief foto\\'s.';
+
+ const mailto = 'mailto:' + encodeURIComponent(CONFIG.export.mailto.to) +
+ '?subject=' + encodeURIComponent(subject) +
+ '&body=' + encodeURIComponent(body);
+
+ // Restore button state
+ if (button) {
+ button.innerHTML = originalText;
+ button.disabled = false;
+ }
+
+ window.location.href = mailto;
+ }, 50);
};
// Clear form