Tidy up indexes and add links to data/api

This commit is contained in:
Brenda Wallace
2019-11-18 10:23:07 +13:00
parent 4f8830676e
commit 0823e971ed
6 changed files with 98 additions and 97 deletions

View File

@@ -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

View File

@@ -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
%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

View File

@@ -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

View File

@@ -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}"

View File

@@ -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

View File

@@ -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