From c8d449c31b29b281a219512bdd5defd5e5ea20f3 Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Thu, 14 Nov 2024 11:20:00 +0000 Subject: Adds Edit and Delete buttons to the show page for admin --- app/views/pdfresources/edit.html.erb | 2 +- app/views/pdfresources/show.html.erb | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/app/views/pdfresources/edit.html.erb b/app/views/pdfresources/edit.html.erb index aa8d60e..bab5c81 100644 --- a/app/views/pdfresources/edit.html.erb +++ b/app/views/pdfresources/edit.html.erb @@ -1,4 +1,4 @@ -
+

Editing <%= @pdfresource.name %>

<%= render "form", pdfresource: @pdfresource %> diff --git a/app/views/pdfresources/show.html.erb b/app/views/pdfresources/show.html.erb index a4e1d04..525e5dd 100644 --- a/app/views/pdfresources/show.html.erb +++ b/app/views/pdfresources/show.html.erb @@ -29,8 +29,20 @@

<%= @pdfresource.description %>

- <%= button_to "Add to basket", '#', - class: "bg-blue-500 hover:bg-blue-600 text-white font-semibold py-2 px-6 rounded-lg" %> +
+ <%= button_to "Add to basket", '#', + class: "bg-blue-500 hover:bg-blue-600 text-white font-semibold py-2 px-6 rounded-lg" %> + + <% if Current.session.user&.is_admin %> + <%= link_to "Edit", edit_pdfresource_path(@pdfresource), + class: "bg-gray-500 hover:bg-gray-600 text-white font-semibold py-2 px-6 rounded-lg" %> + + <%= button_to "Delete", @pdfresource, + method: :delete, + class: "bg-red-500 hover:bg-red-600 text-white font-semibold py-2 px-6 rounded-lg", + data: { turbo_confirm: "Are you sure you want to delete this resource?" } %> + <% end %> +
-- cgit v1.2.3