fix: Update views and controllers for event image display
Update all event-related view templates and controllers to properly handle and display event images throughout the application. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -70,12 +70,23 @@
|
||||
<%= form.label :image, "Image de couverture", class: "block text-sm font-medium text-gray-700 mb-2" %>
|
||||
<div class="space-y-4">
|
||||
<!-- Current image preview -->
|
||||
<% if @event.image.attached? %>
|
||||
<div class="relative">
|
||||
<%= image_tag @event.image.variant(resize_to_limit: [400, 225]), class: "w-full h-48 object-cover rounded-lg border border-gray-200" %>
|
||||
<div class="absolute top-2 right-2">
|
||||
<button type="button" onclick="this.closest('div').querySelector('input[type=file]').click()" class="bg-red-500 text-white p-2 rounded-full hover:bg-red-600 transition-colors">
|
||||
<i data-lucide="trash-2" class="w-4 h-4"></i>
|
||||
<% if @event.has_image? %>
|
||||
<div class="flex items-start space-x-4">
|
||||
<div class="flex-shrink-0">
|
||||
<% if @event.event_image_variant(:small).is_a?(String) %>
|
||||
<!-- Old image field -->
|
||||
<%= image_tag @event.event_image_variant(:small), class: "w-32 h-24 object-cover rounded-lg border border-gray-200" %>
|
||||
<% else %>
|
||||
<!-- Attached image -->
|
||||
<%= image_tag @event.event_image_variant(:small), class: "w-32 h-24 object-cover rounded-lg border border-gray-200" %>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="flex-1 min-w-0">
|
||||
<p class="text-sm font-medium text-gray-900 mb-1">Image actuelle</p>
|
||||
<p class="text-sm text-gray-600 mb-2">Uploader une nouvelle image pour la remplacer.</p>
|
||||
<button type="button" onclick="this.closest('div').querySelector('input[type=file]').click()" class="bg-red-500 text-white p-2 rounded-lg hover:bg-red-600 transition-colors inline-flex items-center">
|
||||
<i data-lucide="trash-2" class="w-4 h-4 mr-1"></i>
|
||||
<span>Remplacer l'image</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -86,7 +97,7 @@
|
||||
<%= form.file_field :image, class: "w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-transparent file:mr-4 file:py-2 file:px-4 file:rounded-lg file:border-0 file:text-sm file:font-semibold file:bg-purple-50 file:text-purple-700 hover:file:bg-purple-100", accept: "image/png,image/jpeg,image/jpg,image/webp", data: { action: "change->event-form#previewImage" } %>
|
||||
<div class="mt-1 text-sm text-gray-500">
|
||||
Formats acceptés : PNG, JPG, JPEG, WebP (max 5MB)
|
||||
<% if @event.image.attached? %>
|
||||
<% if @event.has_image? %>
|
||||
<br>Laissez vide pour conserver l'image actuelle
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user