Module: Avo::ResourcesHelper

Instance Method Summary collapse

Instance Method Details

#field_wrapper(**args, &block) ⇒ Object Also known as: edit_field_wrapper, show_field_wrapper



23
24
25
26
27
# File 'app/helpers/avo/resources_helper.rb', line 23

def field_wrapper(**args, &block)
  render Avo::FieldWrapperComponent.new(**args) do
    capture(&block)
  end
end

#filter_wrapper(name: nil, index: nil, **args, &block) ⇒ Object



31
32
33
34
35
36
37
38
# File 'app/helpers/avo/resources_helper.rb', line 31

def filter_wrapper(name: nil, index: nil, **args, &block)
  render layout: "layouts/avo/filter_wrapper", locals: {
    name: name,
    index: index
  } do
    capture(&block)
  end
end

#index_field_wrapper(**args, &block) ⇒ Object



17
18
19
20
21
# File 'app/helpers/avo/resources_helper.rb', line 17

def index_field_wrapper(**args, &block)
  render Index::FieldWrapperComponent.new(**args) do
    capture(&block)
  end
end

#item_selector_data_attributes(resource, controller: "") ⇒ Object



40
41
42
43
44
45
46
# File 'app/helpers/avo/resources_helper.rb', line 40

def item_selector_data_attributes(resource, controller: "")
  {
    resource_name: resource.model_key,
    resource_id: resource.record.to_param,
    controller: "item-selector #{controller}"
  }
end

#resource_grid(resources, resource) ⇒ Object



10
11
12
13
14
15
# File 'app/helpers/avo/resources_helper.rb', line 10

def resource_grid(resources, resource)
  render partial: "avo/partials/resource_grid", locals: {
    resources: resources,
    resource: resource
  }
end

#resource_show_path(resource:, parent_resource: nil, parent_record: nil, parent_or_child_resource: nil) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
# File 'app/helpers/avo/resources_helper.rb', line 48

def resource_show_path(resource:, parent_resource: nil, parent_record: nil, parent_or_child_resource: nil)
  args = {}

  if parent_record.present?
    args = {
      via_resource_class: parent_resource.class.to_s,
      via_record_id: parent_record.to_param
    }
  end

  resource_path(record: resource.record, resource: parent_or_child_resource, **args)
end

#resource_table(resources, resource) ⇒ Object



3
4
5
6
7
8
# File 'app/helpers/avo/resources_helper.rb', line 3

def resource_table(resources, resource)
  render partial: "avo/partials/resource_table", locals: {
    resources: resources,
    resource: resource
  }
end