Module: Koi::HeaderHelper
- Included in:
- HeaderComponent
- Defined in:
- app/helpers/koi/header_helper.rb
Instance Method Summary collapse
-
#actions_list {|Block| ... } ⇒ String?
This helper generates an accessible actions navigation structure with proper ARIA attributes for screen readers.
-
#breadcrumb_list {|Block| ... } ⇒ String?
This helper generates an accessible breadcrumb navigation structure with proper ARIA attributes for screen readers.
-
#link_to_archive_or_delete(model, archive_text: "Archive", delete_text: "Delete", confirm: "Are you sure?", url: polymorphic_path([:admin, model])) ⇒ String?
Conditionally creates an archive or delete link based on the record’s status.
-
#link_to_delete(model, text = "Delete", confirm: "Are you sure?", url: polymorphic_path([:admin, model])) ⇒ String?
Creates a delete link with confirmation.
Instance Method Details
#actions_list {|Block| ... } ⇒ String?
This helper generates an accessible actions navigation structure with proper ARIA attributes for screen readers. The action items should be provided as content within the block.
44 45 46 47 48 49 50 |
# File 'app/helpers/koi/header_helper.rb', line 44 def actions_list(**, &) return if (content = capture(&)).blank? tag.nav(**_koi_actions_attributes(**)) do tag.ul(content, class: "actions-list", role: "list") end end |
#breadcrumb_list {|Block| ... } ⇒ String?
This helper generates an accessible breadcrumb navigation structure with proper ARIA attributes for screen readers. The breadcrumb items should be provided as content within the block.
20 21 22 23 24 25 26 |
# File 'app/helpers/koi/header_helper.rb', line 20 def (**, &) return if (content = capture(&)).blank? tag.nav(**(**)) do tag.ol(content, class: "breadcrumbs-list", role: "list") end end |
#link_to_archive_or_delete(model, archive_text: "Archive", delete_text: "Delete", confirm: "Are you sure?", url: polymorphic_path([:admin, model])) ⇒ String?
Conditionally creates an archive or delete link based on the record’s status.
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'app/helpers/koi/header_helper.rb', line 87 def link_to_archive_or_delete(model, archive_text: "Archive", delete_text: "Delete", confirm: "Are you sure?", url: polymorphic_path([:admin, model]), **) raise ArgumentError unless model.respond_to?(:archived?) return unless model.persisted? if model.archived? link_to(delete_text, url, data: { turbo_method: :delete, turbo_confirm: confirm }, **) else link_to(archive_text, url, data: { turbo_method: :delete }, **) end end |
#link_to_delete(model, text = "Delete", confirm: "Are you sure?", url: polymorphic_path([:admin, model])) ⇒ String?
Creates a delete link with confirmation.
63 64 65 66 67 68 69 70 71 |
# File 'app/helpers/koi/header_helper.rb', line 63 def link_to_delete(model, text = "Delete", confirm: "Are you sure?", url: polymorphic_path([:admin, model]), **) return unless model.persisted? link_to(text, url, data: { turbo_method: :delete, turbo_confirm: confirm }, **) end |