Class: Crm::AttachmentsComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/crm/attachments_component.rb

Overview

ViewComponent: renders the attachments block.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context_object:, attach_url:, wrapped: true, skip_publications: false, multiple_files_allowed: true, template_options_for_select: nil, category_options_for_select: nil, disable_delete: false, context_class_name: nil, controller_path: nil, parent_form_id: nil) ⇒ AttachmentsComponent

Returns a new instance of AttachmentsComponent.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/components/crm/attachments_component.rb', line 8

def initialize(context_object:,
               attach_url:,
               wrapped: true,
               skip_publications: false,
               multiple_files_allowed: true,
               template_options_for_select: nil,
               category_options_for_select: nil,
               disable_delete: false,
               context_class_name: nil,
               controller_path: nil,
               parent_form_id: nil)
  super()
  @context_object = context_object
  @attach_url = attach_url
  @wrapped = wrapped
  @skip_publications = skip_publications
  @multiple_files_allowed = multiple_files_allowed
  @template_options_for_select = template_options_for_select
  @category_options_for_select = category_options_for_select
  @disable_delete = disable_delete
  @explicit_context_class_name = context_class_name || context_object.class.name
  @controller_path = controller_path
  @parent_form_id = parent_form_id
end

Instance Attribute Details

#attach_urlObject (readonly)

Returns the value of attribute attach_url.



5
6
7
# File 'app/components/crm/attachments_component.rb', line 5

def attach_url
  @attach_url
end

#category_options_for_selectObject (readonly)

Returns the value of attribute category_options_for_select.



5
6
7
# File 'app/components/crm/attachments_component.rb', line 5

def category_options_for_select
  @category_options_for_select
end

#context_objectObject (readonly)

Returns the value of attribute context_object.



5
6
7
# File 'app/components/crm/attachments_component.rb', line 5

def context_object
  @context_object
end

#disable_deleteObject (readonly)

Returns the value of attribute disable_delete.



5
6
7
# File 'app/components/crm/attachments_component.rb', line 5

def disable_delete
  @disable_delete
end

#multiple_files_allowedObject (readonly)

Returns the value of attribute multiple_files_allowed.



5
6
7
# File 'app/components/crm/attachments_component.rb', line 5

def multiple_files_allowed
  @multiple_files_allowed
end

#parent_form_idObject (readonly)

Returns the value of attribute parent_form_id.



5
6
7
# File 'app/components/crm/attachments_component.rb', line 5

def parent_form_id
  @parent_form_id
end

#skip_publicationsObject (readonly)

Returns the value of attribute skip_publications.



5
6
7
# File 'app/components/crm/attachments_component.rb', line 5

def skip_publications
  @skip_publications
end

#template_options_for_selectObject (readonly)

Returns the value of attribute template_options_for_select.



5
6
7
# File 'app/components/crm/attachments_component.rb', line 5

def template_options_for_select
  @template_options_for_select
end

#wrappedObject (readonly)

Returns the value of attribute wrapped.



5
6
7
# File 'app/components/crm/attachments_component.rb', line 5

def wrapped
  @wrapped
end

Instance Method Details

#attachments_container_idObject



53
54
55
# File 'app/components/crm/attachments_component.rb', line 53

def attachments_container_id
  "attachments-#{context_object_id}"
end

#context_class_nameObject



37
38
39
# File 'app/components/crm/attachments_component.rb', line 37

def context_class_name
  @explicit_context_class_name
end

#context_object_idObject



33
34
35
# File 'app/components/crm/attachments_component.rb', line 33

def context_object_id
  context_object.try(:id).to_i
end

#controller_pathObject



41
42
43
# File 'app/components/crm/attachments_component.rb', line 41

def controller_path
  @controller_path || context_object.class.name.tableize
end

#frame_idObject



49
50
51
# File 'app/components/crm/attachments_component.rb', line 49

def frame_id
  "attachments-frame-#{context_object_id}"
end


45
46
47
# File 'app/components/crm/attachments_component.rb', line 45

def modal_id
  "publication-picker-modal-#{context_object_id}"
end