From 6bdfe5a669c50c7255cdc601ed0a580c1e52ed40 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 14 Jan 2017 16:28:28 +1300 Subject: [PATCH] Moved plantings nav bar to own file and simplified --- app/controllers/plantings_controller.rb | 4 ++-- app/views/plantings/index.html.haml | 21 +++------------------ 2 files changed, 5 insertions(+), 20 deletions(-) diff --git a/app/controllers/plantings_controller.rb b/app/controllers/plantings_controller.rb index f8d6f4c1f..cc7bdf0b4 100644 --- a/app/controllers/plantings_controller.rb +++ b/app/controllers/plantings_controller.rb @@ -14,8 +14,8 @@ class PlantingsController < ApplicationController else Planting end - - @plantings = @plantings.current unless params[:all] + @show_all = params[:all] == '1' + @plantings = @plantings.current unless @show_all @plantings = @plantings.includes(:owner, :crop, :garden).order(:created_at).paginate(page: params[:page]) respond_to do |format| diff --git a/app/views/plantings/index.html.haml b/app/views/plantings/index.html.haml index 1131e3b56..1311d4451 100644 --- a/app/views/plantings/index.html.haml +++ b/app/views/plantings/index.html.haml @@ -1,25 +1,10 @@ - content_for :title, @owner ? t('.title.owner_plantings', owner: @owner) : @crop ? t('.title.crop_plantings', crop: @crop.name) : t('.title.default') + += render 'nav', owner: @owner, show_all: @show_all + - if @owner = link_to "View #{@owner}'s profile >>", member_path(@owner) -%p - - if can? :create, Planting - - if @owner - %p - - if @owner == current_member - = link_to 'Plant something', new_planting_path, :class => 'btn btn-primary' - - content_for :buttonbar do - = link_to 'My Active Plantings', plantings_by_owner_path(:owner=>current_member.slug), :class => 'btn btn-default' - = link_to 'All My Plantings', plantings_by_owner_path(:all=>1, :owner=>current_member.slug), :class => 'btn btn-default' - = link_to "Everyone's plantings", plantings_path, :class => 'btn btn-default' - - else # everyone's plantings - = link_to 'Plant something', new_planting_path, :class => 'btn btn-primary' - - if current_member - = link_to 'View your plantings', plantings_by_owner_path(:owner => current_member.slug), :class => 'btn btn-default' - = link_to 'Show all (including inactive)', plantings_path(:all=>1) - - else - = render :partial => 'shared/signin_signup', :locals => { :to => "track what you've planted" } - %div.pagination = page_entries_info @plantings = will_paginate @plantings