Part-DB-server/assets/controllers
Sebastian Almberg 0bfbbc961d Fix update confirmation dialog not blocking form submission
The previous implementation used inline onsubmit handlers with return
confirmVersionChange(...), which could fail silently if any JavaScript
error occurred on the page, causing the form to submit without confirmation.

Fixes:
- Use event.preventDefault() FIRST to ensure form never submits by default
- Use DOMContentLoaded event listeners instead of inline handlers
- Properly escape translation strings using json_encode filter
- Wrap in IIFE with 'use strict' for better error handling
- Use data-attributes to identify forms and pass isDowngrade state

Fix DOMContentLoaded race condition in update form handlers

The event listener was not attaching if DOMContentLoaded had already
fired by the time the script executed. Now checks document.readyState
and attaches handlers immediately if DOM is already ready.

Added console.log statements to help debug form handler attachment.

Use Stimulus controller for update confirmation dialogs

The inline script was blocked by Content Security Policy (CSP).
Stimulus controllers are bundled with webpack and properly allowed by CSP.

- Create update_confirm_controller.js Stimulus controller
- Remove inline script from template
- Pass translation strings via data-* attributes
2026-01-30 23:24:48 +01:00
..
common Do not mark internal (relative) links as external and open in new tab in markdown blocks 2025-09-06 19:49:38 +02:00
elements Added clear button to optional part select fields 2026-01-25 19:12:27 +01:00
filters Added copyright/license info to files 2022-11-29 21:21:26 +01:00
helpers Use requestSubmit() in form cleanup controller to avoid CSFR issues 2026-01-18 22:24:17 +01:00
pages change barcode scan form to use requestSubmit() to fix CSRF token not being generated on submission (#1191) 2026-01-18 22:14:17 +01:00
turbo Added copyright/license info to files 2022-11-29 21:21:26 +01:00
bulk_import_controller.js Refactor bulk import functionality to make controller smaller (use services) add DTOs and use stimulus controllers on frontend 2025-09-09 20:30:27 +02:00
bulk_job_manage_controller.js Refactor bulk import functionality to make controller smaller (use services) add DTOs and use stimulus controllers on frontend 2025-09-09 20:30:27 +02:00
csrf_protection_controller.js Updated stimulus recipe 2025-11-30 15:07:59 +01:00
field_mapping_controller.js Refactor bulk info provider: replace complex arrays with DTOs 2025-09-19 16:28:40 +02:00
toggle_password_controller.js Removed the deprecated symfony/ux-toggle-password package by replacing it by our own local versions 2025-08-30 21:57:57 +02:00
update_confirm_controller.js Fix update confirmation dialog not blocking form submission 2026-01-30 23:24:48 +01:00