- Modernized authentication with the introduction of TenantProject
- Created a base mail template - Adapt and improve document API to usage of catalogs and processors - Adapt eveai_sync to new authentication mechanism and usage of catalogs and processors
This commit is contained in:
@@ -59,6 +59,78 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Get all forms with tabs
|
||||
const formsWithTabs = document.querySelectorAll('form');
|
||||
|
||||
formsWithTabs.forEach(form => {
|
||||
// Handle the form's submit event
|
||||
form.addEventListener('submit', function(event) {
|
||||
const invalidFields = form.querySelectorAll(':invalid');
|
||||
|
||||
if (invalidFields.length > 0) {
|
||||
// Prevent form submission
|
||||
event.preventDefault();
|
||||
|
||||
// Find which tab contains the first invalid field
|
||||
const firstInvalidField = invalidFields[0];
|
||||
const tabPane = firstInvalidField.closest('.tab-pane');
|
||||
|
||||
if (tabPane) {
|
||||
// Get the tab ID
|
||||
const tabId = tabPane.id;
|
||||
|
||||
// Find and click the corresponding tab button
|
||||
const tabButton = document.querySelector(`[data-bs-toggle="tab"][data-bs-target="#${tabId}"]`);
|
||||
if (tabButton) {
|
||||
const tab = new bootstrap.Tab(tabButton);
|
||||
tab.show();
|
||||
}
|
||||
|
||||
// Scroll the invalid field into view and focus it
|
||||
firstInvalidField.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||||
firstInvalidField.focus();
|
||||
}
|
||||
|
||||
// Optional: Show a message about validation errors
|
||||
const errorCount = invalidFields.length;
|
||||
const message = `Please fill in all required fields (${errorCount} ${errorCount === 1 ? 'error' : 'errors'} found)`;
|
||||
if (typeof Swal !== 'undefined') {
|
||||
// If SweetAlert2 is available
|
||||
Swal.fire({
|
||||
title: 'Validation Error',
|
||||
text: message,
|
||||
icon: 'error',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
} else {
|
||||
// Fallback to browser alert
|
||||
alert(message);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Optional: Real-time validation as user switches tabs
|
||||
const tabButtons = document.querySelectorAll('[data-bs-toggle="tab"]');
|
||||
tabButtons.forEach(button => {
|
||||
button.addEventListener('shown.bs.tab', function() {
|
||||
const previousTabPane = document.querySelector(button.getAttribute('data-bs-target'));
|
||||
if (previousTabPane) {
|
||||
const invalidFields = previousTabPane.querySelectorAll(':invalid');
|
||||
if (invalidFields.length > 0) {
|
||||
// Add visual indicator to tab
|
||||
button.classList.add('has-error');
|
||||
} else {
|
||||
button.classList.remove('has-error');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
<style>
|
||||
.json-editor-container {
|
||||
|
||||
Reference in New Issue
Block a user