From 0823e971ed85a4123f62d0bbbef8ec473b6435ce Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 18 Nov 2019 10:23:07 +1300 Subject: [PATCH] Tidy up indexes and add links to data/api --- app/helpers/application_helper.rb | 4 +- app/views/harvests/index.html.haml | 59 +++++++++++++---------------- app/views/layouts/_footer.html.haml | 1 + app/views/layouts/_nav.haml | 19 +++++----- app/views/plantings/index.html.haml | 57 ++++++++++++++-------------- app/views/seeds/index.html.haml | 55 ++++++++++++++------------- 6 files changed, 98 insertions(+), 97 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 63a4b45c5..af0d1505b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -64,11 +64,13 @@ module ApplicationHelper pluralize(collection.size, model.model_name.to_s.downcase) end - def show_inactive_tickbox_path(type, owner: nil, show_all: false) + def show_inactive_tickbox_path(type, owner: nil, crop: nil, show_all: false) all = show_all ? '' : 1 path = if owner.present? public_send("member_#{type}_path", owner, all: all) + elsif crop.present? + public_send("crop_#{type}_path", crop, all: all) else public_send("#{type}_path", all: all) end diff --git a/app/views/harvests/index.html.haml b/app/views/harvests/index.html.haml index dd0ccfc29..0e430615c 100644 --- a/app/views/harvests/index.html.haml +++ b/app/views/harvests/index.html.haml @@ -1,19 +1,5 @@ - content_for(:title) do = title('harvests', @owner, @crop, @planting) - -%h1 - = harvest_icon - = title('harvests', @owner, @crop, @planting) - -- if @owner - = link_to "View #{@owner}'s profile >>", member_path(@owner) - -%p - #{ENV['GROWSTUFF_SITE_NAME']} helps you track what you're - harvesting from your home garden and see how productive it is. - -= render 'layouts/nav', model: Harvest - - content_for :breadcrumbs do - if @owner %li.breadcrumb-item= link_to 'Harvests', harvests_path @@ -21,21 +7,30 @@ - else %li.breadcrumb-item.active= link_to "Harvests", harvests_path -.pagination - = page_entries_info @harvests - = will_paginate @harvests - -- unless @harvests.empty? - .index-cards=render @harvests, full: true - -.pagination - = will_paginate @harvests - -%section.open-data - %h5= t('label.data') - %ul.nav#open-data - - ['csv', 'json', 'rss'].each do |format| - %li.list-group-item - = link_to (@owner ? member_harvests_path(@owner, format: format) : harvests_path(format: format)) do - = icon 'fas', format.to_s - = format.upcase \ No newline at end of file +%h1.display-2.text-center + = harvest_icon + = title('harvests', @owner, @crop, @planting) +%p.text-center + #{ENV['GROWSTUFF_SITE_NAME']} helps you track what you're + harvesting from your home garden and see how productive it is. +.row + .col-2 + = render 'layouts/nav', model: Harvest + - if @owner + = render @owner + %section.open-data + %h2 Open Data + %p= t('label.data') + - ['csv', 'json', 'rss'].each do |format| + .badge.badge-info + = link_to (@owner ? member_harvests_path(@owner, format: format) : harvests_path(format: format)) do + = icon 'fas', format.to_s + = format.upcase + .badge.badge-success= link_to 'API Methods', '/api-docs' + .col-10 + %section + %h2 + = page_entries_info @harvests + = will_paginate @harvests + .index-cards=render @harvests, full: true + = will_paginate @harvests diff --git a/app/views/layouts/_footer.html.haml b/app/views/layouts/_footer.html.haml index be60c79fa..aac6212d6 100644 --- a/app/views/layouts/_footer.html.haml +++ b/app/views/layouts/_footer.html.haml @@ -5,6 +5,7 @@ .col-md-4#footer2 != cms_snippet_content(:footer2) .col-md-4#footer3 + .badge.badge-success= link_to 'API', '/api-docs' != cms_snippet_content(:footer3) %div{ style: "float: right;" } = link_to "https://opendefinition.org/ossd/" do diff --git a/app/views/layouts/_nav.haml b/app/views/layouts/_nav.haml index 7122a0e20..4b835a626 100644 --- a/app/views/layouts/_nav.haml +++ b/app/views/layouts/_nav.haml @@ -1,15 +1,14 @@ - if current_member.present? - %ul.nav.crop-actions - %li.nav-item.dropdown.btn.btn-sm - = link_to url_for([current_member, model]), class: 'nav-link' do - My #{model.model_name.human.pluralize} - %li.nav-item.dropdown.btn.btn-sm - = link_to model, class: 'nav-link' do - Everyone's #{model.model_name.human.pluralize} + .card + .card-header + %h2.card-title #{model} links + = link_to url_for([current_member, model]), class: 'btn' do + My #{model.model_name.human.pluralize} + = link_to model, class: 'btn' do + Everyone's #{model.model_name.human.pluralize} - if can?(:create, model) - %li.nav-item.dropdown.btn.btn-sm - = link_to url_for([model, action: :new]), class: 'nav-link' do - Add a #{model.model_name.human} + = link_to url_for([model, action: :new]), class: 'btn' do + Add a #{model.model_name.human} - else = render 'shared/signin_signup', to: "record your #{model.to_s.pluralize.downcase}" diff --git a/app/views/plantings/index.html.haml b/app/views/plantings/index.html.haml index 639840fb3..e6354dae3 100644 --- a/app/views/plantings/index.html.haml +++ b/app/views/plantings/index.html.haml @@ -7,39 +7,40 @@ - else %li.breadcrumb-item.active= link_to 'Plantings', plantings_path -%h1 +%h1.display-2.text-center = planting_icon = title('plantings', @owner, @crop, @planting) .row - .col-md-6 - %ul.nav - %li.list-group-item - = link_to show_inactive_tickbox_path('plantings', owner: @owner, show_all: @show_all) do - = check_box_tag 'active', 'all', @show_all - include finished - - if @owner - %li.list-group-item.btn - = link_to t('.view_owners_profile', owner: @owner), member_path(@owner) - .col-md-6= render 'layouts/nav', model: Planting + .col-2 + = render 'layouts/nav', model: Planting + %hr/ + = link_to show_inactive_tickbox_path('plantings', owner: @owner, crop: @crop, show_all: @show_all) do + = check_box_tag 'active', 'all', @show_all + include finished plantings + %hr + - if @owner.present? + = render @owner + - if @crop.present? + = render @crop -.row - .col-12= page_entries_info @plantings - .col-12= will_paginate @plantings + %section.open-data + %h2 Open Data + %p= t('label.data') + - ['csv', 'json', 'rss'].each do |format| + .badge.badge-info + = link_to (@owner ? member_plantings_path(@owner, format: format) : plantings_path(format: format)) do + = icon 'fas', format.to_s + = format.upcase + .badge.badge-success= link_to 'API Methods', '/api-docs' -.index-cards - - @plantings.each do |planting| - = render planting, full: true + .col-10 -= will_paginate @plantings + %section + %h2= page_entries_info @plantings + = will_paginate @plantings + .index-cards + - @plantings.each do |planting| + = render planting, full: true -%hr/ - -%section.open-data - %h3= t('label.data') - %ul.nav#open-data - - ['csv', 'json', 'rss'].each do |format| - %li.list-group-item - = link_to (@owner ? member_plantings_path(@owner, format: format) : plantings_path(format: format)) do - = icon 'fas', format.to_s - = format.upcase + = will_paginate @plantings diff --git a/app/views/seeds/index.html.haml b/app/views/seeds/index.html.haml index 6c74b13d3..446e12edc 100644 --- a/app/views/seeds/index.html.haml +++ b/app/views/seeds/index.html.haml @@ -6,38 +6,41 @@ %li.breadcrumb-item.active= link_to 'Seeds', seeds_path - content_for :title, title('seeds', @owner, @crop, @planting) -%h1 +%h1.display-2.text-center = seed_icon = title('seeds', @owner, @crop, @planting) .row - .col - %ul.nav - %li.list-group-item - = link_to show_inactive_tickbox_path('seeds', owner: @owner, show_all: @show_all) do - = check_box_tag 'active', 'all', @show_all - include finished - - if @owner - %li.list-group-item.btn - = link_to t('.view_owners_profile', owner: @owner), member_path(@owner) - .col= render 'layouts/nav', model: Seed + .col-2 + = render 'layouts/nav', model: Seed + %hr/ + = link_to show_inactive_tickbox_path('seeds', owner: @owner, crop: @crop, show_all: @show_all) do + = check_box_tag 'active', 'all', @show_all + include finished + %hr/ + - if @owner + = render @owner + - if @crop + = render @crop -- unless @seeds.empty? - = page_entries_info @seeds - = will_paginate @seeds + %section.open-data + %h2 Open Data + %p= t('label.data') + - ['csv', 'json', 'rss'].each do |format| + .badge.badge-info + = link_to (@owner ? member_seeds_path(@owner, format: format) : seeds_path(format: format)) do + = icon 'fas', format.to_s + = format.upcase + .badge.badge-success= link_to 'API Methods', '/api-docs' + .col-10 + %section + %h2= page_entries_info @seeds + = will_paginate @seeds - .index-cards - - @seeds.each do |seed| - = render 'seeds/card', seed: seed + .index-cards + - @seeds.each do |seed| + = render 'seeds/card', seed: seed - = will_paginate @seeds + = will_paginate @seeds -%section.open-data - %h5= t('label.data') - %ul.nav#open-data - - ['csv', 'json', 'rss'].each do |format| - %li.list-group-item - = link_to (@owner ? member_seeds_path(@owner, format: format) : seeds_path(format: format)) do - = icon 'fas', format.to_s - = format.upcase