Module: Adminpanel::Base::ClassMethods
- Defined in:
- app/models/concerns/adminpanel/base.rb
Overview
instance methods static(class) methods
Instance Method Summary collapse
- #display_attributes(type) ⇒ Object
- #display_name ⇒ Object
- #fb_share? ⇒ Boolean
- #form_attributes ⇒ Object
- #gallery_children ⇒ Object
- #get_attribute_label(field) ⇒ Object
- #get_image_relationship ⇒ Object
- #has_images? ⇒ Boolean
- #has_route?(route) ⇒ Boolean
- #icon ⇒ Object
- #mount_images(relation) ⇒ Object
- #relationships_of(type_property) ⇒ Object
- #routes_options ⇒ Object
- #twitter_share? ⇒ Boolean
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_name ⇒ Object
16 17 18 |
# File 'app/models/concerns/adminpanel/base.rb', line 16 def display_name 'please overwrite self.display_name' end |
#fb_share? ⇒ Boolean
103 104 105 |
# File 'app/models/concerns/adminpanel/base.rb', line 103 def fb_share? false end |
#form_attributes ⇒ Object
12 13 14 |
# File 'app/models/concerns/adminpanel/base.rb', line 12 def form_attributes [] end |
#gallery_children ⇒ Object
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_relationship ⇒ Object
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
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
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 |
#icon ⇒ Object
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_options ⇒ Object
88 89 90 91 92 93 |
# File 'app/models/concerns/adminpanel/base.rb', line 88 def { path: ActiveSupport::Inflector.transliterate( display_name.pluralize(I18n.default_locale).downcase ).tr(' ', '-') } end |
#twitter_share? ⇒ Boolean
107 108 109 |
# File 'app/models/concerns/adminpanel/base.rb', line 107 def twitter_share? false end |