Class: Components::LinkList
- Inherits:
-
Base
- Object
- Base
- Components::LinkList
- Includes:
- Phlex::Rails::Helpers::LinkTo
- Defined in:
- app/components/link_list.rb
Instance Method Summary collapse
-
#initialize(links:, icons: true) ⇒ LinkList
constructor
A new instance of LinkList.
- #view_template ⇒ Object
Constructor Details
#initialize(links:, icons: true) ⇒ LinkList
Returns a new instance of LinkList.
9 10 11 12 |
# File 'app/components/link_list.rb', line 9 def initialize(links:, icons: true) @links = links @icons = icons end |
Instance Method Details
#view_template ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/components/link_list.rb', line 14 def view_template return if @links.empty? ul class: "list-unstyled" do @links.each do |link| if link.valid? li do Icon(icon: "link-45deg", role: "presentation") if @icons whitespace link_to( sanitize(link.text) || t("sites.%{site}" % {site: link.site}, default: "%{site}" % {site: link.site}), link.url, rel: "noreferrer" ) if link.deserializer.present? && policy(link.linkable).sync? whitespace link_to({action: "sync", id: link.linkable, link: link.id}, {method: :post}) do Icon(icon: "arrow-repeat", label: t("components.link_list.sync")) end Icon(icon: "exclamation-triangle-fill") if link.problems.exists? end end end end end end |