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:
@@ -1,15 +1,20 @@
|
||||
import { Controller } from "@hotwired/stimulus";
|
||||
|
||||
// Controller for handling user logout functionality
|
||||
// Sends a DELETE request to the server to sign out the user
|
||||
export default class extends Controller {
|
||||
// Define controller values
|
||||
static values = {
|
||||
url: String,
|
||||
url: String, // Optional URL for logout endpoint
|
||||
};
|
||||
|
||||
// Log when the controller is mounted
|
||||
connect() {
|
||||
// Display a message when the controller is mounted
|
||||
console.log("LogoutController mounted", this.element);
|
||||
}
|
||||
|
||||
// Handle the sign out action
|
||||
signOut(event) {
|
||||
event.preventDefault();
|
||||
console.log("User clicked on logout button.");
|
||||
@@ -17,7 +22,7 @@ export default class extends Controller {
|
||||
// Ensure user wants to disconnect with a confirmation request
|
||||
// if (this.hasUrlValue && !confirm(this.element.dataset.confirm)) { return; }
|
||||
|
||||
// Retrieve the csrf token from header
|
||||
// Retrieve the csrf token from header for security
|
||||
const csrfToken = document.querySelector("[name='csrf-token']").content;
|
||||
|
||||
// Define url to redirect user when action is valid
|
||||
|
||||
Reference in New Issue
Block a user