Class: Components::ListsCard

Inherits:
Base
  • Object
show all
Includes:
Phlex::Rails::Helpers::LinkTo
Defined in:
app/components/lists_card.rb

Instance Method Summary collapse

Constructor Details

#initialize(listable:) ⇒ ListsCard

Returns a new instance of ListsCard.



8
9
10
# File 'app/components/lists_card.rb', line 8

def initialize(listable:)
  @listable = listable
end

Instance Method Details

#before_template ⇒ Object



16
17
18
19
# File 'app/components/lists_card.rb', line 16

def before_template
  @all_lists = policy_scope(current_user.lists.without_special).all
  @on_lists, @off_lists = @all_lists.partition { @listable.in? it.models }
end

#render? ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'app/components/lists_card.rb', line 12

def render?
  @listable.present?
end

#view_template ⇒ Object



21
22
23
24
25
26
27
28
# File 'app/components/lists_card.rb', line 21

def view_template
  Card title: t("components.lists_card.title"), variant: :secondary do
    div class: "card-text" do
      on_lists if @on_lists.any?
      add_dropdown
    end
  end
end