Class: TinyAdmin::Views::Actions::Show

Inherits:
DefaultLayout show all
Defined in:
lib/tiny_admin/views/actions/show.rb

Instance Attribute Summary collapse

Attributes inherited from DefaultLayout

#flash_component, #head_component, #messages, #navbar_component, #options, #title

Attributes inherited from BasicLayout

#content, #params, #widgets

Instance Method Summary collapse

Methods inherited from BasicLayout

#label_for, #update_attributes

Methods included from Utils

#humanize, #params_to_s, #prepare_page, #to_class

Instance Attribute Details

#actionsObject

Returns the value of attribute actions.



7
8
9
# File 'lib/tiny_admin/views/actions/show.rb', line 7

def actions
  @actions
end

#fieldsObject

Returns the value of attribute fields.



7
8
9
# File 'lib/tiny_admin/views/actions/show.rb', line 7

def fields
  @fields
end

#prepare_recordObject

Returns the value of attribute prepare_record.



7
8
9
# File 'lib/tiny_admin/views/actions/show.rb', line 7

def prepare_record
  @prepare_record
end

#recordObject

Returns the value of attribute record.



7
8
9
# File 'lib/tiny_admin/views/actions/show.rb', line 7

def record
  @record
end

#referenceObject

Returns the value of attribute reference.



7
8
9
# File 'lib/tiny_admin/views/actions/show.rb', line 7

def reference
  @reference
end

#slugObject

Returns the value of attribute slug.



7
8
9
# File 'lib/tiny_admin/views/actions/show.rb', line 7

def slug
  @slug
end

Instance Method Details

#view_templateObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/tiny_admin/views/actions/show.rb', line 14

def view_template
  super do
    div(class: 'show') {
      div(class: 'row') {
        div(class: 'col-4') {
          h1(class: 'title') { title }
        }
        div(class: 'col-8') {
          actions_buttons
        }
      }

      prepare_record.call(record).each do |key, value|
        field = fields[key]
        div(class: "field-#{field.name} row lh-lg") {
          if field
            div(class: 'field-header col-2') { field.options[:header] || field.title }
          end
          div(class: 'field-value col-10') {
            render TinyAdmin.settings.components[:field_value].new(field, value, record: record)
          }
        }
      end

      render TinyAdmin::Views::Components::Widgets.new(widgets)
    }
  end
end