From 06222c54c248a03d0b019db12bc365ab187e317a Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Thu, 14 Nov 2024 11:28:08 +0000 Subject: Adds nice reminders on the edit page re pdfs and thumbnails --- app/views/pdfresources/_form.html.erb | 56 +++++++++++++++++++++++++++-------- app/views/pdfresources/edit.html.erb | 11 +++++-- 2 files changed, 51 insertions(+), 16 deletions(-) (limited to 'app') 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 @@
<%= required_label_tag(form, :pdfs) %> + <% if pdfresource.pdfs.any? %> +
+

Current PDFs:

+
    + <% pdfresource.pdfs.each do |pdf| %> +
  • <%= pdf.filename %>
  • + <% end %> +
+
+ <% 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" %> -

You can upload up to 10 PDFs per resource. The original files were:

- +

<%= required_label_tag(form, :thumbnails) %> + <% if pdfresource.thumbnails.any? %> +
+

Current Thumbnails:

+
+ <% pdfresource.thumbnails.each do |thumbnail| %> +
+ <%= image_tag thumbnail, class: "rounded-lg shadow-sm" %> +

<%= thumbnail.filename %>

+
+ <% end %> +
+
+ <% 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" %> -

You can upload up to 10 thumbnails per resource. The original files were:

- +

+ <% 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 %> +

@@ -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" %>
-
- <%= form.submit class: "rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium cursor-pointer" %> +
+ <%= 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" %>
<% 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 @@
-

Editing <%= @pdfresource.name %>

+

Editing <%= @pdfresource.name %>

<%= 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" %> +
+ <%= 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" %> +
-- cgit v1.2.3