From 755a60447fb4d8b01ceeb8d98c296a4dfe164fde Mon Sep 17 00:00:00 2001 From: AELOGICA Date: Tue, 7 Jul 2015 08:19:13 +0800 Subject: [PATCH] Made the plantings/_thumbnail partial to contain only a single object. --- app/views/gardens/show.html.haml | 23 +++++-- app/views/members/_gardens.html.haml | 9 ++- app/views/plantings/_thumbnail.html.haml | 86 +++++++++++------------- app/views/plantings/index.html.haml | 8 ++- 4 files changed, 71 insertions(+), 55 deletions(-) diff --git a/app/views/gardens/show.html.haml b/app/views/gardens/show.html.haml index 85a8baae9..f6b38a7e8 100644 --- a/app/views/gardens/show.html.haml +++ b/app/views/gardens/show.html.haml @@ -43,19 +43,28 @@ %p{:style => 'text-align: center; padding-top: 50px'} = link_to "Add photo", new_photo_path(:type => "garden", :id => @garden.id), :class => 'btn btn-primary' - - %h3 - What's planted here? - + %h3 What's planted here? - if @garden.plantings.current.size > 0 - = render :partial => "plantings/thumbnail", :locals => { :plantings => @garden.plantings.current} + %table.table.table-striped + %tr + %th # + %th Photo + %th{:colspan => "3"} Planting details + - @garden.plantings.current.each.with_index do |planting_current, index_current| + = render partial: "plantings/thumbnail", locals: {:planting => planting_current, :index => index_current} - else %p Nothing is currently planted here. + %h3 Previously planted in this garden - if @garden.plantings.finished.size > 0 - %h3 Previously planted in this garden - = render :partial => "plantings/thumbnail", :locals => { :plantings => @garden.plantings.finished} + %table.table.table-striped + %tr + %th # + %th Photo + %th{:colspan => "3"} Planting details + - @garden.plantings.finished.each.with_index do |planting_finished, index_finished| + = render partial: "plantings/thumbnail", locals: {:planting => planting_finished, :index => index_finished} .col-md-3 %h4 About this garden diff --git a/app/views/members/_gardens.html.haml b/app/views/members/_gardens.html.haml index 4147fa74f..8c3f572b0 100644 --- a/app/views/members/_gardens.html.haml +++ b/app/views/members/_gardens.html.haml @@ -34,7 +34,14 @@ = link_to "Add photo", new_photo_path(:type => "garden", :id => g.id), :class => 'btn btn-primary' %h3 What's planted here? - = render :partial => "plantings/thumbnail", :locals => { :plantings => g.featured_plantings} + - if g.featured_plantings.size > 0 + %table.table.table-striped + %tr + %th # + %th Photo + %th{:colspan => "3"} Planting details + - g.featured_plantings.each.with_index do |planting, index| + = render partial: "plantings/thumbnail", locals: {:planting => planting, :index => index} %p = link_to "More about this garden...", url_for(g) diff --git a/app/views/plantings/_thumbnail.html.haml b/app/views/plantings/_thumbnail.html.haml index a7f53e4f7..a3615c6ec 100644 --- a/app/views/plantings/_thumbnail.html.haml +++ b/app/views/plantings/_thumbnail.html.haml @@ -1,48 +1,42 @@ -%table.table.table-striped - %tr - %th # - %th Photo - %th{:colspan => "3"} Planting details - - plantings.each.with_index do |planting, index| +%tr + %td= "##{index+1}" + %td= link_to image_tag((planting.default_photo ? planting.default_photo.thumbnail_url : 'placeholder_150.png'), :alt => planting.crop_id, :class => 'img'), planting + %td + %ul{:style => "list-style-type:none"} + %li Owner: + %li Garden: + %li Planted on: + %li Quantity: + %li Finished on: + %li Sun/shade?: + %li Planted from: + %td + %ul{:style => "list-style-type:none"} + %li= link_to planting.owner.login_name, planting.owner + %li= link_to planting.garden.name, planting.garden + %li= planting.planted_at + %li= "#{display_planting_quantity(planting)}" + %li= "#{display_finished(planting)}" + %li= "#{display_sunniness(planting)}" + %li= "#{display_planted_from(planting)}" + %td + %ul{:style => "list-style-type:none"} + %li= link_to 'Details', planting, :class => 'btn btn-default btn-xs' + - if can? :edit, planting + %li= link_to 'Edit', edit_planting_path(planting), :class => 'btn btn-default btn-xs' + - if ! planting.finished + %li= link_to "Mark as finished", planting_path(planting, :planting => {:finished => 1}), :method => :put, :class => 'btn btn-default btn-xs append-date' + - if can? :destroy, planting + %li= link_to 'Delete', planting, method: :delete, data: { confirm: 'Are you sure?' }, :class => 'btn btn-default btn-xs' %tr - %td= "##{index+1}" - %td= link_to image_tag((planting.default_photo ? planting.default_photo.thumbnail_url : 'placeholder_150.png'), :alt => planting.crop_id, :class => 'img'), planting - %td - %ul{:style => "list-style-type:none"} - %li Owner: - %li Garden: - %li Planted on: - %li Quantity: - %li Finished on: - %li Sun/shade?: - %li Planted from: - %td - %ul{:style => "list-style-type:none"} - %li= link_to planting.owner.login_name, planting.owner - %li= link_to planting.garden.name, planting.garden - %li= planting.planted_at - %li= "#{display_planting_quantity(planting)}" - %li= "#{display_finished(planting)}" - %li= "#{display_sunniness(planting)}" - %li= "#{display_planted_from(planting)}" - %td - %ul{:style => "list-style-type:none"} - %li= link_to 'Details', planting, :class => 'btn btn-default btn-xs' - - if can? :edit, planting - %li= link_to 'Edit', edit_planting_path(planting), :class => 'btn btn-default btn-xs' - - if ! planting.finished - %li= link_to "Mark as finished", planting_path(planting, :planting => {:finished => 1}), :method => :put, :class => 'btn btn-default btn-xs append-date' - - if can? :destroy, planting - %li= link_to 'Delete', planting, method: :delete, data: { confirm: 'Are you sure?' }, :class => 'btn btn-default btn-xs' - %tr - %td - %td - %ul{:style => "list-style-type:none"} - %li - Crop name: - =link_to planting.crop.name, planting.crop - %li= "Days until maturity: #{display_days_before_maturity(planting)}" + %td + %td + %ul{:style => "list-style-type:none"} + %li + Crop name: + =link_to planting.crop.name, planting.crop + %li= "Days until maturity: #{display_days_before_maturity(planting)}" - %td{:colspan => "3"} - %ul{:style => "list-style-type:none"} - %li= render partial: 'plantings/planting_progress', locals: {:planting => planting} \ No newline at end of file + %td{:colspan => "3"} + %ul{:style => "list-style-type:none"} + %li= render partial: 'plantings/planting_progress', locals: {:planting => planting} \ No newline at end of file diff --git a/app/views/plantings/index.html.haml b/app/views/plantings/index.html.haml index ca0db97f5..461ebf43b 100644 --- a/app/views/plantings/index.html.haml +++ b/app/views/plantings/index.html.haml @@ -19,7 +19,13 @@ = will_paginate @plantings - if @plantings.size > 0 - = render partial: "plantings/thumbnail", locals: {:plantings => @plantings} + %table.table.table-striped + %tr + %th # + %th Photo + %th{:colspan => "3"} Planting details + - @plantings.each.with_index do |planting, index| + = render partial: "plantings/thumbnail", locals: {:planting => planting, :index => index} %div.pagination = page_entries_info @plantings, :model => "plantings"