feat: Implement comprehensive event management system for promoters
This commit adds a complete event management interface allowing promoters to create, edit, and manage their events with full CRUD operations. ## Backend Features - New Promoter::EventsController with full CRUD operations - Event state management (draft, published, canceled, sold_out) - User authorization system with can_manage_events? method - Proper scoping to ensure users only see their own events ## Frontend Features - Modern responsive UI with Tailwind CSS styling - Event listing with status indicators and quick actions - Comprehensive event creation and editing forms - Detailed event show page with metrics and management options - Integration with main dashboard via promoter action buttons ## JavaScript Improvements - Refactored inline JavaScript to dedicated Stimulus controller - Auto-slug generation from event names with proper sanitization - Improved code organization following Rails conventions ## Routes & Navigation - Namespaced promoter routes under /promoter/ - RESTful endpoints with state management actions - Proper breadcrumb navigation and user flow ## Files Added/Modified - app/controllers/promoter/events_controller.rb (new) - app/javascript/controllers/event_form_controller.js (new) - app/views/promoter/events/*.html.erb (4 new view files) - app/models/user.rb (added authorization methods) - app/views/pages/dashboard.html.erb (added promoter buttons) - config/routes.rb (added promoter namespace) - app/javascript/controllers/index.js (registered new controller) 🎯 Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
28
app/javascript/controllers/event_form_controller.js
Normal file
28
app/javascript/controllers/event_form_controller.js
Normal file
@@ -0,0 +1,28 @@
|
||||
import { Controller } from "@hotwired/stimulus"
|
||||
|
||||
// Event form controller for handling form interactions
|
||||
// Handles auto-slug generation from event names
|
||||
export default class extends Controller {
|
||||
static targets = ["name", "slug"]
|
||||
|
||||
connect() {
|
||||
console.log("Event form controller connected")
|
||||
}
|
||||
|
||||
// Auto-generate slug from name input
|
||||
generateSlug() {
|
||||
// Only auto-generate if slug field is empty
|
||||
if (this.slugTarget.value === "") {
|
||||
const slug = this.nameTarget.value
|
||||
.toLowerCase()
|
||||
.normalize("NFD")
|
||||
.replace(/[\u0300-\u036f]/g, "") // Remove accents
|
||||
.replace(/[^a-z0-9\s-]/g, "") // Remove special chars
|
||||
.replace(/\s+/g, "-") // Replace spaces with dashes
|
||||
.replace(/-+/g, "-") // Remove duplicate dashes
|
||||
.replace(/^-|-$/g, "") // Remove leading/trailing dashes
|
||||
|
||||
this.slugTarget.value = slug
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user