From dccbf440cb3763cc155eac357822a879e4697ffc Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 18 May 2019 23:18:27 +1200 Subject: [PATCH] Breadcrumbs --- app/views/admin/index.html.haml | 7 +++++ app/views/crops/index.html.haml | 35 ++++++++++++---------- app/views/crops/search.html.haml | 12 +++++--- app/views/crops/show.html.haml | 8 +++++ app/views/layouts/application.html.haml | 11 +++++-- app/views/posts/index.html.haml | 8 +++++ app/views/posts/show.html.haml | 39 +++++++++++++++++-------- 7 files changed, 85 insertions(+), 35 deletions(-) diff --git a/app/views/admin/index.html.haml b/app/views/admin/index.html.haml index ba67f1ec2..f21c5f93a 100644 --- a/app/views/admin/index.html.haml +++ b/app/views/admin/index.html.haml @@ -1,5 +1,12 @@ - content_for :title, 'Admin' +- content_for :breadcrumbs do + %nav{"aria-label" => "breadcrumb"} + %ol.breadcrumb + %li.breadcrumb-item + = link_to 'Home', root_path + %li.breadcrumb-item.active= link_to 'Admin', admin_path + %h2 Manage .row diff --git a/app/views/crops/index.html.haml b/app/views/crops/index.html.haml index ac2dba563..19bb52b41 100644 --- a/app/views/crops/index.html.haml +++ b/app/views/crops/index.html.haml @@ -1,5 +1,4 @@ - content_for :title, t('.title') -- content_for :subtitle, t('.subtitle', crops_size: @crops.size) - content_for :buttonbar do - if can? :wrangle, Crop @@ -7,24 +6,30 @@ - if can? :create, Crop = link_to 'Add new Crop', new_crop_path, class: 'btn btn-primary' +- content_for :breadcrumbs do + %nav{"aria-label" => "breadcrumb"} + %ol.breadcrumb + %li.breadcrumb-item + = link_to 'Home', root_path + %li.breadcrumb-item.active= link_to 'Crops', crops_path -- if @num_requested_crops && @num_requested_crops.positive? - = link_to(I18n.t('crops.requested.link', number_crops: @num_requested_crops), requested_crops_path) - +%h1=t('.title') %p #{ENV['GROWSTUFF_SITE_NAME']} tracks who's growing what, where. View any crop page to see which of our members have planted it and find information on how to grow it yourself. -= form_tag(crops_path, method: :get, class: 'form-inline', role: 'form') do - .form-group - = label_tag :sort, "Sort by:", class: 'sr-only' - = select_tag "sort", - options_for_select({ "Sort by popularity": 'popular', - "Sort alphabetically": 'alpha' }, - @sort || 'popular'), - class: 'form-control' - = submit_tag "Show", class: 'btn btn-primary' + +.well + = form_tag(crops_path, method: :get, class: 'form-inline', role: 'form') do + .form-group + = label_tag :sort, "Sort by:", class: 'sr-only' + = select_tag "sort", + options_for_select({ "Sort by popularity": 'popular', + "Sort alphabetically": 'alpha' }, + @sort || 'popular'), + class: 'form-control' + = submit_tag "Show", class: 'btn btn-success' .pagination= render 'layouts/pagination', collection: @crops @@ -32,9 +37,7 @@ - @crops.each do |crop| .col-md-2= render 'crops/thumbnail', crop: crop -.pagination - = will_paginate @crops - +.pagination= render 'layouts/pagination', collection: @crops %ul.list-inline %li The data on this page is available in the following formats: diff --git a/app/views/crops/search.html.haml b/app/views/crops/search.html.haml index b20273807..4dee37fa5 100644 --- a/app/views/crops/search.html.haml +++ b/app/views/crops/search.html.haml @@ -5,6 +5,14 @@ - else - content_for :title, "Crop search" +- content_for :breadcrumbs do + %nav{"aria-label" => "breadcrumb"} + %ol.breadcrumb + %li.breadcrumb-item + = link_to 'Home', root_path + %li.breadcrumb-item= link_to 'Crops', crops_path + %li.breadcrumb-item.active= link_to 'Search', search_crops_path(term: @term) + %div = form_tag search_crops_path, method: :get, id: 'crop-search', class: 'form-inline' do .form-group @@ -25,10 +33,6 @@ instead. - else - = will_paginate @crops - .row - @crops.each do |crop| .col-md-2= render 'crops/thumbnail', crop: crop - - = will_paginate @crops diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index e99100022..dea9795b2 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -10,6 +10,14 @@ - content_for :scripts do = javascript_include_tag "charts" +- content_for :breadcrumbs do + %nav{"aria-label" => "breadcrumb"} + %ol.breadcrumb + %li.breadcrumb-item + = link_to 'Home', root_path + %li.breadcrumb-item= link_to 'Crops', crops_path + %li.breadcrumb-item.active= link_to @crop, @crop + %h1 = @crop.name %small= @crop.default_scientific_name diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 0362fca92..5dd7ccd33 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -8,9 +8,14 @@ -# anchor tag for accessibility link to skip the navigation menu %a{ name: 'skipnav' } #maincontainer.container - .pull-right= render 'shared/global_actions' - - if content_for?(:buttonbar) - = yield(:buttonbar) + .row + .col-md-12 + - if content_for?(:breadcrumbs) + .float-left= yield(:breadcrumbs) + .float-right + = render 'shared/global_actions' + - if content_for?(:buttonbar) + = yield(:buttonbar) - if content_for?(:subtitle) %small= yield(:subtitle) diff --git a/app/views/posts/index.html.haml b/app/views/posts/index.html.haml index 9c1f6e10d..b4d76e541 100644 --- a/app/views/posts/index.html.haml +++ b/app/views/posts/index.html.haml @@ -1,5 +1,13 @@ - content_for :title, @author ? t('.title.author_posts', author: @author) : t('.title.default') +- content_for :breadcrumbs do + %nav{"aria-label" => "breadcrumb"} + %ol.breadcrumb + %li.breadcrumb-item + = link_to 'Home', root_path + - if @author.present? + %li.breadcrumb-item= link_to @author, @author + %li.breadcrumb-item.active= link_to 'posts', posts_path(author: @author.slug) %h1= @author ? t('.title.author_posts', author: @author) : t('.title.default') .pagination= render 'layouts/pagination', collection: @posts diff --git a/app/views/posts/show.html.haml b/app/views/posts/show.html.haml index 01438393c..1456beada 100644 --- a/app/views/posts/show.html.haml +++ b/app/views/posts/show.html.haml @@ -21,6 +21,33 @@ = render "shared/signin_signup", to: "or to start using #{ENV['GROWSTUFF_SITE_NAME']} to track what you're planting and harvesting" +- content_for :buttonbar do + - if can?(:edit, @post) || can?(:destroy, @post) + - if can? :edit, @post + = link_to edit_post_path(@post), class: 'btn' do + = edit_icon + edit + + - if can? :destroy, @post + = link_to @post, method: :delete, + data: { confirm: 'Are you sure?' }, + class: 'btn btn-danger' do + = delete_icon + delete + + - if @post.comments.count > 10 && can?(:create, Comment) + = link_to 'Comment', new_comment_path(post_id: @post.id), class: 'btn' + + +- content_for :breadcrumbs do + %nav{"aria-label" => "breadcrumb"} + %ol.breadcrumb + %li.breadcrumb-item + = link_to 'Home', root_path + %li.breadcrumb-item= link_to @post.author, @post.author + %li.breadcrumb-item= link_to 'posts', posts_path(author: @post.author.slug) + %li.breadcrumb-item.active{"aria-current" => "page"}= @post.subject + .row .col-8.col-xs-12 @@ -53,18 +80,6 @@ = icon 'fas', 'comment' Comment - - if can?(:edit, @post) || can?(:destroy, @post) - - if can? :edit, @post - = link_to 'Edit Post', edit_post_path(@post), class: 'btn' - - - if can? :destroy, @post - = link_to 'Delete Post', @post, method: :delete, - data: { confirm: 'Are you sure?' }, - class: 'btn' - - - if @post.comments.count > 10 && can?(:create, Comment) - = link_to 'Comment', new_comment_path(post_id: @post.id), class: 'btn' - .col-4.col-xs-12 = render @post.author