diff options
author | Matthew Lemon <y@yulqen.org> | 2024-11-14 11:28:08 +0000 |
---|---|---|
committer | Matthew Lemon <y@yulqen.org> | 2024-11-14 11:28:08 +0000 |
commit | 06222c54c248a03d0b019db12bc365ab187e317a (patch) | |
tree | afe145691540713fd674196dc46d45ef5d72db42 | |
parent | c8d449c31b29b281a219512bdd5defd5e5ea20f3 (diff) |
Adds nice reminders on the edit page re pdfs and thumbnails
-rw-r--r-- | app/views/pdfresources/_form.html.erb | 56 | ||||
-rw-r--r-- | app/views/pdfresources/edit.html.erb | 11 |
2 files changed, 51 insertions, 16 deletions
diff --git a/app/views/pdfresources/_form.html.erb b/app/views/pdfresources/_form.html.erb index 8b439b0..7b1ce60 100644 --- a/app/views/pdfresources/_form.html.erb +++ b/app/views/pdfresources/_form.html.erb @@ -31,24 +31,49 @@ <div class="my-5"> <%= required_label_tag(form, :pdfs) %> + <% if pdfresource.pdfs.any? %> + <div class="mb-4 p-4 bg-gray-50 rounded-lg"> + <h3 class="font-medium text-gray-700">Current PDFs:</h3> + <ul class="list-disc ml-5 text-gray-600"> + <% pdfresource.pdfs.each do |pdf| %> + <li><%= pdf.filename %></li> + <% end %> + </ul> + </div> + <% end %> <%= form.file_field :pdfs, multiple: true, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %> - <p class="text-sm text-gray-700">You can upload up to 10 PDFs per resource. The original files were:</p> - <ul class="list-disc font-bold text-green-500"> - <% pdfresource.pdfs.each do |pdf| %> - <li><%= pdf.filename %></li> + <p class="text-sm text-gray-700"> + <% if pdfresource.persisted? %> + Upload new PDFs only if you want to replace the existing ones. Leave empty to keep current files. + <% else %> + You can upload up to 10 PDFs per resource. <% end %> - </ul> + </p> </div> <div class="my-5"> <%= required_label_tag(form, :thumbnails) %> + <% if pdfresource.thumbnails.any? %> + <div class="mb-4 p-4 bg-gray-50 rounded-lg"> + <h3 class="font-medium text-gray-700">Current Thumbnails:</h3> + <div class="grid grid-cols-2 md:grid-cols-3 gap-4 mt-2"> + <% pdfresource.thumbnails.each do |thumbnail| %> + <div class="relative"> + <%= image_tag thumbnail, class: "rounded-lg shadow-sm" %> + <p class="text-xs text-gray-500 mt-1"><%= thumbnail.filename %></p> + </div> + <% end %> + </div> + </div> + <% end %> <%= form.file_field :thumbnails, multiple: true, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %> - <p class="text-sm text-gray-700">You can upload up to 10 thumbnails per resource. The original files were:</p> - <ul class="list-disc font-bold text-green-500"> - <% pdfresource.thumbnails.each do |thumbnail| %> - <li><%= thumbnail.filename %></li> - <% end.to_sentence %> - </ul> + <p class="text-sm text-gray-700"> + <% if pdfresource.persisted? %> + Upload new thumbnails only if you want to replace the existing ones. Leave empty to keep current files. + <% else %> + You can upload up to 10 thumbnails per resource. + <% end %> + </p> </div> <div class="my-5"> @@ -84,7 +109,12 @@ <%= form.number_field :feature_slot, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %> </div> - <div class="inline"> - <%= form.submit class: "rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium cursor-pointer" %> + <div class="flex gap-4 mt-8"> + <%= form.submit pdfresource.persisted? ? "Update" : "Create", + class: "bg-blue-500 hover:bg-blue-600 text-white font-semibold py-2 px-6 rounded-lg cursor-pointer" %> + + <%= link_to "Cancel", + pdfresource.persisted? ? pdfresource_path(pdfresource) : pdfresources_path, + class: "bg-gray-500 hover:bg-gray-600 text-white font-semibold py-2 px-6 rounded-lg" %> </div> <% end %> diff --git a/app/views/pdfresources/edit.html.erb b/app/views/pdfresources/edit.html.erb index bab5c81..9e3427e 100644 --- a/app/views/pdfresources/edit.html.erb +++ b/app/views/pdfresources/edit.html.erb @@ -1,8 +1,13 @@ <div class="mx-auto md:w-1/2 w-full"> - <h1 class="font-bold text-4xl">Editing <%= @pdfresource.name %> </h1> + <h1 class="font-bold text-4xl">Editing <%= @pdfresource.name %></h1> <%= render "form", pdfresource: @pdfresource %> - <%= link_to "Show this pdfresource", @pdfresource, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %> - <%= link_to "Back to pdfresources", pdfresources_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %> + <div class="flex gap-4 mt-8"> + <%= link_to "Back to resource", @pdfresource, + class: "bg-gray-500 hover:bg-gray-600 text-white font-semibold py-2 px-6 rounded-lg" %> + + <%= link_to "Back to all resources", pdfresources_path, + class: "bg-gray-500 hover:bg-gray-600 text-white font-semibold py-2 px-6 rounded-lg" %> + </div> </div> |