Module: Workarea::Admin::ImportsHelper
- Defined in:
- app/helpers/workarea/admin/imports_helper.rb
Instance Method Summary collapse
- #render_embedded_validation_for(klass, validator) ⇒ Object
- #render_field_validation_for(validator) ⇒ Object
- #render_import_format_notes_for(format) ⇒ Object
- #render_validations_for(klass) ⇒ Object
Instance Method Details
#render_embedded_validation_for(klass, validator) ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'app/helpers/workarea/admin/imports_helper.rb', line 32 def (klass, validator) name = validator.attributes.first.to_s relation = klass.relations[name] return unless relation. content = render_validations_for(relation.klass) name_content = content_tag(:code, name) content_tag(:li, "#{name_content}: #{content}".html_safe) if content.present? end |
#render_field_validation_for(validator) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/helpers/workarea/admin/imports_helper.rb', line 17 def render_field_validation_for(validator) name = validator.class.name.demodulize.gsub(/Validator/, '') attr_content = content_tag(:code, validator.attributes.to_sentence) result = t( 'workarea.admin.imports_helper.field_validation_html', type: name.downcase, field: attr_content ).html_safe result << " #{validator.options}" if validator..present? content_tag(:li, result) end |
#render_import_format_notes_for(format) ⇒ Object
43 44 45 46 47 |
# File 'app/helpers/workarea/admin/imports_helper.rb', line 43 def render_import_format_notes_for(format) render("workarea/admin/data_file_imports/#{format.slug}_notes") rescue ActionView::MissingTemplate # It's ok if there aren't any notes to render end |
#render_validations_for(klass) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'app/helpers/workarea/admin/imports_helper.rb', line 4 def render_validations_for(klass) results = ''.html_safe = klass.validators.select do |valiator| valiator.is_a?(Mongoid::Validatable::AssociatedValidator) end field_validators = klass.validators - field_validators.each { |v| results << render_field_validation_for(v) } .each { |v| results << (klass, v).to_s } results.present? ? content_tag(:ul, results) : '' end |