Module: SqedDepictionsHelper
- Defined in:
- app/helpers/sqed_depictions_helper.rb
Instance Method Summary collapse
- #sqed_card_link(sqed_depiction) ⇒ Object
- #sqed_depiction_buffered_determination_images(collection_object) ⇒ Object
- #sqed_depiction_collecting_event_label_thumb_preview(sqed_depiction) ⇒ Object
- #sqed_depiction_link(sqed_depiction) ⇒ Object
- #sqed_depiction_tag(sqed_depiction) ⇒ Object
- #sqed_depiction_thumb_navigator(sqed_depiction, before = 3, after = 3) ⇒ Object
- #sqed_done_tag(project_id) ⇒ Object
- #sqed_first_with_data_tag ⇒ Object
- #sqed_first_without_data_tag ⇒ Object
- #sqed_last_by_user_tag ⇒ Object
- #sqed_last_with_data_tag ⇒ Object
- #sqed_last_without_data_tag ⇒ Object
- #sqed_not_done_tag(project_id) ⇒ Object
- #sqed_previous_next_links(sqed_depiction) ⇒ Object
- #sqed_waxy_layout(sqed_depictions) ⇒ Object
- #sqed_waxy_legend_section_tag(position, label) ⇒ Object
- #sqed_waxy_legend_tag ⇒ Object
-
#sqed_waxy_metadata(sqed_depiction) ⇒ Object
Array.
Instance Method Details
#sqed_card_link(sqed_depiction) ⇒ Object
132 133 134 |
# File 'app/helpers/sqed_depictions_helper.rb', line 132 def sqed_card_link(sqed_depiction) link_to(sqed_depiction.id, sqed_depiction_breakdown_task_path(sqed_depiction), 'data-turbolinks' => 'false') end |
#sqed_depiction_buffered_determination_images(collection_object) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/helpers/sqed_depictions_helper.rb', line 31 def sqed_depiction_buffered_determination_images(collection_object) return nil if collection_object.sqed_depictions.empty? d = [] collection_object.sqed_depictions.each do |s| begin result = Vendor::SqedToTaxonworks::Result.new( depiction_id: s.depiction.id, ) return nil unless result.sqed..values.include?(:determination_labels) if t = result.image_path_for_small_image(:determination_labels) d.push({ depiction_id: s.depiction.id, image_id: s.depiction.image_id, thumbnail: t, large: result.image_path_for_large_image(:determination_labels) }) end end rescue return [] end d end |
#sqed_depiction_collecting_event_label_thumb_preview(sqed_depiction) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/helpers/sqed_depictions_helper.rb', line 15 def sqed_depiction_collecting_event_label_thumb_preview(sqed_depiction) return content_tag(:div, 'no depiction provided', class: :warning) if sqed_depiction.nil? section = sqed_depiction.collecting_event_sections.first return content_tag(:div, 'no collecting event label data imaged', class: :warning) if section.nil? begin result = Vendor::SqedToTaxonworks::Result.new( depiction_id: sqed_depiction.depiction.id, ) return image_tag(result.image_path_for_large_image(section), id: 'little1', class: 'little_image clickable') rescue return content_tag(:div, link_to('Error parsing.', depiction_path(sqed_depiction.depiction)), class: :warning) end end |
#sqed_depiction_link(sqed_depiction) ⇒ Object
10 11 12 13 |
# File 'app/helpers/sqed_depictions_helper.rb', line 10 def sqed_depiction_link(sqed_depiction) return nil if sqed_depiction.nil? link_to(sqed_depiction_tag(sqed_depiction), sqed_depiction.depiction) end |
#sqed_depiction_tag(sqed_depiction) ⇒ Object
5 6 7 8 |
# File 'app/helpers/sqed_depictions_helper.rb', line 5 def sqed_depiction_tag(sqed_depiction) return nil if sqed_depiction.nil? image_tag(sqed_depiction.depiction.image.image_file.url(:thumb)) + ' on ' + object_tag(sqed_depiction.depiction.depiction_object.) end |
#sqed_depiction_thumb_navigator(sqed_depiction, before = 3, after = 3) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'app/helpers/sqed_depictions_helper.rb', line 57 def sqed_depiction_thumb_navigator(sqed_depiction, before = 3, after = 3) around = sqed_depiction.nearby_sqed_depictions(before, after) around[:before].reverse.collect{|s| link_to(sqed_depiction_collecting_event_label_thumb_preview(s), collection_object_buffered_data_breakdown_task_path(s.depiction.depiction_object)) }.join().html_safe + content_tag(:div, ' this record ', class: 'sqed_thumb_nav_current') + around[:after].collect{|s| link_to(sqed_depiction_collecting_event_label_thumb_preview(s), collection_object_buffered_data_breakdown_task_path(s.depiction.depiction_object), 'data-turbolinks' => 'false') }.join().html_safe end |
#sqed_done_tag(project_id) ⇒ Object
71 72 73 |
# File 'app/helpers/sqed_depictions_helper.rb', line 71 def sqed_done_tag(project_id) SqedDepiction.where(project_id: project_id).count - SqedDepiction.without_collection_object_data.where(project_id: project_id).count end |
#sqed_first_with_data_tag ⇒ Object
110 111 112 113 114 115 116 |
# File 'app/helpers/sqed_depictions_helper.rb', line 110 def sqed_first_with_data_tag if o = SqedDepiction.where(project_id: sessions_current_project_id).with_collection_object_data.first content_tag(:span, ('First with data: ' + sqed_card_link(o)).html_safe, class: [:feedback, 'feedback-success', 'feedback-thin']) else nil end end |
#sqed_first_without_data_tag ⇒ Object
102 103 104 105 106 107 108 |
# File 'app/helpers/sqed_depictions_helper.rb', line 102 def sqed_first_without_data_tag if o = SqedDepiction.where(project_id: sessions_current_project_id).without_collection_object_data.first content_tag(:span, ('First without data: ' + sqed_card_link(o)).html_safe, class: [:feedback, 'feedback-warning', 'feedback-thin']) else nil end end |
#sqed_last_by_user_tag ⇒ Object
118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'app/helpers/sqed_depictions_helper.rb', line 118 def sqed_last_by_user_tag if o = SqedDepiction.joins(:collection_object) .where( project_id: sessions_current_project_id, updated_by_id: sessions_current_user_id) .with_collection_object_data .order('collection_objects.updated_at') .first content_tag(:span, ('Last update by you: ' + sqed_card_link(o)).html_safe, class: [:feedback, 'feedback-success', 'feedback-thin']) else nil end end |
#sqed_last_with_data_tag ⇒ Object
86 87 88 89 90 91 92 |
# File 'app/helpers/sqed_depictions_helper.rb', line 86 def sqed_last_with_data_tag if o = SqedDepiction.with_collection_object_data.where(project_id: sessions_current_project_id).last content_tag(:span, ('Last with data: ' + sqed_card_link(o)).html_safe, class: [:feedback, 'feedback-success', 'feedback-thin']) else nil end end |
#sqed_last_without_data_tag ⇒ Object
94 95 96 97 98 99 100 |
# File 'app/helpers/sqed_depictions_helper.rb', line 94 def sqed_last_without_data_tag if o = SqedDepiction.where(project_id: sessions_current_project_id).without_collection_object_data.last content_tag(:span, ('Last without data: ' + sqed_card_link(o)).html_safe, class: [:feedback, 'feedback-warning', 'feedback-thin']) else nil end end |
#sqed_not_done_tag(project_id) ⇒ Object
75 76 77 |
# File 'app/helpers/sqed_depictions_helper.rb', line 75 def sqed_not_done_tag(project_id) SqedDepiction.without_collection_object_data.where(project_id: project_id).count end |
#sqed_previous_next_links(sqed_depiction) ⇒ Object
79 80 81 82 83 84 |
# File 'app/helpers/sqed_depictions_helper.rb', line 79 def sqed_previous_next_links(sqed_depiction) around = sqed_depiction.nearby_sqed_depictions(1, 1) a = content_tag(:li, link_to('Previous', sqed_depiction_breakdown_task_path(around[:before].first), 'data-turbolinks' => 'false') ) if around[:before].any? b = content_tag(:li, link_to('Next', sqed_depiction_breakdown_task_path(around[:after].first), 'data-turbolinks' => 'false')) if around[:after].any? [a,b].compact.join.html_safe end |
#sqed_waxy_layout(sqed_depictions) ⇒ Object
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'app/helpers/sqed_depictions_helper.rb', line 136 def sqed_waxy_layout(sqed_depictions) layout = Waxy::Geometry::Layout.new( Waxy::Geometry::Orientation::LAYOUT_POINTY, Waxy::Geometry::Point.new(20,20), # size Waxy::Geometry::Point.new(20,20), # start 9 # padding ) = [] sqed_depictions.each do |i| a = Waxy::Meta.new a.size = (i) a.stroke = i.in_progress? ? 'purple' : 'grey' a.link = i.in_progress? && !(i.updated_by_id == sessions_current_user_id) ? nil : sqed_depiction_breakdown_task_path(i).html_safe a.link_title = "#{i.id.to_s} created #{time_ago_in_words(i.created_at)} ago by #{user_tag(i.creator)}" .unshift a end t = sqed_depictions.size.to_f rows = t.divmod(10).first + 1 h = ((t.divmod(10).first + 1) * 40.0) c = Waxy::Render::Svg::Canvas.new(520, h.to_i) c.body << Waxy::Render::Svg.rectangle(layout, , 9, rows ) c.to_svg.html_safe end |
#sqed_waxy_legend_section_tag(position, label) ⇒ Object
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
# File 'app/helpers/sqed_depictions_helper.rb', line 166 def sqed_waxy_legend_section_tag(position, label) layout = Waxy::Geometry::Layout.new( Waxy::Geometry::Orientation::LAYOUT_POINTY, Waxy::Geometry::Point.new(10,10), # size Waxy::Geometry::Point.new(10,10), # start ) a = Waxy::Meta.new a.stroke = 'grey' a.size = (0..5).collect{|s| position == s ? 1.0 : 0 } = [a] c = Waxy::Render::Svg::Canvas.new(35, 35) c.body << Waxy::Render::Svg.rectangle(layout, ) tag.figure do c.to_svg.html_safe + tag.(label) end end |
#sqed_waxy_legend_tag ⇒ Object
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
# File 'app/helpers/sqed_depictions_helper.rb', line 200 def sqed_waxy_legend_tag l = '' [ [ 0, 'Local identifier(s)' ], [ 1, 'Buffered collecting event' ], [ 2, 'Buffered determination' ], [ 3, 'Buffered other labels' ], [ 4, 'Collecting event' ], [ 5, 'Taxon determination(s)'] ].each do |a| l << sqed_waxy_legend_section_tag(a[0], a[1]) end tag.div do tag.h3('Legend') + l.html_safe end end |
#sqed_waxy_metadata(sqed_depiction) ⇒ Object
Returns Array.
188 189 190 191 192 193 194 195 196 197 198 |
# File 'app/helpers/sqed_depictions_helper.rb', line 188 def (sqed_depiction) o = sqed_depiction.depiction_object [ (o.identifiers.local.any? ? 1 : 0), (o.buffered_collecting_event.blank? ? 0 : 1), (o.buffered_determinations.blank? ? 0 : 1), (o.buffered_other_labels.blank? ? 0 : 1), (o.collecting_event_id ? 1 : 0), (o.taxon_determinations.any? ? 1 : 0) ] end |