Implement ticket selection with Stimulus controller and improve code documentation

- Add ticket selection functionality to event show page using Stimulus
- Create ticket_selection_controller.js for handling ticket quantity changes
- Update ticket card component and event show view to work with Stimulus
- Add comprehensive comments to all JavaScript files for better maintainability
- Remove dependent: :destroy from event ticket_types association
This commit is contained in:
kbe
2025-08-30 14:26:59 +02:00
parent 58dbcf3a6a
commit 56b0a45719
14 changed files with 428 additions and 284 deletions

View File

@@ -1,12 +1,16 @@
import { Controller } from "@hotwired/stimulus"
// Controller for handling flash messages
// Automatically dismisses messages after a timeout and handles manual closing
export default class extends Controller {
// Define targets for the controller
static targets = ["message"]
// Initialize the controller when it connects to the DOM
connect() {
console.log("FlashMessageController mounted", this.element);
// Initialize Lucide icons for this element
// Initialize Lucide icons for this element if available
if (typeof lucide !== 'undefined') {
lucide.createIcons({ within: this.element });
}
@@ -17,14 +21,19 @@ export default class extends Controller {
}, 2000)
}
// Clean up the timeout when the controller disconnects
disconnect() {
if (this.timeout) {
clearTimeout(this.timeout)
}
}
// Close the flash message with a fade-out animation
close() {
// Add opacity transition classes
this.element.classList.add('opacity-0', 'transition-opacity', 'duration-300')
// Remove element after transition completes
setTimeout(() => {
this.element.remove()
}, 300)