Module: Adminpanel::Base::ClassMethods

Defined in:
app/models/concerns/adminpanel/base.rb

Overview

instance methods static(class) methods

Instance Method Summary collapse

Instance Method Details

#display_attributes(type) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'app/models/concerns/adminpanel/base.rb', line 31

def display_attributes(type)
  display_attributes = []
  form_attributes.each do |attribute|
    attribute.each do |name, properties|
      if properties['show'].nil? ||
        properties['show'] == 'true' ||
        properties['show'] == type
        display_attributes << attribute
      end
    end
  end

  return display_attributes
end

#display_nameObject



16
17
18
# File 'app/models/concerns/adminpanel/base.rb', line 16

def display_name
  'please overwrite self.display_name'
end

#fb_share?Boolean

Returns:

  • (Boolean)


103
104
105
# File 'app/models/concerns/adminpanel/base.rb', line 103

def fb_share?
  false
end

#form_attributesObject



12
13
14
# File 'app/models/concerns/adminpanel/base.rb', line 12

def form_attributes
  []
end


84
85
86
# File 'app/models/concerns/adminpanel/base.rb', line 84

def gallery_children
  nil
end

#get_attribute_label(field) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'app/models/concerns/adminpanel/base.rb', line 20

def get_attribute_label(field)
  form_attributes.each do |attribute|
    attribute.each do |name, properties|
      if name == field
        return properties["label"]
      end
    end
  end
  return "field #{field} 'label' property not found :("
end

#get_image_relationshipObject



57
58
59
60
61
62
63
64
65
66
# File 'app/models/concerns/adminpanel/base.rb', line 57

def get_image_relationship
  form_attributes.each do |fields|
  fields.each do |attribute, properties|
    if properties['type'] == 'adminpanel_file_field'
      return attribute
    end
  end
  end
  return false
end

#has_images?Boolean

Returns:

  • (Boolean)


46
47
48
49
50
51
52
53
54
55
# File 'app/models/concerns/adminpanel/base.rb', line 46

def has_images?
  form_attributes.each do |fields|
  fields.each do |attribute, properties|
    if properties['type'] == 'adminpanel_file_field'
      return true
    end
  end
  end
  return false
end

#has_route?(route) ⇒ Boolean

Returns:

  • (Boolean)


95
96
97
98
99
100
101
# File 'app/models/concerns/adminpanel/base.rb', line 95

def has_route?(route)
  if (!exlude?(route)) && include_route(route)
    true
  else
    false
  end
end

#iconObject



80
81
82
# File 'app/models/concerns/adminpanel/base.rb', line 80

def icon
  'truck'
end

#mount_images(relation) ⇒ Object



7
8
9
10
# File 'app/models/concerns/adminpanel/base.rb', line 7

def mount_images(relation)
  has_many relation, :dependent => :destroy
  accepts_nested_attributes_for relation, :allow_destroy => true
end

#relationships_of(type_property) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
# File 'app/models/concerns/adminpanel/base.rb', line 68

def relationships_of(type_property)
  classes_of_relation = []
  form_attributes.each do |fields|
  fields.each do |attribute, properties|
    if properties['type'] == type_property
      classes_of_relation << properties['model'].classify.constantize
    end
  end
  end
  return classes_of_relation
end

#routes_optionsObject



88
89
90
91
92
93
# File 'app/models/concerns/adminpanel/base.rb', line 88

def routes_options
  { path: ActiveSupport::Inflector.transliterate(
      display_name.pluralize(I18n.default_locale).downcase
    ).tr(' ', '-')
  }
end

#twitter_share?Boolean

Returns:

  • (Boolean)


107
108
109
# File 'app/models/concerns/adminpanel/base.rb', line 107

def twitter_share?
  false
end