From 9cc0ad0ba90d230bc431135aaadeba4efe5a63e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Thu, 25 Feb 2021 17:20:01 +0100 Subject: [PATCH] Allow cards table actions to receive options Just like we sometimes override options in the generic table actions component, we're going to do the same thing with the cards table actions. --- app/components/admin/widget/cards/row_component.html.erb | 2 +- app/components/admin/widget/cards/row_component.rb | 5 +++-- app/components/admin/widget/cards/table_component.html.erb | 2 +- app/components/admin/widget/cards/table_component.rb | 5 +++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/components/admin/widget/cards/row_component.html.erb b/app/components/admin/widget/cards/row_component.html.erb index 94025a7b1..974753dc8 100644 --- a/app/components/admin/widget/cards/row_component.html.erb +++ b/app/components/admin/widget/cards/row_component.html.erb @@ -17,6 +17,6 @@ <% end %> - <%= render Admin::TableActionsComponent.new(card) %> + <%= render Admin::TableActionsComponent.new(card, options) %> diff --git a/app/components/admin/widget/cards/row_component.rb b/app/components/admin/widget/cards/row_component.rb index fed569949..58343d41f 100644 --- a/app/components/admin/widget/cards/row_component.rb +++ b/app/components/admin/widget/cards/row_component.rb @@ -1,7 +1,8 @@ class Admin::Widget::Cards::RowComponent < ApplicationComponent - attr_reader :card + attr_reader :card, :options - def initialize(card) + def initialize(card, **options) @card = card + @options = options end end diff --git a/app/components/admin/widget/cards/table_component.html.erb b/app/components/admin/widget/cards/table_component.html.erb index d7fc9e579..3a3cf9720 100644 --- a/app/components/admin/widget/cards/table_component.html.erb +++ b/app/components/admin/widget/cards/table_component.html.erb @@ -11,7 +11,7 @@ <% cards.each do |card| %> - <%= render Admin::Widget::Cards::RowComponent.new(card) %> + <%= render Admin::Widget::Cards::RowComponent.new(card, options) %> <% end %> diff --git a/app/components/admin/widget/cards/table_component.rb b/app/components/admin/widget/cards/table_component.rb index eba23de30..efdb279c7 100644 --- a/app/components/admin/widget/cards/table_component.rb +++ b/app/components/admin/widget/cards/table_component.rb @@ -1,9 +1,10 @@ class Admin::Widget::Cards::TableComponent < ApplicationComponent - attr_reader :cards, :no_cards_message + attr_reader :cards, :no_cards_message, :options - def initialize(cards, no_cards_message:) + def initialize(cards, no_cards_message:, **options) @cards = cards @no_cards_message = no_cards_message + @options = options end private