Class: Crm::AttachmentsComponent

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

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.



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

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.



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

def attach_url
  @attach_url
end

#category_options_for_selectObject (readonly)

Returns the value of attribute category_options_for_select.



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

def category_options_for_select
  @category_options_for_select
end

#context_objectObject (readonly)

Returns the value of attribute context_object.



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

def context_object
  @context_object
end

#disable_deleteObject (readonly)

Returns the value of attribute disable_delete.



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

def disable_delete
  @disable_delete
end

#multiple_files_allowedObject (readonly)

Returns the value of attribute multiple_files_allowed.



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

def multiple_files_allowed
  @multiple_files_allowed
end

#parent_form_idObject (readonly)

Returns the value of attribute parent_form_id.



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

def parent_form_id
  @parent_form_id
end

#skip_publicationsObject (readonly)

Returns the value of attribute skip_publications.



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

def skip_publications
  @skip_publications
end

#template_options_for_selectObject (readonly)

Returns the value of attribute template_options_for_select.



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

def template_options_for_select
  @template_options_for_select
end

#wrappedObject (readonly)

Returns the value of attribute wrapped.



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

def wrapped
  @wrapped
end

Instance Method Details

#attachments_container_idObject



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

def attachments_container_id
  "attachments-#{context_object_id}"
end

#context_class_nameObject



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

def context_class_name
  @explicit_context_class_name
end

#context_object_idObject



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

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

#controller_pathObject



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

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

#frame_idObject



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

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


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

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