Use polymorphic routes to manage cards

We use a different logic to load the card depending on the controller
we're using, and then share the rest of the code. This way we simplify
the code a bit, since we don't have to check for the page_id parameter.
This commit is contained in:
Javi Martín
2021-01-06 20:09:36 +01:00
parent 04e817e696
commit 4c0bb894eb
12 changed files with 99 additions and 79 deletions

View File

@@ -17,8 +17,6 @@
<% end %>
</td>
<td>
<%= render Admin::TableActionsComponent.new(card,
edit_path: edit_admin_widget_card_path(card, page_id: params[:page_id])
) %>
<%= render Admin::TableActionsComponent.new(card) %>
</td>
</tr>

View File

@@ -8,7 +8,7 @@
<div class="float-right">
<%= link_to t("admin.site_customization.pages.cards.create_card"),
new_admin_widget_card_path(page_id: params[:page_id]), class: "button" %>
new_admin_site_customization_page_widget_card_path(@page), class: "button" %>
</div>
<% if @cards.present? %>

View File

@@ -30,7 +30,7 @@
<td>
<%= render Admin::TableActionsComponent.new(page) do |actions| %>
<%= actions.link_to t("admin.site_customization.pages.page.see_cards"),
admin_site_customization_page_cards_path(page),
admin_site_customization_page_widget_cards_path(page),
class: "cards-link" %>
<% if page.status == "published" %>