Module: DataAttributesHelper
- Defined in:
- app/helpers/data_attributes_helper.rb
Instance Method Summary collapse
- #add_data_attribute_link(object: nil, attribute: nil) ⇒ Object
- #data_attribute_annotation_tag(data_attribute) ⇒ Object
- #data_attribute_autocomplete_tag(data_attribute, term = nil) ⇒ Object
- #data_attribute_edit_link(data_attribute) ⇒ Object
- #data_attribute_link(data_attribute) ⇒ Object
- #data_attribute_list_tag(object) ⇒ Object
-
#data_attribute_predicate_tag(data_attribute) ⇒ Object
TODO deprecate.
- #data_attribute_tag(data_attribute) ⇒ Object
- #data_attributes_search_form ⇒ Object
Instance Method Details
#add_data_attribute_link(object: nil, attribute: nil) ⇒ Object
42 43 44 45 46 47 |
# File 'app/helpers/data_attributes_helper.rb', line 42 def add_data_attribute_link(object: nil, attribute: nil) link_to('Add data attribute', new_data_attribute_path( data_attribute: { attribute_subject_type: object.class.base_class.name, attribute_subject_id: object.id})) if object.has_data_attributes? end |
#data_attribute_annotation_tag(data_attribute) ⇒ Object
8 9 10 11 12 |
# File 'app/helpers/data_attributes_helper.rb', line 8 def data_attribute_annotation_tag(data_attribute) return nil if data_attribute.nil? s = (data_attribute_predicate_tag(data_attribute) + ': ' + content_tag(:span, data_attribute.value, class: [:annotation__data_attribute_value]) ).html_safe content_tag(:span, s.html_safe, class: [:annotation__data_attribute]) end |
#data_attribute_autocomplete_tag(data_attribute, term = nil) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/helpers/data_attributes_helper.rb', line 14 def data_attribute_autocomplete_tag(data_attribute, term = nil) return nil if data_attribute.nil? s = [ [ content_tag(:span, data_attribute.predicate_name, class: [:feedback, 'feedback-thin', 'feedback-primary']), content_tag(:span, data_attribute.value, class: [:feedback, 'feedback-thin', 'feedback-primary']), content_tag(:span, data_attribute.type, class: [:feedback, 'feedback-thin', 'feedback-secondary']), content_tag(:span, data_attribute.attribute_subject_type, class: [:feedback, 'feedback-thin', 'feedback-light'])].join(' '), content_tag(:div, object_tag(data_attribute.annotated_object.)) ].join mark_tag(s, term) end |
#data_attribute_edit_link(data_attribute) ⇒ Object
58 59 60 61 62 63 64 |
# File 'app/helpers/data_attributes_helper.rb', line 58 def data_attribute_edit_link(data_attribute) if data_attribute..editable? link_to 'Edit', edit_data_attribute_path(data_attribute) else content_tag(:em, 'Edit') end end |
#data_attribute_link(data_attribute) ⇒ Object
49 50 51 52 |
# File 'app/helpers/data_attributes_helper.rb', line 49 def data_attribute_link(data_attribute) return nil if data_attribute.nil? link_to(object_tag(data_attribute).html_safe, data_attribute.annotated_object.) end |
#data_attribute_list_tag(object) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'app/helpers/data_attributes_helper.rb', line 32 def data_attribute_list_tag(object) return nil unless object.has_data_attributes? && object.data_attributes.any? content_tag(:h3, 'Data attributes') + content_tag(:ul, class: 'annotations__data_attribute_list') do object.data_attributes.collect{|a| content_tag(:li, data_attribute_annotation_tag(a)) }.join.html_safe end end |
#data_attribute_predicate_tag(data_attribute) ⇒ Object
TODO deprecate
27 28 29 30 |
# File 'app/helpers/data_attributes_helper.rb', line 27 def data_attribute_predicate_tag(data_attribute) return nil if data_attribute.nil? data_attribute.predicate_name end |
#data_attribute_tag(data_attribute) ⇒ Object
3 4 5 6 |
# File 'app/helpers/data_attributes_helper.rb', line 3 def data_attribute_tag(data_attribute) return nil if data_attribute.nil? (data_attribute.predicate_name + ' ' + data_attribute.value + ' on ' + object_tag(data_attribute.annotated_object) ).html_safe end |
#data_attributes_search_form ⇒ Object
54 55 56 |
# File 'app/helpers/data_attributes_helper.rb', line 54 def data_attributes_search_form render('/data_attributes/quick_search_form') end |