diff --git a/db.sqlite3 b/db.sqlite3 index 79d4607..088d726 100644 Binary files a/db.sqlite3 and b/db.sqlite3 differ diff --git a/installations/templates/installations/installation_report_step.html b/installations/templates/installations/installation_report_step.html index 2d14128..3246dea 100644 --- a/installations/templates/installations/installation_report_step.html +++ b/installations/templates/installations/installation_report_step.html @@ -31,6 +31,60 @@ .removal-checkbox:checked:focus { box-shadow: 0 0 0 0.25rem rgba(220, 53, 69, 0.25) !important; } + + /* Upload Loader Overlay */ + #uploadLoader { + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + background-color: rgba(0, 0, 0, 0.7); + z-index: 9999; + display: none; + justify-content: center; + align-items: center; + } + + #uploadLoader.active { + display: flex; + } + + .loader-content { + background: white; + padding: 2rem; + border-radius: 12px; + text-align: center; + box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3); + max-width: 300px; + } + + .loader-spinner { + width: 50px; + height: 50px; + border: 5px solid #f3f3f3; + border-top: 5px solid #696cff; + border-radius: 50%; + animation: spin 1s linear infinite; + margin: 0 auto 1rem; + } + + @keyframes spin { + 0% { transform: rotate(0deg); } + 100% { transform: rotate(360deg); } + } + + .loader-text { + font-size: 1.1rem; + font-weight: 500; + color: #333; + margin-bottom: 0.5rem; + } + + .loader-subtext { + font-size: 0.9rem; + color: #666; + } {% endblock %} @@ -38,6 +92,15 @@ {% include '_toasts.html' %} + +
+
+
+
در حال آپلود...
+
لطفا تا بارگذاری کامل گزارش منتظر بمانید.
+
+
+ {% instance_info_modal instance %} @@ -516,7 +579,7 @@ {% if user_is_installer %} {% endif %} - {% if next_step and not edit_mode %} + {% if next_step and not edit_mode and report %} بعدی @@ -638,6 +701,9 @@ // Require date and show success toast on submit (persist across redirect) (function(){ const form = document.querySelector('form[enctype]') || document.querySelector('form'); + const loader = document.getElementById('uploadLoader'); + const submitButton = document.querySelector('button[type="submit"][form="installation-report-form"]'); + if (!form) return; form.addEventListener('submit', function(ev){ const display = document.getElementById('id_visited_date_display'); @@ -663,8 +729,32 @@ return false; } } catch(_) {} + + // Show loader overlay when form is valid and submitting + if (loader) { + loader.classList.add('active'); + } + + // Disable submit button to prevent double submission + if (submitButton) { + submitButton.disabled = true; + submitButton.innerHTML = 'در حال ارسال...'; + } + try { sessionStorage.setItem('install_report_saved', '1'); } catch(_) {} }, false); + + // Hide loader on back navigation or page show (in case of errors) + window.addEventListener('pageshow', function(event) { + if (loader) { + loader.classList.remove('active'); + } + if (submitButton) { + submitButton.disabled = false; + submitButton.innerHTML = 'ثبت گزارش'; + } + }); + // on load, if saved flag exists, show toast try { if (sessionStorage.getItem('install_report_saved') === '1') {