Module: Locomotive::CustomFieldsHelper
- Defined in:
- app/helpers/locomotive/custom_fields_helper.rb
Instance Method Summary collapse
- #options_for_content_type ⇒ Object
- #options_for_content_type_inverse_of ⇒ Object
- #options_for_custom_field_type ⇒ Object
- #options_for_group_by_field(content_type) ⇒ Object
- #options_for_label_field(content_type) ⇒ Object
- #options_for_order_by(content_type) ⇒ Object
- #options_for_order_direction ⇒ Object
- #options_for_text_formatting ⇒ Object
Instance Method Details
#options_for_content_type ⇒ Object
45 46 47 48 49 |
# File 'app/helpers/locomotive/custom_fields_helper.rb', line 45 def current_site.content_types.map do |c| [c.name, c.entries_class_name] end.compact end |
#options_for_content_type_inverse_of ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'app/helpers/locomotive/custom_fields_helper.rb', line 51 def {}.tap do |hash| current_site.content_types.where(:'entries_custom_fields.type'.in => %w(belongs_to many_to_many)).each do |content_type| content_type.entries_custom_fields.each do |field| if %w(belongs_to many_to_many).include?(field.type) type = field.type == 'belongs_to' ? 'has_many' : field.type hash[type] ||= [] hash[type] << { label: field.label, name: field.name, class_name: content_type.entries_class_name } end end end end end |
#options_for_custom_field_type ⇒ Object
4 5 6 7 8 |
# File 'app/helpers/locomotive/custom_fields_helper.rb', line 4 def %w(string text integer float boolean email date date_time file tags select belongs_to has_many many_to_many).map do |type| [t("custom_fields.type.#{type}"), type] end end |
#options_for_group_by_field(content_type) ⇒ Object
18 19 20 21 22 23 24 |
# File 'app/helpers/locomotive/custom_fields_helper.rb', line 18 def (content_type) content_type.ordered_entries_custom_fields.find_all do |field| %w(select belongs_to).include?(field.type) end.map do |field| [field.label, field._id] end end |
#options_for_label_field(content_type) ⇒ Object
10 11 12 13 14 15 16 |
# File 'app/helpers/locomotive/custom_fields_helper.rb', line 10 def (content_type) content_type.ordered_entries_custom_fields.find_all do |field| %w(file string email date date_time).include?(field.type) end.map do |field| [field.label, field._id] end end |
#options_for_order_by(content_type) ⇒ Object
26 27 28 29 30 31 |
# File 'app/helpers/locomotive/custom_fields_helper.rb', line 26 def (content_type) = %w{created_at updated_at _position}.map do |type| [t("locomotive.content_types.form.order_by.#{type.gsub(/^_/, '')}"), type] end + (content_type) end |
#options_for_order_direction ⇒ Object
33 34 35 36 37 |
# File 'app/helpers/locomotive/custom_fields_helper.rb', line 33 def %w(asc desc).map do |direction| [t("locomotive.content_types.form.order_direction.#{direction}"), direction] end end |
#options_for_text_formatting ⇒ Object
39 40 41 42 43 |
# File 'app/helpers/locomotive/custom_fields_helper.rb', line 39 def %w(none html).map do |option| [t("locomotive.custom_fields.text_formatting.#{option}"), option] end end |