Class: Crm::AttachmentsDisplayComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Crm::AttachmentsDisplayComponent
- Defined in:
- app/components/crm/attachments_display_component.rb
Overview
ViewComponent: renders the attachments display block.
Lists a record's uploads inside a Turbo Frame, wrapping each upload in a
UploadWrapperComponent with deletion disabled.
Instance Attribute Summary collapse
- #context_object ⇒ Object, String readonly
- #controller_path ⇒ Object, String readonly
Instance Method Summary collapse
-
#attachments_container_id ⇒ String
DOM id of the attachments grid container.
-
#context_object_id ⇒ Integer
Numeric id of the context object, used in DOM ids.
-
#frame_id ⇒ String
DOM id of the wrapping Turbo Frame.
-
#initialize(context_object:, controller_path: nil) ⇒ AttachmentsDisplayComponent
constructor
A new instance of AttachmentsDisplayComponent.
Constructor Details
#initialize(context_object:, controller_path: nil) ⇒ AttachmentsDisplayComponent
Returns a new instance of AttachmentsDisplayComponent.
15 16 17 18 19 |
# File 'app/components/crm/attachments_display_component.rb', line 15 def initialize(context_object:, controller_path: nil) super() @context_object = context_object @controller_path = controller_path || context_object.class.name.tableize end |
Instance Attribute Details
#context_object ⇒ Object, String (readonly)
10 11 12 |
# File 'app/components/crm/attachments_display_component.rb', line 10 def context_object @context_object end |
#controller_path ⇒ Object, String (readonly)
10 11 12 |
# File 'app/components/crm/attachments_display_component.rb', line 10 def controller_path @controller_path end |
Instance Method Details
#attachments_container_id ⇒ String
DOM id of the attachments grid container.
35 36 37 |
# File 'app/components/crm/attachments_display_component.rb', line 35 def "attachments-#{context_object_id}" end |
#context_object_id ⇒ Integer
Numeric id of the context object, used in DOM ids.
23 24 25 |
# File 'app/components/crm/attachments_display_component.rb', line 23 def context_object_id context_object.try(:id).to_i end |
#frame_id ⇒ String
DOM id of the wrapping Turbo Frame.
29 30 31 |
# File 'app/components/crm/attachments_display_component.rb', line 29 def frame_id "attachments-frame-#{context_object_id}" end |