Module: Para::Component::CrudDecorator

Includes:
BaseDecorator
Defined in:
app/decorators/para/component/crud_decorator.rb

Instance Method Summary collapse

Instance Method Details

#page_container_classObject



31
32
33
# File 'app/decorators/para/component/crud_decorator.rb', line 31

def page_container_class
  history? ? 'col-md-8' : super
end

#path(namespace: :resources, **options) ⇒ Object



6
7
8
9
# File 'app/decorators/para/component/crud_decorator.rb', line 6

def path(namespace: :resources, **options)
  options[:model] ||= model_singular_route_key
  find_path([:admin, self, namespace], options)
end

#relation_path(controller_or_resource, *nested_resources, **options) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/decorators/para/component/crud_decorator.rb', line 11

def relation_path(controller_or_resource, *nested_resources, **options)
  nested = nested_resources.any?
  id_key = nested ? :resource_id : :id

  if (id = extract_id_from(controller_or_resource))
    options[id_key] = id
  elsif Hash === controller_or_resource
    options = controller_or_resource
  end

  route_key = route_key_for(options[id_key], options)
  options[:model] = model_singular_route_key

  data = [:admin, self, route_key].compact + nested_resources

  options[:action] = action_option_for(options, nested: nested)

  find_path(data, options)
end