From 4d0f63bf7425be600a9ca7405bd160478d5b3071 Mon Sep 17 00:00:00 2001 From: Skud Date: Tue, 30 Jul 2013 16:11:31 +1000 Subject: [PATCH] Added a popover for planting images too. --- app/views/crops/_image_with_popover.html.haml | 2 +- app/views/crops/_popover.html.haml | 12 +++++------- app/views/home/_crops.html.haml | 2 +- app/views/plantings/_image_with_popover.html.haml | 11 +++++++++++ app/views/plantings/_popover.html.haml | 7 +++++++ 5 files changed, 25 insertions(+), 9 deletions(-) create mode 100644 app/views/plantings/_image_with_popover.html.haml create mode 100644 app/views/plantings/_popover.html.haml diff --git a/app/views/crops/_image_with_popover.html.haml b/app/views/crops/_image_with_popover.html.haml index c8c3de8b4..2937ef22a 100644 --- a/app/views/crops/_image_with_popover.html.haml +++ b/app/views/crops/_image_with_popover.html.haml @@ -3,7 +3,7 @@ crop.default_photo ? crop.default_photo.thumbnail_url : 'placeholder_150.png', | :alt => crop.system_name | ), | - '#', | + crop, | :rel => "popover", | 'data-trigger' => 'hover', | 'data-title' => crop.system_name, | diff --git a/app/views/crops/_popover.html.haml b/app/views/crops/_popover.html.haml index f51adef17..c692f3d51 100644 --- a/app/views/crops/_popover.html.haml +++ b/app/views/crops/_popover.html.haml @@ -1,10 +1,8 @@ %p - - if crop.scientific_names.count > 0 - %i - %small + %small + - if crop.scientific_names.count > 0 + %i = crop.scientific_names.first.scientific_name %br/ - %small - Planted - = pluralize(crop.plantings_count, "time") -= link_to "More detail", crop + Planted + = pluralize(crop.plantings_count, "time") diff --git a/app/views/home/_crops.html.haml b/app/views/home/_crops.html.haml index 78fda3977..bd3690469 100644 --- a/app/views/home/_crops.html.haml +++ b/app/views/home/_crops.html.haml @@ -17,7 +17,7 @@ - count += 1 .row .span2{:style => 'padding-bottom: 6px'} - =link_to image_tag(p.photos.first.thumbnail_url, :alt => p.to_s), p + = render :partial => 'plantings/image_with_popover.html.haml', :locals => { :planting => p } .span10 = link_to p.crop, p.crop in diff --git a/app/views/plantings/_image_with_popover.html.haml b/app/views/plantings/_image_with_popover.html.haml new file mode 100644 index 000000000..8c36d26c9 --- /dev/null +++ b/app/views/plantings/_image_with_popover.html.haml @@ -0,0 +1,11 @@ += link_to | + image_tag( | + planting.photos.present? ? planting.photos.first.thumbnail_url : 'placeholder_150.png', | + :alt => planting.to_s | + ), | + planting, | + :rel => "popover", | + 'data-trigger' => 'hover', | + 'data-title' => planting.to_s, | + 'data-content' => "#{ render :partial => 'plantings/popover', :locals => { :planting => planting } }", | + 'data-html' => true diff --git a/app/views/plantings/_popover.html.haml b/app/views/plantings/_popover.html.haml new file mode 100644 index 000000000..d7a83f616 --- /dev/null +++ b/app/views/plantings/_popover.html.haml @@ -0,0 +1,7 @@ +%p + %small + Quantity: + = planting.quantity ? planting.quantity : 'unknown' + %br/ + Planted on: + = planting.planted_at.to_s