diff options
author | Matthew Lemon <y@yulqen.org> | 2024-11-14 11:20:00 +0000 |
---|---|---|
committer | Matthew Lemon <y@yulqen.org> | 2024-11-14 11:20:00 +0000 |
commit | c8d449c31b29b281a219512bdd5defd5e5ea20f3 (patch) | |
tree | 32f053272d42bdc56c277b400292448509f91345 | |
parent | 213bd45bb257f0f8fd6108f184b98519ecbf77e7 (diff) |
Adds Edit and Delete buttons to the show page for admin
-rw-r--r-- | app/views/pdfresources/edit.html.erb | 2 | ||||
-rw-r--r-- | 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 @@ -<div class="mx-auto md:w-2/3 w-full"> +<div class="mx-auto md:w-1/2 w-full"> <h1 class="font-bold text-4xl">Editing <%= @pdfresource.name %> </h1> <%= 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 @@ <p class="text-gray-700"><%= @pdfresource.description %></p> </div> - <%= button_to "Add to basket", '#', - class: "bg-blue-500 hover:bg-blue-600 text-white font-semibold py-2 px-6 rounded-lg" %> + <div class="flex gap-4"> + <%= 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 %> + </div> </div> </div> |