From 3aaec284d7d07355620dd646529ba94bcf2287b8 Mon Sep 17 00:00:00 2001 From: James Mead Date: Fri, 22 Dec 2023 11:35:18 +0000 Subject: [PATCH] Display filename of existing cover on album form c.f. what we're doing for the track original files in the same form. We might want to try to extract the duplication, but I'm a bit unsure how to do that with the current `TailwindFormBuilder` implementation. We could probably do it in a helper method, but that doesn't feel quite right either. We might also want to consider doing this for the profile picture file field on the artist form, but I'm trying to keep this PR focussed on the album form. --- app/views/albums/_form.html.erb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/views/albums/_form.html.erb b/app/views/albums/_form.html.erb index bc7563a0..7637600e 100644 --- a/app/views/albums/_form.html.erb +++ b/app/views/albums/_form.html.erb @@ -4,7 +4,11 @@ <%= form.currency_field :price, symbol: '£', class: 'w-full mb-2' %> <%= form.text_area :about, rows: 10, class: 'w-full mb-3' %> <%= form.text_area :credits, rows: 10, class: 'w-full mb-3' %> - <%= form.labels :cover %> + <% if form.object.cover.attached? %> + <%= form.labels :cover, text: "Cover (#{form.object.cover.filename})" %> + <% else %> + <%= form.labels :cover, text: "Cover" %> + <% end %> <%= form.file_field :cover, accept: 'image/jpeg,image/png', class: 'block border border-slate-200 mb-3 file:mr-3 file:px-3 file:py-3 w-full file:border-0 file:bg-amber-600 hover:file:bg-amber-500 file:text-white' %>