mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-19 06:15:44 -04:00
Tidy up sidebar on crop detail page
This commit is contained in:
16
app/views/crops/_alternate_names.html.haml
Normal file
16
app/views/crops/_alternate_names.html.haml
Normal file
@@ -0,0 +1,16 @@
|
||||
.alternate_names
|
||||
%h4 Alternate names
|
||||
- if crop.alternate_names.empty?
|
||||
%p None known.
|
||||
- else
|
||||
%ul
|
||||
- crop.alternate_names.each do |an|
|
||||
%li
|
||||
= an.name
|
||||
- if can? :edit, an
|
||||
= link_to 'Edit', edit_alternate_name_path(an), { :class => 'btn btn-default btn-xs' }
|
||||
- if can? :destroy, an
|
||||
= link_to 'Delete', an, method: :delete, data: { confirm: 'Are you sure?' }, :class => 'btn btn-default btn-xs'
|
||||
%p
|
||||
- if can? :edit, crop
|
||||
= link_to 'Add', new_alternate_name_path( :crop_id => crop.id ), { :class => 'btn btn-default btn-xs' }
|
||||
@@ -1,5 +1,7 @@
|
||||
- if ! crop.harvests.empty?
|
||||
%p
|
||||
%strong Grown for:
|
||||
%p
|
||||
%strong Grown for:
|
||||
- if crop.harvests.empty?
|
||||
not known.
|
||||
- else
|
||||
- popular_plant_parts = crop.popular_plant_parts.sort_by {|s, freq| freq }.reverse
|
||||
!= popular_plant_parts.map {|p, freq| link_to(p, p) + " (#{freq})" }.join(", ")
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
- if crop.planted_from.length > 0
|
||||
%p
|
||||
%strong Plant from:
|
||||
%p
|
||||
%strong Plant from:
|
||||
- if crop.planted_from.empty?
|
||||
not known.
|
||||
- else
|
||||
- planted_from = crop.planted_from.sort_by {|s, freq| freq }.reverse
|
||||
= planted_from.map {|s, freq| "#{s} (#{freq})" }.join(", ")
|
||||
- if crop.sunniness.length > 0
|
||||
%p
|
||||
%strong Plant in:
|
||||
|
||||
%p
|
||||
%strong Plant in:
|
||||
- if crop.sunniness.empty?
|
||||
not known.
|
||||
- else
|
||||
- sunniness = crop.sunniness.sort_by {|s, freq| freq }.reverse
|
||||
= sunniness.map {|s, freq| "#{s} (#{freq})" }.join(", ")
|
||||
|
||||
16
app/views/crops/_scientific_names.html.haml
Normal file
16
app/views/crops/_scientific_names.html.haml
Normal file
@@ -0,0 +1,16 @@
|
||||
.scientific_names
|
||||
%h4 Scientific names
|
||||
- if crop.scientific_names.empty?
|
||||
%p None known.
|
||||
- else
|
||||
%ul
|
||||
- crop.scientific_names.each do |sn|
|
||||
%li
|
||||
= sn.scientific_name
|
||||
- if can? :edit, sn
|
||||
= link_to 'Edit', edit_scientific_name_path(sn), { :class => 'btn btn-default btn-xs' }
|
||||
- if can? :destroy, sn
|
||||
= link_to 'Delete', sn, method: :delete, data: { confirm: 'Are you sure?' }, :class => 'btn btn-default btn-xs'
|
||||
%p
|
||||
- if can? :edit, crop
|
||||
= link_to 'Add', new_scientific_name_path( :crop_id => crop.id ), { :class => 'btn btn-default btn-xs' }
|
||||
@@ -4,7 +4,12 @@
|
||||
is a variety of
|
||||
= succeed "." do
|
||||
= link_to crop.parent, crop.parent
|
||||
- if crop.varieties.count > 0
|
||||
%h3
|
||||
Varieties:
|
||||
|
||||
- unless crop.varieties.empty?
|
||||
%p
|
||||
Varieties of #{crop.name}:
|
||||
|
||||
= render :partial => 'hierarchy', :locals => { :display_crops => [ crop ] }
|
||||
|
||||
- if ! crop.parent and crop.varieties.empty?
|
||||
%p None known.
|
||||
|
||||
11
app/views/crops/_wrangle.html.haml
Normal file
11
app/views/crops/_wrangle.html.haml
Normal file
@@ -0,0 +1,11 @@
|
||||
- if can? :edit, crop or can? :destroy, crop
|
||||
%h4 Crop wrangling
|
||||
%p
|
||||
You are a
|
||||
= succeed "." do
|
||||
%strong CROP WRANGLER
|
||||
%p
|
||||
- if can? :edit, crop
|
||||
= link_to 'Edit crop', edit_crop_path(crop), { :class => 'btn btn-default btn-xs' }
|
||||
- if can? :destroy, crop
|
||||
= link_to 'Delete crop', crop, method: :delete, data: { confirm: 'Are you sure?' }, :class => 'btn btn-default btn-xs'
|
||||
@@ -47,52 +47,20 @@
|
||||
= will_paginate @posts, :params => {:anchor => "posts"}
|
||||
|
||||
.col-md-3
|
||||
- if can? :edit, @crop or can? :destroy, @crop
|
||||
%h4 Crop wrangling
|
||||
%p
|
||||
You are a
|
||||
= succeed "." do
|
||||
%strong CROP WRANGLER
|
||||
%p
|
||||
- if can? :edit, @crop
|
||||
= link_to 'Edit crop', edit_crop_path(@crop), { :class => 'btn btn-default btn-xs' }
|
||||
- if can? :destroy, @crop
|
||||
= link_to 'Delete crop', @crop, method: :delete, data: { confirm: 'Are you sure?' }, :class => 'btn btn-default btn-xs'
|
||||
|
||||
.scientific_names
|
||||
%h4 Scientific names
|
||||
%ul
|
||||
- @crop.scientific_names.each do |sn|
|
||||
%li
|
||||
= sn.scientific_name
|
||||
- if can? :edit, sn
|
||||
= link_to 'Edit', edit_scientific_name_path(sn), { :class => 'btn btn-default btn-xs' }
|
||||
- if can? :destroy, sn
|
||||
= link_to 'Delete', sn, method: :delete, data: { confirm: 'Are you sure?' }, :class => 'btn btn-default btn-xs'
|
||||
%p
|
||||
- if can? :edit, @crop
|
||||
= link_to 'Add', new_scientific_name_path( :crop_id => @crop.id ), { :class => 'btn btn-default btn-xs' }
|
||||
= render :partial => 'wrangle', :locals => { :crop => @crop }
|
||||
= render :partial => 'scientific_names', :locals => { :crop => @crop }
|
||||
= render :partial => 'alternate_names', :locals => { :crop => @crop }
|
||||
|
||||
.alternate_names
|
||||
%h4 Alternate names
|
||||
%ul
|
||||
- @crop.alternate_names.each do |an|
|
||||
%li
|
||||
= an.name
|
||||
- if can? :edit, an
|
||||
= link_to 'Edit', edit_alternate_name_path(an), { :class => 'btn btn-default btn-xs' }
|
||||
- if can? :destroy, an
|
||||
= link_to 'Delete', an, method: :delete, data: { confirm: 'Are you sure?' }, :class => 'btn btn-default btn-xs'
|
||||
%p
|
||||
- if can? :edit, @crop
|
||||
= link_to 'Add', new_alternate_name_path( :crop_id => @crop.id ), { :class => 'btn btn-default btn-xs' }
|
||||
|
||||
= render :partial => 'varieties', :locals => { :crop => @crop }
|
||||
%h4 Planting advice
|
||||
|
||||
= render :partial => 'grown_for', :locals => { :crop => @crop }
|
||||
|
||||
= render :partial => 'planting_advice', :locals => { :crop => @crop }
|
||||
|
||||
%h4 Varieties
|
||||
= render :partial => 'varieties', :locals => { :crop => @crop }
|
||||
|
||||
|
||||
%h4 More information
|
||||
%ul
|
||||
%li= link_to 'Wikipedia (English)', @crop.en_wikipedia_url
|
||||
|
||||
@@ -14,7 +14,7 @@ describe "crops/_planting_advice" do
|
||||
context "sunniness" do
|
||||
it "doesn't show sunniness if none are set" do
|
||||
render :partial => 'crops/planting_advice', :locals => { :crop => @crop }
|
||||
rendered.should_not contain "Plant in:"
|
||||
rendered.should contain "Plant in: not known."
|
||||
end
|
||||
|
||||
it "shows sunniness frequencies" do
|
||||
@@ -39,7 +39,7 @@ describe "crops/_planting_advice" do
|
||||
|
||||
it "doesn't show planted_from if none are set" do
|
||||
render :partial => 'crops/planting_advice', :locals => { :crop => @crop }
|
||||
rendered.should_not contain "Plant from:"
|
||||
rendered.should contain "Plant from: not known."
|
||||
end
|
||||
|
||||
it "shows planted_from frequencies" do
|
||||
|
||||
Reference in New Issue
Block a user