From 58f8a882420ada6ed09573e1ba7707ab04eca074 Mon Sep 17 00:00:00 2001 From: apdarr Date: Thu, 17 Jan 2019 11:03:20 -0500 Subject: [PATCH 01/68] set newrelic to use ssl --- config/newrelic.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/newrelic.yml b/config/newrelic.yml index 63500e405..b7c9cdfdb 100644 --- a/config/newrelic.yml +++ b/config/newrelic.yml @@ -65,7 +65,7 @@ common: &default_settings # encryption involved in SSL communication, but this work is done # asynchronously to the threads that process your application code, # so it should not impact response times. - ssl: false + ssl: true # EXPERIMENTAL: enable verification of the SSL certificate sent by # the server. This setting has no effect unless SSL is enabled From 4f4421cb38ac4f211793401015cfd3190a38cb99 Mon Sep 17 00:00:00 2001 From: apdarr Date: Tue, 22 Jan 2019 16:59:38 -0500 Subject: [PATCH 02/68] enforce ssl for new relic --- CONTRIBUTORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index a9f784ac3..2dcbb1842 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -87,6 +87,7 @@ submit the change with your pull request. - Christopher Bazin / [RobotScissors](https://github.com/robotscissors) - Ahmed Shahin / [codeminator](https://www.github.com/codeminator) - Brandon Baker / [brandonbaker40](https://github.com/brandonbaker40) +- Alex Darr / [apdarr](https://github.com/apdarr) ## Bots From a3f32aba9bb9b34233b7e6699d5d6c4f486894a2 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 11:46:50 +1300 Subject: [PATCH 03/68] Call t() on button labels --- app/views/shared/buttons/_add_photo.haml | 2 +- app/views/shared/buttons/_delete.haml | 6 +++--- app/views/shared/buttons/_edit.haml | 4 ++-- app/views/shared/buttons/_finish_planting.html.haml | 4 ++-- app/views/shared/buttons/_finish_seeds.haml | 4 ++-- app/views/shared/buttons/_harvest_planting.haml | 4 ++-- app/views/shared/buttons/_save_seeds.haml | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/views/shared/buttons/_add_photo.haml b/app/views/shared/buttons/_add_photo.haml index 71e97c0e9..09199c208 100644 --- a/app/views/shared/buttons/_add_photo.haml +++ b/app/views/shared/buttons/_add_photo.haml @@ -1,4 +1,4 @@ - if can?(:create, Photo) = link_to path, class: 'btn btn-default btn-xs' do %span.glyphicon.glyphicon-camera{ title: "Add photo" } - Add photo + =t(:add_photo) diff --git a/app/views/shared/buttons/_delete.haml b/app/views/shared/buttons/_delete.haml index b7490837b..635b652c0 100644 --- a/app/views/shared/buttons/_delete.haml +++ b/app/views/shared/buttons/_delete.haml @@ -1,4 +1,4 @@ = link_to path, method: :delete, - data: { confirm: 'Are you sure?' }, class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-trash{ title: "Delete" } - Delete + data: { confirm: t(:are_you_sure?) }, class: 'btn btn-default btn-xs' do + %span.glyphicon.glyphicon-trash{ title: t(:delete) } + =t :delete diff --git a/app/views/shared/buttons/_edit.haml b/app/views/shared/buttons/_edit.haml index 87d464023..f45fc529e 100644 --- a/app/views/shared/buttons/_edit.haml +++ b/app/views/shared/buttons/_edit.haml @@ -1,3 +1,3 @@ = link_to path, class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-pencil{ title: "Edit" } - Edit + %span.glyphicon.glyphicon-pencil{ title: t(:edit) } + =t :edit diff --git a/app/views/shared/buttons/_finish_planting.html.haml b/app/views/shared/buttons/_finish_planting.html.haml index 7b1ba8319..166bb6817 100644 --- a/app/views/shared/buttons/_finish_planting.html.haml +++ b/app/views/shared/buttons/_finish_planting.html.haml @@ -1,5 +1,5 @@ - if can?(:edit, planting) && !planting.finished = link_to planting_path(planting, planting: { finished: 1 }), method: :put, class: 'btn btn-default btn-xs append-date' do - %span.glyphicon.glyphicon-ok{ title: "Finished" } - Mark as finished + %span.glyphicon.glyphicon-ok{ title: t(:finished) } + =t :mark_as_finished diff --git a/app/views/shared/buttons/_finish_seeds.haml b/app/views/shared/buttons/_finish_seeds.haml index 211e3ec8b..54a4d68b5 100644 --- a/app/views/shared/buttons/_finish_seeds.haml +++ b/app/views/shared/buttons/_finish_seeds.haml @@ -1,5 +1,5 @@ - unless seed.finished = link_to seed_path(seed, seed: { finished: 1 }), method: :put, class: 'btn btn-default btn-xs append-date' do - %span.glyphicon.glyphicon-ok{ title: "Finished" } - Mark as finished + %span.glyphicon.glyphicon-ok{ title: t(:finished) } + =t(:mark_as_finished) diff --git a/app/views/shared/buttons/_harvest_planting.haml b/app/views/shared/buttons/_harvest_planting.haml index c90e163ad..f18d948bd 100644 --- a/app/views/shared/buttons/_harvest_planting.haml +++ b/app/views/shared/buttons/_harvest_planting.haml @@ -1,4 +1,4 @@ - planting.active? && if can?(:create, Harvest) && can?(:edit, planting) = link_to new_planting_harvest_path(planting), class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-leaf{ title: "Harvest" } - Harvest + %span.glyphicon.glyphicon-leaf{ title: :harvest } + =t(:harvest) diff --git a/app/views/shared/buttons/_save_seeds.haml b/app/views/shared/buttons/_save_seeds.haml index 00d5febb0..c1664de35 100644 --- a/app/views/shared/buttons/_save_seeds.haml +++ b/app/views/shared/buttons/_save_seeds.haml @@ -1,4 +1,4 @@ - if planting.active? = link_to new_planting_seed_path(planting), class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-heart{ title: "Save seeds" } - Save seeds + %span.glyphicon.glyphicon-heart{ title: t(:save_seeds) } + =t(:save_seeds) From 7169b624b0edac057c36853e396b4d0d4f85a6cf Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 11:47:25 +1300 Subject: [PATCH 04/68] Move the action buttons to EVERY page --- app/views/home/index.html.haml | 7 ------- app/views/layouts/application.html.haml | 1 + app/views/shared/_global_actions.html.haml | 6 ++++++ 3 files changed, 7 insertions(+), 7 deletions(-) create mode 100644 app/views/shared/_global_actions.html.haml diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index d05d6a37a..0259ce590 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -4,13 +4,6 @@ %h1= t('.welcome', site_name: ENV['GROWSTUFF_SITE_NAME'], member_name: current_member) = render 'stats' - %p - .btn-group - = link_to t('.plant'), new_planting_path, class: 'btn btn-default' - = link_to t('.harvest'), new_harvest_path, class: 'btn btn-default' - = link_to t('.add_seeds'), new_seed_path, class: 'btn btn-default' - = link_to t('.post'), new_post_path, class: 'btn btn-default' - - else .hidden-xs .jumbotron diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 070ed73db..34dbbdfe5 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -8,6 +8,7 @@ #maincontainer .row .col-md-12 + = render 'shared/global_actions' - if content_for?(:title) %h1#title = yield(:title) diff --git a/app/views/shared/_global_actions.html.haml b/app/views/shared/_global_actions.html.haml new file mode 100644 index 000000000..d4b4a5e97 --- /dev/null +++ b/app/views/shared/_global_actions.html.haml @@ -0,0 +1,6 @@ +%p + .btn-group + = link_to t(:plant_something), new_planting_path, class: 'btn btn-default' + = link_to t(:harvest_something), new_harvest_path, class: 'btn btn-default' + = link_to t(:save_seeds), new_seed_path, class: 'btn btn-default' + = link_to t(:write_blog_post), new_post_path, class: 'btn btn-default' From e886929af519ff579dda13ab11e03d6cb487954c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 13:37:58 +1300 Subject: [PATCH 05/68] Put buttons translations under buttons namespace --- app/views/shared/buttons/_add_photo.haml | 2 +- app/views/shared/buttons/_delete.haml | 2 +- app/views/shared/buttons/_edit.haml | 2 +- app/views/shared/buttons/_finish_planting.html.haml | 2 +- app/views/shared/buttons/_finish_seeds.haml | 2 +- app/views/shared/buttons/_harvest_planting.haml | 2 +- app/views/shared/buttons/_save_seeds.haml | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/views/shared/buttons/_add_photo.haml b/app/views/shared/buttons/_add_photo.haml index 09199c208..c2c87f315 100644 --- a/app/views/shared/buttons/_add_photo.haml +++ b/app/views/shared/buttons/_add_photo.haml @@ -1,4 +1,4 @@ - if can?(:create, Photo) = link_to path, class: 'btn btn-default btn-xs' do %span.glyphicon.glyphicon-camera{ title: "Add photo" } - =t(:add_photo) + =t('buttons.add_photo') diff --git a/app/views/shared/buttons/_delete.haml b/app/views/shared/buttons/_delete.haml index 635b652c0..d89a51d2d 100644 --- a/app/views/shared/buttons/_delete.haml +++ b/app/views/shared/buttons/_delete.haml @@ -1,4 +1,4 @@ = link_to path, method: :delete, data: { confirm: t(:are_you_sure?) }, class: 'btn btn-default btn-xs' do %span.glyphicon.glyphicon-trash{ title: t(:delete) } - =t :delete + =t('buttons.delete') diff --git a/app/views/shared/buttons/_edit.haml b/app/views/shared/buttons/_edit.haml index f45fc529e..3e00821c5 100644 --- a/app/views/shared/buttons/_edit.haml +++ b/app/views/shared/buttons/_edit.haml @@ -1,3 +1,3 @@ = link_to path, class: 'btn btn-default btn-xs' do %span.glyphicon.glyphicon-pencil{ title: t(:edit) } - =t :edit + =t('buttons.edit') diff --git a/app/views/shared/buttons/_finish_planting.html.haml b/app/views/shared/buttons/_finish_planting.html.haml index 166bb6817..c38ba3185 100644 --- a/app/views/shared/buttons/_finish_planting.html.haml +++ b/app/views/shared/buttons/_finish_planting.html.haml @@ -2,4 +2,4 @@ = link_to planting_path(planting, planting: { finished: 1 }), method: :put, class: 'btn btn-default btn-xs append-date' do %span.glyphicon.glyphicon-ok{ title: t(:finished) } - =t :mark_as_finished + =t('buttons.mark_as_finished') diff --git a/app/views/shared/buttons/_finish_seeds.haml b/app/views/shared/buttons/_finish_seeds.haml index 54a4d68b5..49c34ac17 100644 --- a/app/views/shared/buttons/_finish_seeds.haml +++ b/app/views/shared/buttons/_finish_seeds.haml @@ -2,4 +2,4 @@ = link_to seed_path(seed, seed: { finished: 1 }), method: :put, class: 'btn btn-default btn-xs append-date' do %span.glyphicon.glyphicon-ok{ title: t(:finished) } - =t(:mark_as_finished) + =t('buttons.mark_as_finished') diff --git a/app/views/shared/buttons/_harvest_planting.haml b/app/views/shared/buttons/_harvest_planting.haml index f18d948bd..8845e4c01 100644 --- a/app/views/shared/buttons/_harvest_planting.haml +++ b/app/views/shared/buttons/_harvest_planting.haml @@ -1,4 +1,4 @@ - planting.active? && if can?(:create, Harvest) && can?(:edit, planting) = link_to new_planting_harvest_path(planting), class: 'btn btn-default btn-xs' do %span.glyphicon.glyphicon-leaf{ title: :harvest } - =t(:harvest) + =t('buttons.harvest') diff --git a/app/views/shared/buttons/_save_seeds.haml b/app/views/shared/buttons/_save_seeds.haml index c1664de35..312f54cf4 100644 --- a/app/views/shared/buttons/_save_seeds.haml +++ b/app/views/shared/buttons/_save_seeds.haml @@ -1,4 +1,4 @@ - if planting.active? = link_to new_planting_seed_path(planting), class: 'btn btn-default btn-xs' do %span.glyphicon.glyphicon-heart{ title: t(:save_seeds) } - =t(:save_seeds) + =t('buttons.save_seeds') From 30255a24d26183f8ec7b07fb75b033ec2d794c3c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 13:40:56 +1300 Subject: [PATCH 06/68] Use buttons.* translations for glyphicons titles --- app/views/shared/_global_actions.html.haml | 8 ++++---- app/views/shared/buttons/_add_photo.haml | 2 +- app/views/shared/buttons/_delete.haml | 2 +- app/views/shared/buttons/_edit.haml | 2 +- app/views/shared/buttons/_finish_planting.html.haml | 2 +- app/views/shared/buttons/_finish_seeds.haml | 2 +- app/views/shared/buttons/_harvest_planting.haml | 4 ++-- app/views/shared/buttons/_save_seeds.haml | 4 ++-- config/locales/en.yml | 10 ++++++++++ 9 files changed, 23 insertions(+), 13 deletions(-) diff --git a/app/views/shared/_global_actions.html.haml b/app/views/shared/_global_actions.html.haml index d4b4a5e97..59481c858 100644 --- a/app/views/shared/_global_actions.html.haml +++ b/app/views/shared/_global_actions.html.haml @@ -1,6 +1,6 @@ %p .btn-group - = link_to t(:plant_something), new_planting_path, class: 'btn btn-default' - = link_to t(:harvest_something), new_harvest_path, class: 'btn btn-default' - = link_to t(:save_seeds), new_seed_path, class: 'btn btn-default' - = link_to t(:write_blog_post), new_post_path, class: 'btn btn-default' + = link_to t('buttons.plant_something'), new_planting_path, class: 'btn btn-default' + = link_to t('buttons.harvest_something'), new_harvest_path, class: 'btn btn-default' + = link_to t('buttons.save_seeds'), new_seed_path, class: 'btn btn-default' + = link_to t('buttons.write_blog_post'), new_post_path, class: 'btn btn-default' diff --git a/app/views/shared/buttons/_add_photo.haml b/app/views/shared/buttons/_add_photo.haml index c2c87f315..425ca52fc 100644 --- a/app/views/shared/buttons/_add_photo.haml +++ b/app/views/shared/buttons/_add_photo.haml @@ -1,4 +1,4 @@ - if can?(:create, Photo) = link_to path, class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-camera{ title: "Add photo" } + %span.glyphicon.glyphicon-camera{ title: t('buttons.add_photo') } =t('buttons.add_photo') diff --git a/app/views/shared/buttons/_delete.haml b/app/views/shared/buttons/_delete.haml index d89a51d2d..f4ae4f5cd 100644 --- a/app/views/shared/buttons/_delete.haml +++ b/app/views/shared/buttons/_delete.haml @@ -1,4 +1,4 @@ = link_to path, method: :delete, data: { confirm: t(:are_you_sure?) }, class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-trash{ title: t(:delete) } + %span.glyphicon.glyphicon-trash{ title: t('buttons.delete') } =t('buttons.delete') diff --git a/app/views/shared/buttons/_edit.haml b/app/views/shared/buttons/_edit.haml index 3e00821c5..1ad2fc77e 100644 --- a/app/views/shared/buttons/_edit.haml +++ b/app/views/shared/buttons/_edit.haml @@ -1,3 +1,3 @@ = link_to path, class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-pencil{ title: t(:edit) } + %span.glyphicon.glyphicon-pencil{ title: t('buttons.edit') } =t('buttons.edit') diff --git a/app/views/shared/buttons/_finish_planting.html.haml b/app/views/shared/buttons/_finish_planting.html.haml index c38ba3185..5d49418a1 100644 --- a/app/views/shared/buttons/_finish_planting.html.haml +++ b/app/views/shared/buttons/_finish_planting.html.haml @@ -1,5 +1,5 @@ - if can?(:edit, planting) && !planting.finished = link_to planting_path(planting, planting: { finished: 1 }), method: :put, class: 'btn btn-default btn-xs append-date' do - %span.glyphicon.glyphicon-ok{ title: t(:finished) } + %span.glyphicon.glyphicon-ok{ title: t('buttons.finished') } =t('buttons.mark_as_finished') diff --git a/app/views/shared/buttons/_finish_seeds.haml b/app/views/shared/buttons/_finish_seeds.haml index 49c34ac17..4589e50f2 100644 --- a/app/views/shared/buttons/_finish_seeds.haml +++ b/app/views/shared/buttons/_finish_seeds.haml @@ -1,5 +1,5 @@ - unless seed.finished = link_to seed_path(seed, seed: { finished: 1 }), method: :put, class: 'btn btn-default btn-xs append-date' do - %span.glyphicon.glyphicon-ok{ title: t(:finished) } + %span.glyphicon.glyphicon-ok{ title: t('buttons.finished') } =t('buttons.mark_as_finished') diff --git a/app/views/shared/buttons/_harvest_planting.haml b/app/views/shared/buttons/_harvest_planting.haml index 8845e4c01..d81b18fa2 100644 --- a/app/views/shared/buttons/_harvest_planting.haml +++ b/app/views/shared/buttons/_harvest_planting.haml @@ -1,4 +1,4 @@ - planting.active? && if can?(:create, Harvest) && can?(:edit, planting) = link_to new_planting_harvest_path(planting), class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-leaf{ title: :harvest } - =t('buttons.harvest') + %span.glyphicon.glyphicon-leaf{ title: = t('buttons.harvest') } + = t('buttons.harvest') diff --git a/app/views/shared/buttons/_save_seeds.haml b/app/views/shared/buttons/_save_seeds.haml index 312f54cf4..d18807b2b 100644 --- a/app/views/shared/buttons/_save_seeds.haml +++ b/app/views/shared/buttons/_save_seeds.haml @@ -1,4 +1,4 @@ - if planting.active? = link_to new_planting_seed_path(planting), class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-heart{ title: t(:save_seeds) } - =t('buttons.save_seeds') + %span.glyphicon.glyphicon-heart{ title: t('buttons.save_seeds') } + = t('buttons.save_seeds') diff --git a/config/locales/en.yml b/config/locales/en.yml index 879d7c51c..7f2778983 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -63,6 +63,16 @@ en: seed: one: seed other: seeds + buttons: + add_photo: Add photo + delete: Delete + edit: Edit + harvest: Harvest + harvest_something: Harvest something + mark_as_finished: Mark as finished + plant_something: Plant something + save_seeds: Save seeds + write_blog_post: Write blog post crops: index: subtitle: "%{crops_size} total" From 6c16dca9b4a85a2ca1b10a6fe565b7dd441c1fdb Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 14:13:12 +1300 Subject: [PATCH 07/68] Dry the gglypicons --- app/views/shared/_glyphicon.html.haml | 1 + app/views/shared/buttons/_add_photo.haml | 2 +- app/views/shared/buttons/_delete.haml | 2 +- app/views/shared/buttons/_edit.haml | 2 +- app/views/shared/buttons/_finish_planting.html.haml | 4 ++-- app/views/shared/buttons/_finish_seeds.haml | 2 +- app/views/shared/buttons/_harvest_planting.haml | 2 +- app/views/shared/buttons/_save_seeds.haml | 2 +- 8 files changed, 9 insertions(+), 8 deletions(-) create mode 100644 app/views/shared/_glyphicon.html.haml diff --git a/app/views/shared/_glyphicon.html.haml b/app/views/shared/_glyphicon.html.haml new file mode 100644 index 000000000..39f2546cf --- /dev/null +++ b/app/views/shared/_glyphicon.html.haml @@ -0,0 +1 @@ +%span{class: "glyphicon.glyphicon-#{icon}", title: t(title) } \ No newline at end of file diff --git a/app/views/shared/buttons/_add_photo.haml b/app/views/shared/buttons/_add_photo.haml index 425ca52fc..0e4a75c07 100644 --- a/app/views/shared/buttons/_add_photo.haml +++ b/app/views/shared/buttons/_add_photo.haml @@ -1,4 +1,4 @@ - if can?(:create, Photo) = link_to path, class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-camera{ title: t('buttons.add_photo') } + = render 'shared/glyphicon', icon: 'camera', title: 'buttons.add_photo' =t('buttons.add_photo') diff --git a/app/views/shared/buttons/_delete.haml b/app/views/shared/buttons/_delete.haml index f4ae4f5cd..8be23926a 100644 --- a/app/views/shared/buttons/_delete.haml +++ b/app/views/shared/buttons/_delete.haml @@ -1,4 +1,4 @@ = link_to path, method: :delete, data: { confirm: t(:are_you_sure?) }, class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-trash{ title: t('buttons.delete') } + = render 'shared/glyphicon', icon: 'trash', title: 'buttons.delete' =t('buttons.delete') diff --git a/app/views/shared/buttons/_edit.haml b/app/views/shared/buttons/_edit.haml index 1ad2fc77e..f7f75ea36 100644 --- a/app/views/shared/buttons/_edit.haml +++ b/app/views/shared/buttons/_edit.haml @@ -1,3 +1,3 @@ = link_to path, class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-pencil{ title: t('buttons.edit') } + = render 'shared/glyphicon', icon: 'pencil', title: 'buttons.edit' =t('buttons.edit') diff --git a/app/views/shared/buttons/_finish_planting.html.haml b/app/views/shared/buttons/_finish_planting.html.haml index 5d49418a1..d0a931b41 100644 --- a/app/views/shared/buttons/_finish_planting.html.haml +++ b/app/views/shared/buttons/_finish_planting.html.haml @@ -1,5 +1,5 @@ - if can?(:edit, planting) && !planting.finished = link_to planting_path(planting, planting: { finished: 1 }), method: :put, class: 'btn btn-default btn-xs append-date' do - %span.glyphicon.glyphicon-ok{ title: t('buttons.finished') } - =t('buttons.mark_as_finished') + = render 'shared/glyphicon', icon: 'ok', title: 'buttons.finished' + = t('buttons.mark_as_finished') diff --git a/app/views/shared/buttons/_finish_seeds.haml b/app/views/shared/buttons/_finish_seeds.haml index 4589e50f2..23316d861 100644 --- a/app/views/shared/buttons/_finish_seeds.haml +++ b/app/views/shared/buttons/_finish_seeds.haml @@ -1,5 +1,5 @@ - unless seed.finished = link_to seed_path(seed, seed: { finished: 1 }), method: :put, class: 'btn btn-default btn-xs append-date' do - %span.glyphicon.glyphicon-ok{ title: t('buttons.finished') } + = render 'shared/glyphicon', icon: 'ok', title: 'buttons.finished' =t('buttons.mark_as_finished') diff --git a/app/views/shared/buttons/_harvest_planting.haml b/app/views/shared/buttons/_harvest_planting.haml index d81b18fa2..296ee30a0 100644 --- a/app/views/shared/buttons/_harvest_planting.haml +++ b/app/views/shared/buttons/_harvest_planting.haml @@ -1,4 +1,4 @@ - planting.active? && if can?(:create, Harvest) && can?(:edit, planting) = link_to new_planting_harvest_path(planting), class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-leaf{ title: = t('buttons.harvest') } + = render 'shared/glyphicon', icon: 'leaf', title: 'buttons.harvest' = t('buttons.harvest') diff --git a/app/views/shared/buttons/_save_seeds.haml b/app/views/shared/buttons/_save_seeds.haml index d18807b2b..d4cf794f5 100644 --- a/app/views/shared/buttons/_save_seeds.haml +++ b/app/views/shared/buttons/_save_seeds.haml @@ -1,4 +1,4 @@ - if planting.active? = link_to new_planting_seed_path(planting), class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-heart{ title: t('buttons.save_seeds') } + = render 'shared/glyphicon', icon: 'heart', title: 'buttons.save_seeds' = t('buttons.save_seeds') From 2f271da9099399c0b75f6c2db832088882cf55bd Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 14:13:36 +1300 Subject: [PATCH 08/68] Move global buttons and search --- app/views/crops/_search_bar.haml | 9 ++ app/views/layouts/_header.html.haml | 107 +++++++++++------------- app/views/layouts/application.html.haml | 21 ++--- 3 files changed, 69 insertions(+), 68 deletions(-) create mode 100644 app/views/crops/_search_bar.haml diff --git a/app/views/crops/_search_bar.haml b/app/views/crops/_search_bar.haml new file mode 100644 index 000000000..390c32390 --- /dev/null +++ b/app/views/crops/_search_bar.haml @@ -0,0 +1,9 @@ += form_tag crops_search_path, method: :get, id: 'navbar-search' do + = label_tag :term, "Search crop database:", class: 'sr-only' + .input + .input-group + = text_field_tag 'term', nil, class: 'search-query input-medium form-control', placeholder: 'Search crops' + .input-group-btn + %button.btn.btn-default{ style: "height: 34px;" } + = submit_tag "Search", class: 'btn sr-only' + %span.glyphicon.glyphicon-search diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml index d2b8fd01c..ca6bf15bc 100644 --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -17,72 +17,67 @@ alt: ENV['GROWSTUFF_SITE_NAME']) .form.navbar-form.pull-left - = form_tag crops_search_path, method: :get, id: 'navbar-search' do - = label_tag :term, "Search crop database:", class: 'sr-only' - .input - .input-group - = text_field_tag 'term', nil, class: 'search-query input-medium form-control', placeholder: 'Search crops' - .input-group-btn - %button.btn.btn-default{ style: "height: 34px;" } - = submit_tag "Search", class: 'btn sr-only' - %span.glyphicon.glyphicon-search + = render 'crops/search_bar' .navbar-collapse.collapse#navbar-collapse - %ul.nav.navbar-nav.navbar-right - %li.dropdown< - %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: crops_path } - = t('.crops') - %b.caret - %ul.dropdown-menu - %li= link_to t('.browse_crops'), crops_path - %li= link_to t('.seeds'), seeds_path - %li= link_to t('.plantings'), plantings_path - %li= link_to t('.harvests'), harvests_path - %li.dropdown< - %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: members_path } - = t('.community') - %b.caret - %ul.dropdown-menu - %li= link_to t('.community_map'), places_path - %li= link_to t('.browse_members'), members_path - %li= link_to t('.posts'), posts_path - %li= link_to t('.forums'), forums_path - - - if member_signed_in? + .navbar-right + = render 'shared/global_actions' + %ul.nav.navbar-nav.navbar-right %li.dropdown< - %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: root_path } - - if current_member.notifications.unread_count.positive? - = t('.your_stuff', unread_count: current_member.notifications.unread_count) - - else - = t('.current_memberlogin_name', current_memberlogin_name: current_member.login_name) + %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: crops_path } + = t('.crops') %b.caret %ul.dropdown-menu - %li= link_to t('.profile'), member_path(current_member) - %li= link_to t('.gardens'), gardens_by_owner_path(owner: current_member.slug) - %li= link_to t('.plantings'), plantings_by_owner_path(owner: current_member.slug) - %li= link_to t('.harvest'), harvests_by_owner_path(owner: current_member.slug) - %li= link_to t('.seeds'), seeds_by_owner_path(owner: current_member.slug) - %li= link_to t('.posts'), posts_by_author_path(author: current_member.slug) - %li + %li= link_to t('.browse_crops'), crops_path + %li= link_to t('.seeds'), seeds_path + %li= link_to t('.plantings'), plantings_path + %li= link_to t('.harvests'), harvests_path + %li.dropdown< + %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: members_path } + = t('.community') + %b.caret + %ul.dropdown-menu + %li= link_to t('.community_map'), places_path + %li= link_to t('.browse_members'), members_path + %li= link_to t('.posts'), posts_path + %li= link_to t('.forums'), forums_path + + - if member_signed_in? + %li.dropdown< + %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: root_path } - if current_member.notifications.unread_count.positive? - = link_to(t('.inbox_unread', unread_count: current_member.notifications.unread_count), - notifications_path) + = t('.your_stuff', unread_count: current_member.notifications.unread_count) - else - = link_to(t('.inbox'), notifications_path) - - if current_member.role?(:crop_wrangler) || current_member.role?(:admin) - %li.divider{ role: 'presentation' } - - if current_member.role?(:crop_wrangler) - %li= link_to t('.crop_wrangling'), wrangle_crops_path - - if current_member.role?(:admin) - %li= link_to t('.admin'), admin_path + = t('.current_memberlogin_name', current_memberlogin_name: current_member.login_name) + %b.caret + %ul.dropdown-menu + %li= link_to t('.profile'), member_path(current_member) + %li= link_to t('.gardens'), gardens_by_owner_path(owner: current_member.slug) + %li= link_to t('.plantings'), plantings_by_owner_path(owner: current_member.slug) + %li= link_to t('.harvest'), harvests_by_owner_path(owner: current_member.slug) + %li= link_to t('.seeds'), seeds_by_owner_path(owner: current_member.slug) + %li= link_to t('.posts'), posts_by_author_path(author: current_member.slug) + %li + - if current_member.notifications.unread_count.positive? + = link_to(t('.inbox_unread', unread_count: current_member.notifications.unread_count), + notifications_path) + - else + = link_to(t('.inbox'), notifications_path) + - if current_member.role?(:crop_wrangler) || current_member.role?(:admin) + %li.divider{ role: 'presentation' } + - if current_member.role?(:crop_wrangler) + %li= link_to t('.crop_wrangling'), wrangle_crops_path + - if current_member.role?(:admin) + %li= link_to t('.admin'), admin_path - %li= link_to t('.sign_out'), destroy_member_session_path, method: :delete - - - else - %li= link_to t('.sign_in'), new_member_session_path, id: 'navbar-signin' - %li= link_to t('.sign_up'), new_member_registration_path, id: 'navbar-signup' + %li= link_to t('.sign_out'), destroy_member_session_path, method: :delete + - else + %li= link_to t('.sign_in'), new_member_session_path, id: 'navbar-signin' + %li= link_to t('.sign_up'), new_member_registration_path, id: 'navbar-signup' + -# anchor tag for accessibility link to skip the navigation menu %a{ name: 'skipnav' } + diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 34dbbdfe5..8fc527ff1 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -6,19 +6,16 @@ = render partial: "layouts/header" #maincontainer - .row - .col-md-12 - = render 'shared/global_actions' - - if content_for?(:title) - %h1#title - = yield(:title) - - if content_for?(:subtitle) - %small= yield(:subtitle) + - if content_for?(:title) + %h1#title + = yield(:title) + - if content_for?(:subtitle) + %small= yield(:subtitle) - - if content_for?(:buttonbar) - .btn-group.layout-actions= yield(:buttonbar) - = render partial: "shared/flash_messages", flash: flash - = yield + - if content_for?(:buttonbar) + .btn-group.layout-actions= yield(:buttonbar) + = render partial: "shared/flash_messages", flash: flash + = yield %footer = render partial: "layouts/footer" From acc100f744d88d61bd2cf9e786e0adea33c74924 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 14:19:40 +1300 Subject: [PATCH 09/68] Adding missing translations for plantings --- config/locales/en.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/config/locales/en.yml b/config/locales/en.yml index 7f2778983..4b104ab81 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -225,6 +225,13 @@ en: index: title: "%{site_name} Community Map" plantings: + badges: + days_until_finished: days until finished + days_until_harvest: days until harvest + harvesting_now: harvesting now + late_finishing: late finishing + sharedbuttonsfinish_planting: shared/buttons/finish_planting + super_late: super late form: finish_helper: > A planting is finished when you've harvested all of the crop, or it dies, or it's otherwise From 6eebc7480c9e4fd8a722fb8b8c9a4c06b679dbbb Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 18:41:51 +1300 Subject: [PATCH 10/68] Moved global actions - only show if no buttonbar --- app/views/layouts/_header.html.haml | 1 - app/views/layouts/application.html.haml | 24 ++++++++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml index ca6bf15bc..990a23c76 100644 --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -21,7 +21,6 @@ .navbar-collapse.collapse#navbar-collapse .navbar-right - = render 'shared/global_actions' %ul.nav.navbar-nav.navbar-right %li.dropdown< %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: crops_path } diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 8fc527ff1..2b1c2e982 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -6,15 +6,23 @@ = render partial: "layouts/header" #maincontainer - - if content_for?(:title) - %h1#title - = yield(:title) - - if content_for?(:subtitle) - %small= yield(:subtitle) - - - if content_for?(:buttonbar) - .btn-group.layout-actions= yield(:buttonbar) = render partial: "shared/flash_messages", flash: flash + .row + .col-md-8 + - if content_for?(:title) + %h1#title + = yield(:title) + - if content_for?(:subtitle) + %small= yield(:subtitle) + + + + .col-md-4 + - if content_for?(:buttonbar) + .btn-group.layout-actions= yield(:buttonbar) + - else + = render 'shared/global_actions' + = yield %footer From 279ce38c86cf19048fb0ec897668deb3d2c2bdd6 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 18:42:02 +1300 Subject: [PATCH 11/68] Moving actions to the button bar --- app/views/crops/_wrangle.html.haml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/crops/_wrangle.html.haml b/app/views/crops/_wrangle.html.haml index 8e8f87558..16b7ed23b 100644 --- a/app/views/crops/_wrangle.html.haml +++ b/app/views/crops/_wrangle.html.haml @@ -4,11 +4,11 @@ You are a = succeed "." do %strong CROP WRANGLER - %p + - content_for(:buttonbar) do - if can? :edit, crop - = link_to 'Edit crop', edit_crop_path(crop), class: 'btn btn-default btn-xs' + = link_to t(:edit_crop), edit_crop_path(crop), class: 'btn btn-default' - if can? :destroy, crop = link_to 'Delete crop', crop, method: :delete, - data: { confirm: 'Are you sure?' }, - class: 'btn btn-default btn-xs' + data: { confirm: t('are_you_sure') }, + class: 'btn btn-default' From f5a63d770c57b22543fd97d52f72d3a3116ae39d Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 18:42:13 +1300 Subject: [PATCH 12/68] Moving garden actions to button bar --- app/views/gardens/show.html.haml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/views/gardens/show.html.haml b/app/views/gardens/show.html.haml index 8b45b0b16..b71f09c78 100644 --- a/app/views/gardens/show.html.haml +++ b/app/views/gardens/show.html.haml @@ -16,7 +16,8 @@ .row .col-md-9 - = render 'gardens/actions', garden: @garden + -content_for(:buttonbar) do + = render 'gardens/actions', garden: @garden - unless @garden.active @@ -57,7 +58,7 @@ - if @finished_plantings.size.positive? - @finished_plantings.each do |planting| .col-xs-6.col-md-2 - = render partial: "plantings/thumbnail", locals: { planting: planting } + = render "plantings/thumbnail", planting: planting - else %p Nothing has been planted here. .col-md-3 From a4f20bff7783f1a71d31309e6885995882d2b603 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 18:42:21 +1300 Subject: [PATCH 13/68] More button label translations --- config/locales/en.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config/locales/en.yml b/config/locales/en.yml index 4b104ab81..17a7acc36 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -63,14 +63,17 @@ en: seed: one: seed other: seeds + are_you_sure: 'Are you sure?' buttons: add_photo: Add photo delete: Delete edit: Edit harvest: Harvest + harvest_crop: Harvest %{crop_name} harvest_something: Harvest something mark_as_finished: Mark as finished plant_something: Plant something + plant_crop: Plant %{crop_name} save_seeds: Save seeds write_blog_post: Write blog post crops: From 614eff06b98a206f42d407b80047fdf68f5657d2 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 18:42:34 +1300 Subject: [PATCH 14/68] Bigger buttons --- app/views/shared/_global_actions.html.haml | 13 +++++++------ app/views/shared/buttons/_edit.haml | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/views/shared/_global_actions.html.haml b/app/views/shared/_global_actions.html.haml index 59481c858..2b5ca1168 100644 --- a/app/views/shared/_global_actions.html.haml +++ b/app/views/shared/_global_actions.html.haml @@ -1,6 +1,7 @@ -%p - .btn-group - = link_to t('buttons.plant_something'), new_planting_path, class: 'btn btn-default' - = link_to t('buttons.harvest_something'), new_harvest_path, class: 'btn btn-default' - = link_to t('buttons.save_seeds'), new_seed_path, class: 'btn btn-default' - = link_to t('buttons.write_blog_post'), new_post_path, class: 'btn btn-default' +.btn-group + = link_to t('buttons.plant_something'), new_planting_path, class: 'btn btn-default' + = link_to t('buttons.harvest_something'), new_harvest_path, class: 'btn btn-default' + = link_to t('buttons.save_seeds'), new_seed_path, class: 'btn btn-default' + +.btn-group + = link_to t('buttons.write_blog_post'), new_post_path, class: 'btn btn-default' diff --git a/app/views/shared/buttons/_edit.haml b/app/views/shared/buttons/_edit.haml index f7f75ea36..f80cdf917 100644 --- a/app/views/shared/buttons/_edit.haml +++ b/app/views/shared/buttons/_edit.haml @@ -1,3 +1,3 @@ -= link_to path, class: 'btn btn-default btn-xs' do += link_to path, class: 'btn btn-default' do = render 'shared/glyphicon', icon: 'pencil', title: 'buttons.edit' =t('buttons.edit') From fcfe7f196e746b3f58649a57174c28948583ba2b Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 18:42:44 +1300 Subject: [PATCH 15/68] Button for planting stuff --- app/views/shared/buttons/_plant.html.haml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 app/views/shared/buttons/_plant.html.haml diff --git a/app/views/shared/buttons/_plant.html.haml b/app/views/shared/buttons/_plant.html.haml new file mode 100644 index 000000000..8044dddef --- /dev/null +++ b/app/views/shared/buttons/_plant.html.haml @@ -0,0 +1,3 @@ += link_to new_planting_path(garden_id: garden.id), class: 'btn btn-default' do + = render 'shared/glyphicon', icon: 'grain', title: 'buttons.plant' + = t('buttons.plant_something_here') \ No newline at end of file From d1c367e3d909cc0cd55e7a5afedc25f6399115aa Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 18:42:52 +1300 Subject: [PATCH 16/68] Fixed glyphicons --- app/views/shared/_glyphicon.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/shared/_glyphicon.html.haml b/app/views/shared/_glyphicon.html.haml index 39f2546cf..dd34405cc 100644 --- a/app/views/shared/_glyphicon.html.haml +++ b/app/views/shared/_glyphicon.html.haml @@ -1 +1 @@ -%span{class: "glyphicon.glyphicon-#{icon}", title: t(title) } \ No newline at end of file +%span.glyphicon{class: "glyphicon-#{icon}", title: t(title) } \ No newline at end of file From ba3863739254432fecae9d18fe99085c3bf51da8 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 18:43:07 +1300 Subject: [PATCH 17/68] Wrapping crop actions in btn-group --- app/views/crops/_actions.html.haml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/views/crops/_actions.html.haml b/app/views/crops/_actions.html.haml index e15979f61..b27f4b89a 100644 --- a/app/views/crops/_actions.html.haml +++ b/app/views/crops/_actions.html.haml @@ -1,9 +1,10 @@ .crop-actions - - if can? :create, Planting - = link_to "Plant this", new_planting_path(crop_id: crop.id), class: 'btn btn-default' + .btn-group + - if can? :create, Planting + = link_to t('buttons.plant_crop', crop_name: crop.name), new_planting_path(crop_id: crop.id), class: 'btn btn-default' - - if can? :create, Harvest - = link_to "Harvest this", new_harvest_path(crop_id: crop.id), class: 'btn btn-default' + - if can? :create, Harvest + = link_to t('buttons.harvest_crop', crop_name: crop.name), new_harvest_path(crop_id: crop.id), class: 'btn btn-default' - - if can? :create, Seed - = link_to 'Add seeds to stash', new_seed_path(params: { crop_id: crop.id }), class: 'btn btn-default' + - if can? :create, Seed + = link_to t('buttons.add_seed_to_stash'), new_seed_path(params: { crop_id: crop.id }), class: 'btn btn-default' From de3c7fb1c51cf0539ebf6cffce021da82dc10494 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 18:43:25 +1300 Subject: [PATCH 18/68] Move homepage title to the :title content --- app/views/home/index.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index 0259ce590..be274c930 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -1,7 +1,7 @@ .homepage.row .col-md-12 - if member_signed_in? - %h1= t('.welcome', site_name: ENV['GROWSTUFF_SITE_NAME'], member_name: current_member) + - content_for :title, t('.welcome', site_name: ENV['GROWSTUFF_SITE_NAME'], member_name: current_member) = render 'stats' - else From b86e6e6dab7773ed762f218609a6a878cc7cfb43 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 18:43:37 +1300 Subject: [PATCH 19/68] More translations in garden actions --- app/views/gardens/_actions.html.haml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/app/views/gardens/_actions.html.haml b/app/views/gardens/_actions.html.haml index a5187991e..5ff23e09a 100644 --- a/app/views/gardens/_actions.html.haml +++ b/app/views/gardens/_actions.html.haml @@ -2,28 +2,29 @@ - if can?(:edit, garden) .btn-group - if garden.active - = link_to new_planting_path(garden_id: garden.id), class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-grain{ title: "Plant" } - Plant something - = link_to "Mark as inactive", garden_path(garden, garden: { active: 0 }), - method: :put, class: 'btn btn-default btn-xs', + = render 'shared/buttons/plant', garden: garden + = render 'shared/glyphicon', icon: 'ban', title: 'buttons.mark_as_inactive' + = link_to t('buttons.mark_as_inactive'), garden_path(garden, garden: { active: 0 }), + method: :put, class: 'btn btn-default', data: { confirm: 'All plantings associated with this garden will be marked as finished. Are you sure?' } - else + = render 'shared/glyphicon', icon: 'check', title: 'buttons.mark_active' = link_to "Mark as active", garden_path(garden, garden: { active: 1 }), method: :put + = render 'shared/buttons/edit', path: edit_garden_path(garden) - if can?(:edit, garden) && can?(:create, Photo) = link_to new_photo_path(type: "garden", id: garden.id), - class: 'btn btn-default btn-xs' do + class: 'btn btn-default' do %span.glyphicon.glyphicon-camera{ title: "Add photo" } - Add photo + = t('buttons.add_a_photo') - if can?(:destroy, garden) .pull-right = link_to garden_path(garden), method: :delete, data: { confirm: 'All plantings associated with this garden will also be deleted. Are you sure?' }, - class: 'btn btn-default btn-xs', id: 'delete_garden_link' do + class: 'btn btn-default', id: 'delete_garden_link' do %span.glyphicon.glyphicon-trash{ title: "Delete" } - Delete + = t('buttons.delete_this_garden') From 67e58fe9018a2c03f65cf8b88b24a202ac9d4863 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 22 Jan 2019 15:19:24 +1300 Subject: [PATCH 20/68] Moving buttons to the right of page (with translations) --- app/helpers/buttons_helper.rb | 66 ++++++++++++++++++++++ app/views/crops/_actions.html.haml | 9 ++- app/views/crops/_wrangle.html.haml | 14 +++-- app/views/gardens/_actions.html.haml | 25 ++------ app/views/layouts/application.html.haml | 11 ++-- app/views/plantings/_actions.html.haml | 17 +++--- app/views/shared/_global_actions.html.haml | 24 ++++++-- app/views/shared/_glyphicon.html.haml | 3 +- config/locales/en.yml | 36 ++++++++---- 9 files changed, 144 insertions(+), 61 deletions(-) create mode 100644 app/helpers/buttons_helper.rb diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb new file mode 100644 index 000000000..4dbf7015a --- /dev/null +++ b/app/helpers/buttons_helper.rb @@ -0,0 +1,66 @@ +module ButtonsHelper + def garden_plant_something_button(garden) + button(new_planting_path(garden_id: garden.id), 'buttons.plant_something_here', 'leaf') + end + + def garden_mark_active(garden) + link_to t('buttons.mark_as_active'), garden_path(garden, garden: { active: 1 }), method: :put, class: 'btn btn-default btn-xs' + end + + def garden_mark_inactive(garden) + link_to t('buttons.mark_as_inactive'), + garden_path(garden, garden: { active: 0 }), + method: :put, class: 'btn btn-default btn-xs', + data: { confirm: 'All plantings associated with this garden will be marked as finished. Are you sure?' } + end + + def garden_add_photo_button(garden) + button(new_photo_path(id: garden.id, type: "garden"), 'buttons.add_a_photo', 'camera') + end + + def garden_edit_button(garden) + button(edit_garden_path(garden), 'buttons.edit', 'pencil') + end + + def planting_edit_button(planting) + button(edit_planting_path(planting), 'buttons.edit', 'pencil') + end + + def planting_add_photo_button(planting) + button(new_photo_path(id: planting.id, type: 'planting'), 'buttons.add_photo', 'camera') + end + + def planting_finish_button(planting) + if can?(:edit, planting) + button( + planting_path(planting, planting: { finished: 1 }), + 'buttons.mark_as_finished', + 'ok' + ) + end + end + + def planting_harvest_button(planting) + if planting.active? && can?(:create, Harvest) && can?(:edit, planting) + button(new_planting_harvest_path(planting), 'buttons.harvest', 'apple') + end + end + + def planting_save_seeds_button(planting) + button(new_planting_seed_path(planting), 'buttons.save_seeds', 'heart') if can?(:edit, planting) + end + + def delete_button(model, message: 'are_you_sure') + link_to model, method: :delete, data: { confirm: t(message) }, class: 'btn btn-default btn-xs' do + render 'shared/glyphicon', icon: 'trash', title: 'buttons.delete' + end + end + + private + + def button(path, title, icon, size = 'btn-xs') + link_to path, class: "btn btn-default #{size}" do + render 'shared/glyphicon', icon: icon, title: title + end + end +end diff --git a/app/views/crops/_actions.html.haml b/app/views/crops/_actions.html.haml index b27f4b89a..5cc80036b 100644 --- a/app/views/crops/_actions.html.haml +++ b/app/views/crops/_actions.html.haml @@ -1,10 +1,13 @@ .crop-actions .btn-group - if can? :create, Planting - = link_to t('buttons.plant_crop', crop_name: crop.name), new_planting_path(crop_id: crop.id), class: 'btn btn-default' + = link_to new_planting_path(crop_id: crop.id), class: 'btn btn-default' do + = t('buttons.plant_crop', crop_name: crop.name) - if can? :create, Harvest - = link_to t('buttons.harvest_crop', crop_name: crop.name), new_harvest_path(crop_id: crop.id), class: 'btn btn-default' + = link_to new_harvest_path(crop_id: crop.id), class: 'btn btn-default' do + = t('buttons.harvest_crop', crop_name: crop.name) - if can? :create, Seed - = link_to t('buttons.add_seed_to_stash'), new_seed_path(params: { crop_id: crop.id }), class: 'btn btn-default' + = link_to new_seed_path(crop_id: crop.id), class: 'btn btn-default' do + = t('buttons.add_seed_to_stash', crop_name: crop.name) diff --git a/app/views/crops/_wrangle.html.haml b/app/views/crops/_wrangle.html.haml index 16b7ed23b..fafafd490 100644 --- a/app/views/crops/_wrangle.html.haml +++ b/app/views/crops/_wrangle.html.haml @@ -4,11 +4,13 @@ You are a = succeed "." do %strong CROP WRANGLER - - content_for(:buttonbar) do - - if can? :edit, crop + + - if can? :edit, crop + %p = link_to t(:edit_crop), edit_crop_path(crop), class: 'btn btn-default' - - if can? :destroy, crop + - if can? :destroy, crop + %p = link_to 'Delete crop', crop, - method: :delete, - data: { confirm: t('are_you_sure') }, - class: 'btn btn-default' + method: :delete, + data: { confirm: t('are_you_sure') }, + class: 'btn btn-default' diff --git a/app/views/gardens/_actions.html.haml b/app/views/gardens/_actions.html.haml index 5ff23e09a..54842b577 100644 --- a/app/views/gardens/_actions.html.haml +++ b/app/views/gardens/_actions.html.haml @@ -2,29 +2,16 @@ - if can?(:edit, garden) .btn-group - if garden.active - = render 'shared/buttons/plant', garden: garden - = render 'shared/glyphicon', icon: 'ban', title: 'buttons.mark_as_inactive' - = link_to t('buttons.mark_as_inactive'), garden_path(garden, garden: { active: 0 }), - method: :put, class: 'btn btn-default', - data: { confirm: 'All plantings associated with this garden will be marked as finished. Are you sure?' } + = garden_plant_something_button(garden) + = garden_mark_inactive(garden) - else - = render 'shared/glyphicon', icon: 'check', title: 'buttons.mark_active' - = link_to "Mark as active", garden_path(garden, garden: { active: 1 }), - method: :put + = garden_mark_active(garden) - = render 'shared/buttons/edit', path: edit_garden_path(garden) + = garden_edit_button(garden) - if can?(:edit, garden) && can?(:create, Photo) - = link_to new_photo_path(type: "garden", id: garden.id), - class: 'btn btn-default' do - %span.glyphicon.glyphicon-camera{ title: "Add photo" } - = t('buttons.add_a_photo') + = garden_add_photo_button(garden) - if can?(:destroy, garden) .pull-right - = link_to garden_path(garden), - method: :delete, - data: { confirm: 'All plantings associated with this garden will also be deleted. Are you sure?' }, - class: 'btn btn-default', id: 'delete_garden_link' do - %span.glyphicon.glyphicon-trash{ title: "Delete" } - = t('buttons.delete_this_garden') + = delete_button(garden, message: 'All plantings associated with this garden will also be deleted. Are you sure?') diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 2b1c2e982..3ac9f7cf6 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -14,15 +14,14 @@ = yield(:title) - if content_for?(:subtitle) %small= yield(:subtitle) - - + + - if content_for?(:buttonbar) + .btn-group.layout-actions + = yield(:buttonbar) .col-md-4 - - if content_for?(:buttonbar) - .btn-group.layout-actions= yield(:buttonbar) - - else - = render 'shared/global_actions' + = render 'shared/global_actions' = yield %footer diff --git a/app/views/plantings/_actions.html.haml b/app/views/plantings/_actions.html.haml index 6f5b1b93d..ca3fceefc 100644 --- a/app/views/plantings/_actions.html.haml +++ b/app/views/plantings/_actions.html.haml @@ -1,12 +1,13 @@ - if can?(:edit, planting) - .btn-group.planting-actions - = render 'shared/buttons/edit', path: edit_planting_path(planting) - = render 'shared/buttons/add_photo', path: new_photo_path(id: planting.id, type: 'planting') + .planting-actions + .btn-group + = planting_edit_button(planting) + = planting_add_photo_button(planting) - - if planting.active? - = render 'shared/buttons/finish_planting', planting: planting - = render 'shared/buttons/harvest_planting', planting: planting - = render 'shared/buttons/save_seeds', planting: planting + - if planting.active? + = planting_finish_button(planting) + = planting_harvest_button(planting) + = planting_save_seeds_button(planting) - if can? :destroy, planting - = render 'shared/buttons/delete', path: planting + = delete_button(planting) diff --git a/app/views/shared/_global_actions.html.haml b/app/views/shared/_global_actions.html.haml index 2b5ca1168..29b2f1ef3 100644 --- a/app/views/shared/_global_actions.html.haml +++ b/app/views/shared/_global_actions.html.haml @@ -1,7 +1,19 @@ -.btn-group - = link_to t('buttons.plant_something'), new_planting_path, class: 'btn btn-default' - = link_to t('buttons.harvest_something'), new_harvest_path, class: 'btn btn-default' - = link_to t('buttons.save_seeds'), new_seed_path, class: 'btn btn-default' +- if signed_in? + .global-actions + .btn-group + = link_to gardens_by_owner_path(owner: current_member.slug), class: 'btn btn-default' do + = t('links.my_gardens') -.btn-group - = link_to t('buttons.write_blog_post'), new_post_path, class: 'btn btn-default' + .btn-group + = link_to new_planting_path, class: 'btn btn-default' do + = t('buttons.plant') + = link_to new_harvest_path, class: 'btn btn-default' do + = t('buttons.harvest') + = link_to new_seed_path, class: 'btn btn-default' do + = t('buttons.save_seeds') + + .btn-group + = link_to t('buttons.write_blog_post'), new_post_path, class: 'btn btn-default' + +- content_for(:attributions) do + seed by Template from the Noun Project \ No newline at end of file diff --git a/app/views/shared/_glyphicon.html.haml b/app/views/shared/_glyphicon.html.haml index dd34405cc..65cba2bdd 100644 --- a/app/views/shared/_glyphicon.html.haml +++ b/app/views/shared/_glyphicon.html.haml @@ -1 +1,2 @@ -%span.glyphicon{class: "glyphicon-#{icon}", title: t(title) } \ No newline at end of file +%span.glyphicon{class: "glyphicon-#{icon}", title: t(title) } +=t(title) \ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index 17a7acc36..d850060b2 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -63,17 +63,27 @@ en: seed: one: seed other: seeds - are_you_sure: 'Are you sure?' + application_helper: + title: + title: + default: Default + are_you_sure: Are you sure? buttons: + add: Add add_photo: Add photo + add_seed_to_stash: Add %{crop_name} seeds to stash delete: Delete edit: Edit harvest: Harvest harvest_crop: Harvest %{crop_name} harvest_something: Harvest something + mark_as_active: Mark as active mark_as_finished: Mark as finished - plant_something: Plant something + mark_as_inactive: Mark as inactive + plant: Plant plant_crop: Plant %{crop_name} + plant_something: Plant something + plant_something_here: Plant something here save_seeds: Save seeds write_blog_post: Write blog post crops: @@ -84,6 +94,7 @@ en: link: You have %{number_crops} crops awaiting approval subtitle: Pending approval title: Requested crops + edit_crop: Edit crop forms: optional: "(Optional)" forums: @@ -95,28 +106,25 @@ en: form: location_helper: If you have a location set in your profile, it will be used when you create a new garden. location: "%{owner}'s %{garden}" - updated: Garden was successfully updated. overview: - gardensphoto: gardens/photo - plantingsthumbnail: plantings/thumbnail - no_plantings: no plantings gardensactions: gardens/actions + gardensphoto: gardens/photo + no_plantings: no plantings + plantingsthumbnail: plantings/thumbnail + updated: Garden was successfully updated. harvests: created: Harvest was successfully created. index: title: crop_harvests: Everyone's %{crop} harvests - planting_harvests: Harvests from %{planting} default: Everyone's harvests owner_harvests: "%{owner} harvests" + planting_harvests: Harvests from %{planting} updated: Harvest was successfully updated. home: blurb: already_html: Or %{sign_in} if you already have an account - intro: > - %{site_name} is a community of food gardeners. We're building an open source - platform to help you learn about growing food, track what you plant and harvest, - and swap seeds and produce with other gardeners near you. + intro: "%{site_name} is a community of food gardeners. We're building an open source platform to help you learn about growing food, track what you plant and harvest, and swap seeds and produce with other gardeners near you.\n" perks: Join now for your free garden journal, seed sharing, forums, and more. sign_in_linktext: sign in sign_up: Sign up @@ -135,6 +143,7 @@ en: harvest: Harvest plant: Plant post: Post + recently_added: Recently added welcome: Welcome to %{site_name}, %{member_name} members: title: Some of our members @@ -164,6 +173,8 @@ en: talk_linktext: Growstuff Talk why_linktext: why Growstuff is open source wiki_linktext: Growstuff Wiki + plantings: + recently_planted: Recently planted seeds: crop: Crop description: Description @@ -208,6 +219,8 @@ en: support_growstuff: Support Growstuff toggle_navigation: Toggle Navigation your_stuff: Your Stuff (%{unread_count}) + links: + my_gardens: My gardens members: index: title: "%{site_name} members" @@ -250,7 +263,6 @@ en: badges: late_finishing: late finishing super_late: super late - sharedbuttonsfinish_planting: shared/buttons/finish_planting days_until_finished: days until finished harvesting_now: harvesting now days_until_harvest: days until harvest From 313a18db080736d6f4656863f15ce4017058a305 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 22 Jan 2019 15:55:41 +1300 Subject: [PATCH 21/68] Titles of pages consistent with buttons to pages --- app/views/harvests/new.html.haml | 2 +- app/views/plantings/new.html.haml | 2 +- app/views/posts/new.html.haml | 2 +- app/views/seeds/new.html.haml | 2 +- config/locales/en.yml | 4 ++++ 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/views/harvests/new.html.haml b/app/views/harvests/new.html.haml index 5b5004622..f3a9dbe75 100644 --- a/app/views/harvests/new.html.haml +++ b/app/views/harvests/new.html.haml @@ -1,3 +1,3 @@ -- content_for :title, "New Harvest" +- content_for :title, t('harvests.harvest_something') = render 'form' diff --git a/app/views/plantings/new.html.haml b/app/views/plantings/new.html.haml index f28af6b19..c509e5646 100644 --- a/app/views/plantings/new.html.haml +++ b/app/views/plantings/new.html.haml @@ -1,3 +1,3 @@ -= content_for :title, "Plant something" += content_for :title, t('plantings.plant_something') = render 'form' diff --git a/app/views/posts/new.html.haml b/app/views/posts/new.html.haml index 75b111f6e..748c290b8 100644 --- a/app/views/posts/new.html.haml +++ b/app/views/posts/new.html.haml @@ -1,3 +1,3 @@ -= content_for :title, @forum ? "Post in #{@forum.name}" : "Post something" += content_for :title, @forum ? "Post in #{@forum.name}" : t('posts.write_blog_post') = render 'form' diff --git a/app/views/seeds/new.html.haml b/app/views/seeds/new.html.haml index 834c958d8..6a59b7050 100644 --- a/app/views/seeds/new.html.haml +++ b/app/views/seeds/new.html.haml @@ -1,3 +1,3 @@ -- content_for :title, "Add seeds" +- content_for :title, t('seeds.save_seeds') = render 'form' diff --git a/config/locales/en.yml b/config/locales/en.yml index d850060b2..850492e09 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -114,6 +114,7 @@ en: updated: Garden was successfully updated. harvests: created: Harvest was successfully created. + harvest_something: Harvest something index: title: crop_harvests: Everyone's %{crop} harvests @@ -248,6 +249,7 @@ en: late_finishing: late finishing sharedbuttonsfinish_planting: shared/buttons/finish_planting super_late: super late + plant_something: Plant something form: finish_helper: > A planting is finished when you've harvested all of the crop, or it dies, or it's otherwise @@ -269,6 +271,7 @@ en: progress: progress_0_not_planted_yet: 'Progress: 0% - not planted yet' posts: + write_blog_post: Write blog post index: title: author_posts: "%{author} posts" @@ -284,6 +287,7 @@ en: crop_seeds: Everyone's %{crop} seeds default: Everyone's seeds owner_seeds: "%{owner} seeds" + save_seeds: Save seeds string: "%{crop} seeds belonging to %{owner}" unauthorized: create: From e2a0278e40204d50e4e0bdab12db89ed25fca45b Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 22 Jan 2019 16:46:44 +1300 Subject: [PATCH 22/68] Use same t() for the button for writing blog posts --- app/views/shared/_global_actions.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/shared/_global_actions.html.haml b/app/views/shared/_global_actions.html.haml index 29b2f1ef3..771033c8a 100644 --- a/app/views/shared/_global_actions.html.haml +++ b/app/views/shared/_global_actions.html.haml @@ -13,7 +13,7 @@ = t('buttons.save_seeds') .btn-group - = link_to t('buttons.write_blog_post'), new_post_path, class: 'btn btn-default' + = link_to t('posts.write_blog_post'), new_post_path, class: 'btn btn-default' - content_for(:attributions) do seed by Template from the Noun Project \ No newline at end of file From dfd7765c474d3c478079bd104a1221c213bbfedc Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 22 Jan 2019 16:48:57 +1300 Subject: [PATCH 23/68] Rubocop fix ups --- app/helpers/buttons_helper.rb | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index 4dbf7015a..f6fe45346 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -4,7 +4,9 @@ module ButtonsHelper end def garden_mark_active(garden) - link_to t('buttons.mark_as_active'), garden_path(garden, garden: { active: 1 }), method: :put, class: 'btn btn-default btn-xs' + link_to t('buttons.mark_as_active'), + garden_path(garden, garden: { active: 1 }), + method: :put, class: 'btn btn-default btn-xs' end def garden_mark_inactive(garden) @@ -31,19 +33,19 @@ module ButtonsHelper end def planting_finish_button(planting) - if can?(:edit, planting) - button( - planting_path(planting, planting: { finished: 1 }), - 'buttons.mark_as_finished', - 'ok' - ) - end + return unless can?(:edit, planting) + + button( + planting_path(planting, planting: { finished: 1 }), + 'buttons.mark_as_finished', + 'ok' + ) end def planting_harvest_button(planting) - if planting.active? && can?(:create, Harvest) && can?(:edit, planting) - button(new_planting_harvest_path(planting), 'buttons.harvest', 'apple') - end + return unless planting.active? && can?(:create, Harvest) && can?(:edit, planting) + + button(new_planting_harvest_path(planting), 'buttons.harvest', 'apple') end def planting_save_seeds_button(planting) From 6ced6c5c4e29268834e34b5569bcc0d6b0134c09 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 22 Jan 2019 16:54:25 +1300 Subject: [PATCH 24/68] Update link label in spec --- spec/features/seeds/misc_seeds_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/features/seeds/misc_seeds_spec.rb b/spec/features/seeds/misc_seeds_spec.rb index e095ed390..941d25f00 100644 --- a/spec/features/seeds/misc_seeds_spec.rb +++ b/spec/features/seeds/misc_seeds_spec.rb @@ -21,10 +21,10 @@ feature "seeds", js: true do describe "button on front page to add seeds" do before do visit root_path - click_link "Add seeds" + click_link "Save seeds" end it { expect(current_path).to eq new_seed_path } - it { expect(page).to have_content 'Add seeds' } + it { expect(page).to have_content 'Save seeds' } end describe "Clicking link to owner's profile" do From 8df90dacfcf34ed325061960f9f2788c5ee9a9d9 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 22 Jan 2019 16:54:54 +1300 Subject: [PATCH 25/68] Seperate specs --- spec/features/gardens/actions_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/features/gardens/actions_spec.rb b/spec/features/gardens/actions_spec.rb index a22ab6886..0f4545714 100644 --- a/spec/features/gardens/actions_spec.rb +++ b/spec/features/gardens/actions_spec.rb @@ -46,9 +46,9 @@ feature "Gardens" do before { visit gardens_path(owner: FactoryBot.create(:member)) } include_examples "has buttons bar at top" - it 'does not show actions on other member garden' do - is_expected.not_to have_link 'Plant something' - is_expected.not_to have_link 'Mark as inactive' + describe 'does not show actions on other member garden' do + it { is_expected.not_to have_link 'Plant something' } + it { is_expected.not_to have_link 'Mark as inactive' } end end end From 02d4d12582fcbecea6fefc95b78859ba2c0a8abe Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 22 Jan 2019 16:58:13 +1300 Subject: [PATCH 26/68] suffix _button to button helpers --- app/helpers/buttons_helper.rb | 4 ++-- app/views/gardens/_actions.html.haml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index f6fe45346..b3ed95a25 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -3,13 +3,13 @@ module ButtonsHelper button(new_planting_path(garden_id: garden.id), 'buttons.plant_something_here', 'leaf') end - def garden_mark_active(garden) + def garden_mark_active_button(garden) link_to t('buttons.mark_as_active'), garden_path(garden, garden: { active: 1 }), method: :put, class: 'btn btn-default btn-xs' end - def garden_mark_inactive(garden) + def garden_mark_inactive_button(garden) link_to t('buttons.mark_as_inactive'), garden_path(garden, garden: { active: 0 }), method: :put, class: 'btn btn-default btn-xs', diff --git a/app/views/gardens/_actions.html.haml b/app/views/gardens/_actions.html.haml index 54842b577..656bc0b58 100644 --- a/app/views/gardens/_actions.html.haml +++ b/app/views/gardens/_actions.html.haml @@ -3,9 +3,9 @@ .btn-group - if garden.active = garden_plant_something_button(garden) - = garden_mark_inactive(garden) + = garden_mark_inactive_button(garden) - else - = garden_mark_active(garden) + = garden_mark_active_button(garden) = garden_edit_button(garden) From 8270611f0c1655a223a3b99f1ccd8f00602fb9ca Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 22 Jan 2019 17:03:34 +1300 Subject: [PATCH 27/68] Removed un-used viewss --- app/views/shared/buttons/_harvest_planting.haml | 4 ---- app/views/shared/buttons/_plant.html.haml | 3 --- app/views/shared/buttons/_save_seeds.haml | 4 ---- 3 files changed, 11 deletions(-) delete mode 100644 app/views/shared/buttons/_harvest_planting.haml delete mode 100644 app/views/shared/buttons/_plant.html.haml delete mode 100644 app/views/shared/buttons/_save_seeds.haml diff --git a/app/views/shared/buttons/_harvest_planting.haml b/app/views/shared/buttons/_harvest_planting.haml deleted file mode 100644 index 296ee30a0..000000000 --- a/app/views/shared/buttons/_harvest_planting.haml +++ /dev/null @@ -1,4 +0,0 @@ -- planting.active? && if can?(:create, Harvest) && can?(:edit, planting) - = link_to new_planting_harvest_path(planting), class: 'btn btn-default btn-xs' do - = render 'shared/glyphicon', icon: 'leaf', title: 'buttons.harvest' - = t('buttons.harvest') diff --git a/app/views/shared/buttons/_plant.html.haml b/app/views/shared/buttons/_plant.html.haml deleted file mode 100644 index 8044dddef..000000000 --- a/app/views/shared/buttons/_plant.html.haml +++ /dev/null @@ -1,3 +0,0 @@ -= link_to new_planting_path(garden_id: garden.id), class: 'btn btn-default' do - = render 'shared/glyphicon', icon: 'grain', title: 'buttons.plant' - = t('buttons.plant_something_here') \ No newline at end of file diff --git a/app/views/shared/buttons/_save_seeds.haml b/app/views/shared/buttons/_save_seeds.haml deleted file mode 100644 index d4cf794f5..000000000 --- a/app/views/shared/buttons/_save_seeds.haml +++ /dev/null @@ -1,4 +0,0 @@ -- if planting.active? - = link_to new_planting_seed_path(planting), class: 'btn btn-default btn-xs' do - = render 'shared/glyphicon', icon: 'heart', title: 'buttons.save_seeds' - = t('buttons.save_seeds') From c811ab1f5151a356d66fb24d7c9ca90dc5f37584 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 22 Jan 2019 17:11:22 +1300 Subject: [PATCH 28/68] Moved harvest buttons to match other #show pages --- app/views/harvests/show.html.haml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/views/harvests/show.html.haml b/app/views/harvests/show.html.haml index a584389fe..c2c773819 100644 --- a/app/views/harvests/show.html.haml +++ b/app/views/harvests/show.html.haml @@ -8,6 +8,9 @@ = tag("meta", property: "og:url", content: request.original_url) = tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME']) +-content_for(:buttonbar) do + = render 'harvests/actions', harvest: @harvest + .row .col-md-6 %p @@ -32,7 +35,6 @@ %b Quantity: = display_quantity(@harvest) - = render 'harvests/actions', harvest: @harvest .col-md-6 = render partial: "crops/index_card", locals: { crop: @harvest.crop } From 8ae062fe9beec641b4133f4606a8753ab18cab2b Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 22 Jan 2019 17:11:30 +1300 Subject: [PATCH 29/68] Added missing harvest actions --- app/helpers/buttons_helper.rb | 8 ++++++++ app/views/harvests/_actions.html.haml | 10 ++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index b3ed95a25..89b3c95e6 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -1,4 +1,12 @@ module ButtonsHelper + def harvest_add_photo_button(harvest) + button(new_photo_path(id: harvest.id, type: "harvest"), 'buttons.add_a_photo', 'camera') + end + + def harvest_edit_button(harvest) + button(edit_harvest_path(harvest), 'buttons.edit', 'pencil') + end + def garden_plant_something_button(garden) button(new_planting_path(garden_id: garden.id), 'buttons.plant_something_here', 'leaf') end diff --git a/app/views/harvests/_actions.html.haml b/app/views/harvests/_actions.html.haml index 2ebfbc8f9..a86cbdb18 100644 --- a/app/views/harvests/_actions.html.haml +++ b/app/views/harvests/_actions.html.haml @@ -1,7 +1,5 @@ .harvest-actions - - if can?(:edit, harvest) || can?(:destroy, harvest) - .btn-group - - if can? :edit, harvest - = render 'shared/buttons/edit', path: edit_harvest_path(harvest) - - if can? :destroy, harvest - .pull-right= render 'shared/buttons/delete', path: harvest_path(harvest) + .btn-group + = harvest_edit_button(harvest) if can? :edit, harvest + = harvest_add_photo_button(harvest) + = delete_button(harvest) if can? :destroy, harvest From b58e0cf3ce091e39657e241acb7aa7bd4130fb8d Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 22 Jan 2019 17:11:50 +1300 Subject: [PATCH 30/68] Moved garden actions code to top of view --- app/views/gardens/show.html.haml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/views/gardens/show.html.haml b/app/views/gardens/show.html.haml index b71f09c78..2c8ec76d6 100644 --- a/app/views/gardens/show.html.haml +++ b/app/views/gardens/show.html.haml @@ -14,12 +14,11 @@ = javascript_include_tag "charts" = javascript_include_tag "https://www.gstatic.com/charts/loader.js" +-content_for(:buttonbar) do + = render 'gardens/actions', garden: @garden + .row .col-md-9 - -content_for(:buttonbar) do - = render 'gardens/actions', garden: @garden - - - unless @garden.active .alert.alert-warning This garden is inactive. From ad001767e26e517814fe85b99a46128d5b0ddce9 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 22 Jan 2019 17:15:25 +1300 Subject: [PATCH 31/68] Move seed buttongs to buttons helper --- app/helpers/buttons_helper.rb | 8 ++++++++ app/views/seeds/_actions.html.haml | 7 +++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index 89b3c95e6..c1121a04f 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -1,4 +1,12 @@ module ButtonsHelper + def seed_add_photo_button(seed) + button(new_photo_path(id: seed.id, type: "seed"), 'buttons.add_a_photo', 'camera') + end + + def seed_edit_button(seed) + button(edit_seed_path(seed), 'buttons.edit', 'pencil') + end + def harvest_add_photo_button(harvest) button(new_photo_path(id: harvest.id, type: "harvest"), 'buttons.add_a_photo', 'camera') end diff --git a/app/views/seeds/_actions.html.haml b/app/views/seeds/_actions.html.haml index 6e1cef334..ea731c16b 100644 --- a/app/views/seeds/_actions.html.haml +++ b/app/views/seeds/_actions.html.haml @@ -1,8 +1,8 @@ .seed-actions - if can? :edit, seed .btn-group - = render 'shared/buttons/edit', path: edit_seed_path(seed) - = render 'shared/buttons/add_photo', path: new_photo_path(id: seed.id, type: 'seed') + = seed_edit_button(seed) + = seed_add_photo_button(seed) - if can?(:create, Planting) && seed.active? = link_to new_planting_path(seed_id: seed), class: 'btn btn-default btn-xs' do @@ -11,5 +11,4 @@ = render 'shared/buttons/finish_seeds', seed: seed - - if can? :destroy, seed - = render 'shared/buttons/delete', path: seed + = delete_button(seed) if can? :destroy, seed From 22e50aa61823cb2d68e12747e6aee37ac9ac98c3 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 22 Jan 2019 17:20:34 +1300 Subject: [PATCH 32/68] DRY the edit buttons --- app/helpers/buttons_helper.rb | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index c1121a04f..206322dab 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -2,18 +2,10 @@ module ButtonsHelper def seed_add_photo_button(seed) button(new_photo_path(id: seed.id, type: "seed"), 'buttons.add_a_photo', 'camera') end - - def seed_edit_button(seed) - button(edit_seed_path(seed), 'buttons.edit', 'pencil') - end def harvest_add_photo_button(harvest) button(new_photo_path(id: harvest.id, type: "harvest"), 'buttons.add_a_photo', 'camera') end - - def harvest_edit_button(harvest) - button(edit_harvest_path(harvest), 'buttons.edit', 'pencil') - end def garden_plant_something_button(garden) button(new_planting_path(garden_id: garden.id), 'buttons.plant_something_here', 'leaf') @@ -35,13 +27,21 @@ module ButtonsHelper def garden_add_photo_button(garden) button(new_photo_path(id: garden.id, type: "garden"), 'buttons.add_a_photo', 'camera') end + + def seed_edit_button(seed) + edit_button(edit_seed_path(seed)) + end + + def harvest_edit_button(harvest) + edit_button(edit_harvest_path(harvest)) + end def garden_edit_button(garden) - button(edit_garden_path(garden), 'buttons.edit', 'pencil') + edit_button(edit_garden_path(garden)) end def planting_edit_button(planting) - button(edit_planting_path(planting), 'buttons.edit', 'pencil') + edit_button(edit_planting_path(planting)) end def planting_add_photo_button(planting) @@ -68,6 +68,10 @@ module ButtonsHelper button(new_planting_seed_path(planting), 'buttons.save_seeds', 'heart') if can?(:edit, planting) end + def edit_button(path) + button(path, 'buttons.edit', 'pencil') + end + def delete_button(model, message: 'are_you_sure') link_to model, method: :delete, data: { confirm: t(message) }, class: 'btn btn-default btn-xs' do render 'shared/glyphicon', icon: 'trash', title: 'buttons.delete' From a8547d60337873d97187ae04a29cb262d66d5fb4 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 22 Jan 2019 17:20:52 +1300 Subject: [PATCH 33/68] Update labels on button in crop detail spec --- spec/features/crops/crop_detail_page_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/features/crops/crop_detail_page_spec.rb b/spec/features/crops/crop_detail_page_spec.rb index cbc73cf9c..523770bcb 100644 --- a/spec/features/crops/crop_detail_page_spec.rb +++ b/spec/features/crops/crop_detail_page_spec.rb @@ -105,13 +105,13 @@ feature "crop detail page", js: true do background { subject } scenario "has a link to plant the crop" do - expect(page).to have_link "Plant this", href: new_planting_path(crop_id: crop.id) + expect(page).to have_link "Plant #{crop.name}", href: new_planting_path(crop_id: crop.id) end scenario "has a link to harvest the crop" do - expect(page).to have_link "Harvest this", href: new_harvest_path(crop_id: crop.id) + expect(page).to have_link "Harvest #{crop.name}", href: new_harvest_path(crop_id: crop.id) end scenario "has a link to add seeds" do - expect(page).to have_link "Add seeds to stash", href: new_seed_path(crop_id: crop.id) + expect(page).to have_link "Add #{crop.name} seeds to stash", href: new_seed_path(crop_id: crop.id) end end From a95c3a988cf0469845d095b904ada23d2a798322 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 08:03:57 +1300 Subject: [PATCH 34/68] DRY the add photo buttons --- app/helpers/buttons_helper.rb | 33 +++++++++++++------------- app/views/gardens/_actions.html.haml | 4 +--- app/views/harvests/_actions.html.haml | 4 ++-- app/views/plantings/_actions.html.haml | 2 +- app/views/seeds/_actions.html.haml | 2 +- 5 files changed, 21 insertions(+), 24 deletions(-) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index 206322dab..994265adc 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -1,12 +1,4 @@ module ButtonsHelper - def seed_add_photo_button(seed) - button(new_photo_path(id: seed.id, type: "seed"), 'buttons.add_a_photo', 'camera') - end - - def harvest_add_photo_button(harvest) - button(new_photo_path(id: harvest.id, type: "harvest"), 'buttons.add_a_photo', 'camera') - end - def garden_plant_something_button(garden) button(new_planting_path(garden_id: garden.id), 'buttons.plant_something_here', 'leaf') end @@ -24,14 +16,10 @@ module ButtonsHelper data: { confirm: 'All plantings associated with this garden will be marked as finished. Are you sure?' } end - def garden_add_photo_button(garden) - button(new_photo_path(id: garden.id, type: "garden"), 'buttons.add_a_photo', 'camera') - end - def seed_edit_button(seed) edit_button(edit_seed_path(seed)) end - + def harvest_edit_button(harvest) edit_button(edit_harvest_path(harvest)) end @@ -44,10 +32,6 @@ module ButtonsHelper edit_button(edit_planting_path(planting)) end - def planting_add_photo_button(planting) - button(new_photo_path(id: planting.id, type: 'planting'), 'buttons.add_photo', 'camera') - end - def planting_finish_button(planting) return unless can?(:edit, planting) @@ -68,11 +52,22 @@ module ButtonsHelper button(new_planting_seed_path(planting), 'buttons.save_seeds', 'heart') if can?(:edit, planting) end + # Generic buttons (works out which model) + def add_photo_button(model) + return unless can?(:edit, model) && can?(:create, Photo) + + button( + new_photo_path(id: model.id, type: model_type_for_photo(model)), + 'buttons.add_a_photo', 'camera') + end + + def edit_button(path) button(path, 'buttons.edit', 'pencil') end def delete_button(model, message: 'are_you_sure') + return unless can? :destroy, model link_to model, method: :delete, data: { confirm: t(message) }, class: 'btn btn-default btn-xs' do render 'shared/glyphicon', icon: 'trash', title: 'buttons.delete' end @@ -80,6 +75,10 @@ module ButtonsHelper private + def model_type_for_photo(model) + ActiveModel::Name.new(model.class).to_s.downcase + end + def button(path, title, icon, size = 'btn-xs') link_to path, class: "btn btn-default #{size}" do render 'shared/glyphicon', icon: icon, title: title diff --git a/app/views/gardens/_actions.html.haml b/app/views/gardens/_actions.html.haml index 656bc0b58..67743037d 100644 --- a/app/views/gardens/_actions.html.haml +++ b/app/views/gardens/_actions.html.haml @@ -8,9 +8,7 @@ = garden_mark_active_button(garden) = garden_edit_button(garden) - - - if can?(:edit, garden) && can?(:create, Photo) - = garden_add_photo_button(garden) + = render 'shared/buttons/add_photo', model: garden - if can?(:destroy, garden) .pull-right diff --git a/app/views/harvests/_actions.html.haml b/app/views/harvests/_actions.html.haml index a86cbdb18..feabfbf96 100644 --- a/app/views/harvests/_actions.html.haml +++ b/app/views/harvests/_actions.html.haml @@ -1,5 +1,5 @@ .harvest-actions .btn-group = harvest_edit_button(harvest) if can? :edit, harvest - = harvest_add_photo_button(harvest) - = delete_button(harvest) if can? :destroy, harvest + = render 'shared/buttons/add_photo', model: harvest + = delete_button(harvest) diff --git a/app/views/plantings/_actions.html.haml b/app/views/plantings/_actions.html.haml index ca3fceefc..a8291089b 100644 --- a/app/views/plantings/_actions.html.haml +++ b/app/views/plantings/_actions.html.haml @@ -2,7 +2,7 @@ .planting-actions .btn-group = planting_edit_button(planting) - = planting_add_photo_button(planting) + = render 'shared/buttons/add_photo', model: planting - if planting.active? = planting_finish_button(planting) diff --git a/app/views/seeds/_actions.html.haml b/app/views/seeds/_actions.html.haml index ea731c16b..c801142a4 100644 --- a/app/views/seeds/_actions.html.haml +++ b/app/views/seeds/_actions.html.haml @@ -2,7 +2,7 @@ - if can? :edit, seed .btn-group = seed_edit_button(seed) - = seed_add_photo_button(seed) + = add_photo_button(seed) - if can?(:create, Planting) && seed.active? = link_to new_planting_path(seed_id: seed), class: 'btn btn-default btn-xs' do From a6ac57f045ce45209636e99adad64f158a83f7cb Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 08:04:06 +1300 Subject: [PATCH 35/68] Tests for edit and add photo buttons --- spec/helpers/buttons_helper_spec.rb | 33 +++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 spec/helpers/buttons_helper_spec.rb diff --git a/spec/helpers/buttons_helper_spec.rb b/spec/helpers/buttons_helper_spec.rb new file mode 100644 index 000000000..d3def8e00 --- /dev/null +++ b/spec/helpers/buttons_helper_spec.rb @@ -0,0 +1,33 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the ButtonsHelper. For example: +# +# describe ButtonsHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe ButtonsHelper, type: :helper do + before { allow(self).to receive(:can?) { true } } + let(:garden) { FactoryBot.create :garden } + let(:planting) { FactoryBot.create :planting } + let(:harvest) { FactoryBot.create :harvest } + let(:seed) { FactoryBot.create :seed } + + describe 'add_photo_button' do + it { expect(add_photo_button(garden)).to include "/photos/new?id=#{garden.id}&type=garden" } + it { expect(add_photo_button(planting)).to include "/photos/new?id=#{planting.id}&type=planting" } + it { expect(add_photo_button(harvest)).to include "/photos/new?id=#{harvest.id}&type=harvest" } + it { expect(add_photo_button(seed)).to include "/photos/new?id=#{seed.id}&type=seed" } + end + + describe 'edit_button' do + it { expect(garden_edit_button(garden)).to include "/gardens/#{garden.slug}/edit" } + it { expect(planting_edit_button(planting)).to include "/plantings/#{planting.slug}/edit" } + it { expect(harvest_edit_button(harvest)).to include "/harvests/#{harvest.slug}/edit" } + it { expect(seed_edit_button(seed)).to include "/seeds/#{seed.slug}/edit" } + end +end From 8eb948796795abed5e50a6f78736890c672c495f Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 14:03:36 +1300 Subject: [PATCH 36/68] Move home page greeting test to features spec (from views) --- spec/features/home/home_spec.rb | 5 +++++ spec/views/home/index_spec.rb | 4 ---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/spec/features/home/home_spec.rb b/spec/features/home/home_spec.rb index 3847d532b..d02bb619f 100644 --- a/spec/features/home/home_spec.rb +++ b/spec/features/home/home_spec.rb @@ -84,5 +84,10 @@ feature "home page" do include_examples 'show plantings' include_examples 'show harvests' include_examples 'shows seeds' + + describe 'should say welcome' do + before { visit root_path } + it { expect(page).to have_content "Welcome to #{ENV['GROWSTUFF_SITE_NAME']}, #{member.login_name}" } + end end end diff --git a/spec/views/home/index_spec.rb b/spec/views/home/index_spec.rb index 5e11882fd..4bc1e9c10 100644 --- a/spec/views/home/index_spec.rb +++ b/spec/views/home/index_spec.rb @@ -36,9 +36,5 @@ describe 'home/index.html.haml', type: "view" do controller.stub(:current_user) { @member } render end - - it 'should say welcome' do - rendered.should have_content "Welcome to #{ENV['GROWSTUFF_SITE_NAME']}, #{@member.login_name}" - end end end From 9130b44fb9a4fd132da5c2f2dd2a7668fc41dc86 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 14:04:48 +1300 Subject: [PATCH 37/68] Rubocop fixup --- app/helpers/buttons_helper.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index 994265adc..ea475fa05 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -58,16 +58,17 @@ module ButtonsHelper button( new_photo_path(id: model.id, type: model_type_for_photo(model)), - 'buttons.add_a_photo', 'camera') + 'buttons.add_a_photo', 'camera' + ) end - def edit_button(path) button(path, 'buttons.edit', 'pencil') end def delete_button(model, message: 'are_you_sure') return unless can? :destroy, model + link_to model, method: :delete, data: { confirm: t(message) }, class: 'btn btn-default btn-xs' do render 'shared/glyphicon', icon: 'trash', title: 'buttons.delete' end From 761a0b41422ac5205a4d7493babaf41b99d92aef Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 14:07:39 +1300 Subject: [PATCH 38/68] Always use the helper for add_photo buttons --- app/views/gardens/_actions.html.haml | 2 +- app/views/harvests/_actions.html.haml | 2 +- app/views/plantings/_actions.html.haml | 2 +- app/views/plantings/_badges.html.haml | 39 ++++++++++++------------ app/views/shared/buttons/_add_photo.haml | 4 --- 5 files changed, 23 insertions(+), 26 deletions(-) delete mode 100644 app/views/shared/buttons/_add_photo.haml diff --git a/app/views/gardens/_actions.html.haml b/app/views/gardens/_actions.html.haml index 67743037d..3834d4787 100644 --- a/app/views/gardens/_actions.html.haml +++ b/app/views/gardens/_actions.html.haml @@ -8,7 +8,7 @@ = garden_mark_active_button(garden) = garden_edit_button(garden) - = render 'shared/buttons/add_photo', model: garden + = add_photo_button(garden) - if can?(:destroy, garden) .pull-right diff --git a/app/views/harvests/_actions.html.haml b/app/views/harvests/_actions.html.haml index feabfbf96..28a9aee77 100644 --- a/app/views/harvests/_actions.html.haml +++ b/app/views/harvests/_actions.html.haml @@ -1,5 +1,5 @@ .harvest-actions .btn-group = harvest_edit_button(harvest) if can? :edit, harvest - = render 'shared/buttons/add_photo', model: harvest + = add_photo_button(harvest) = delete_button(harvest) diff --git a/app/views/plantings/_actions.html.haml b/app/views/plantings/_actions.html.haml index a8291089b..3de6ce339 100644 --- a/app/views/plantings/_actions.html.haml +++ b/app/views/plantings/_actions.html.haml @@ -2,7 +2,7 @@ .planting-actions .btn-group = planting_edit_button(planting) - = render 'shared/buttons/add_photo', model: planting + = add_photo_button(planting) - if planting.active? = planting_finish_button(planting) diff --git a/app/views/plantings/_badges.html.haml b/app/views/plantings/_badges.html.haml index 2d690b914..e7ac1f6d3 100644 --- a/app/views/plantings/_badges.html.haml +++ b/app/views/plantings/_badges.html.haml @@ -1,20 +1,21 @@ -// Finish times -- if planting.finish_is_predicatable? - - if planting.super_late? - %span.badge.badge-super-late= t('.super_late') - = render 'shared/buttons/finish_planting', planting: planting - - elsif planting.late? - %span.badge.badge-late= t('.late_finishing') - - else - %span.badge - = days_from_now_to_finished(planting) - = t('.days_until_finished') +- unless planting.finished? + // Finish times + - if planting.finish_is_predicatable? + - if planting.super_late? + %span.badge.badge-super-late= t('.super_late') + = render 'shared/buttons/finish_planting', planting: planting + - elsif planting.late? + %span.badge.badge-late= t('.late_finishing') + - else + %span.badge + = days_from_now_to_finished(planting) + = t('.days_until_finished') -// Harvest times -- unless planting.super_late? - - if planting.harvest_time? - %span.badge.badge-harvest= t('.harvesting_now') - - elsif planting.before_harvest_time? - %span.badge - = days_from_now_to_first_harvest(planting) - = t('.days_until_harvest') + // Harvest times + - unless planting.super_late? + - if planting.harvest_time? + %span.badge.badge-harvest= t('.harvesting_now') + - elsif planting.before_harvest_time? + %span.badge + = days_from_now_to_first_harvest(planting) + = t('.days_until_harvest') diff --git a/app/views/shared/buttons/_add_photo.haml b/app/views/shared/buttons/_add_photo.haml deleted file mode 100644 index 0e4a75c07..000000000 --- a/app/views/shared/buttons/_add_photo.haml +++ /dev/null @@ -1,4 +0,0 @@ -- if can?(:create, Photo) - = link_to path, class: 'btn btn-default btn-xs' do - = render 'shared/glyphicon', icon: 'camera', title: 'buttons.add_photo' - =t('buttons.add_photo') From e6e582cb4ae9c0f89c1fbbc4c7da6ff5fd21e166 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 14:33:48 +1300 Subject: [PATCH 39/68] Move some action button specs to feature specs because it's in a buttonbar, not the view now --- spec/features/gardens/actions_spec.rb | 5 +++++ spec/views/gardens/show.html.haml_spec.rb | 12 ------------ 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/spec/features/gardens/actions_spec.rb b/spec/features/gardens/actions_spec.rb index 0f4545714..18a339e09 100644 --- a/spec/features/gardens/actions_spec.rb +++ b/spec/features/gardens/actions_spec.rb @@ -54,6 +54,11 @@ feature "Gardens" do end describe '#show' do + before { visit garden_path(garden) } + it { is_expected.to have_link 'Edit' } + it { is_expected.to have_link 'Delete' } + it { is_expected.to have_content "Plant something here" } + it { is_expected.to have_content "Add photo" } end end diff --git a/spec/views/gardens/show.html.haml_spec.rb b/spec/views/gardens/show.html.haml_spec.rb index 5594c6755..0a3f813e8 100644 --- a/spec/views/gardens/show.html.haml_spec.rb +++ b/spec/views/gardens/show.html.haml_spec.rb @@ -42,18 +42,6 @@ describe "gardens/show" do render end - it 'should have an edit button' do - rendered.should have_link 'Edit' - end - - it "shows a 'plant something' button" do - rendered.should have_content "Plant something" - end - - it "shows an 'add photo' button" do - rendered.should have_content "Add photo" - end - it "links to the right crop in the planting link" do assert_select("a[href='#{new_planting_path}?garden_id=#{@garden.id}']") end From 8ec35cc65c411359d9e7b71779f11f7579da29eb Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 14:36:36 +1300 Subject: [PATCH 40/68] Action specs for someone else's garden --- spec/features/gardens/actions_spec.rb | 36 ++++++++++++++++----------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/spec/features/gardens/actions_spec.rb b/spec/features/gardens/actions_spec.rb index 18a339e09..8468cec18 100644 --- a/spec/features/gardens/actions_spec.rb +++ b/spec/features/gardens/actions_spec.rb @@ -9,6 +9,7 @@ feature "Gardens" do background { login_as member } let(:garden) { member.gardens.first } + let(:other_member_garden) { FactoryBot.create :garden } describe '#index' do shared_examples "has buttons bar at top" do @@ -26,13 +27,11 @@ feature "Gardens" do include_examples "has buttons bar at top" it "has actions on garden" do - within '.garden-actions' do - is_expected.to have_link 'Plant something' - is_expected.to have_link 'Mark as inactive' - is_expected.to have_link 'Edit' - is_expected.to have_link 'Add photo' - is_expected.to have_link 'Delete' - end + is_expected.to have_link 'Plant something here' + is_expected.to have_link 'Mark as inactive' + is_expected.to have_link 'Edit' + is_expected.to have_link 'Add photo' + is_expected.to have_link 'Delete' end end @@ -47,18 +46,27 @@ feature "Gardens" do include_examples "has buttons bar at top" describe 'does not show actions on other member garden' do - it { is_expected.not_to have_link 'Plant something' } - it { is_expected.not_to have_link 'Mark as inactive' } + it { is_expected.not_to have_link 'Edit' } + it { is_expected.not_to have_link 'Delete' } end end end describe '#show' do - before { visit garden_path(garden) } - it { is_expected.to have_link 'Edit' } - it { is_expected.to have_link 'Delete' } - it { is_expected.to have_content "Plant something here" } - it { is_expected.to have_content "Add photo" } + describe 'my garden' do + before { visit garden_path(garden) } + it { is_expected.to have_link 'Edit' } + it { is_expected.to have_link 'Delete' } + it { is_expected.to have_content "Plant something here" } + it { is_expected.to have_content "Add photo" } + end + describe "someone else's garden" do + before { visit garden_path(other_member_garden) } + it { is_expected.not_to have_link 'Edit' } + it { is_expected.not_to have_link 'Delete' } + it { is_expected.not_to have_content "Plant something here" } + it { is_expected.not_to have_content "Add photo" } + end end end From c78b96b9d6cbf42a961252dc3bd0a4936a11ce09 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 14:36:48 +1300 Subject: [PATCH 41/68] Update from should to expect syntax --- spec/views/gardens/show.html.haml_spec.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/spec/views/gardens/show.html.haml_spec.rb b/spec/views/gardens/show.html.haml_spec.rb index 0a3f813e8..5a33707b3 100644 --- a/spec/views/gardens/show.html.haml_spec.rb +++ b/spec/views/gardens/show.html.haml_spec.rb @@ -12,28 +12,28 @@ describe "gardens/show" do render end - it 'should show the location' do - rendered.should have_content @garden.location + it 'shows the location' do + expect(rendered).to have_content @garden.location end - it 'should show the area' do - rendered.should have_content pluralize(@garden.area, @garden.area_unit) + it 'shows the area' do + expect(rendered).to have_content pluralize(@garden.area, @garden.area_unit) end - it 'should show the description' do - rendered.should have_content "totally cool garden" + it 'shows the description' do + expect(rendered).to have_content "totally cool garden" end it 'renders markdown in the description' do assert_select "strong", "totally" end - it 'should show plantings on the garden page' do - rendered.should have_content @planting.crop.name + it 'shows plantings on the garden page' do + expect(rendered).to have_content @planting.crop.name end it "doesn't show the note about random plantings" do - rendered.should_not have_content "Note: these are a random selection" + expect(rendered).to have_content "Note: these are a random selection" end context 'signed in' do From 424866b733666bacce6b05955cc6e3b4d60ddb7f Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 14:37:00 +1300 Subject: [PATCH 42/68] Add "something" to global action labels --- app/views/shared/_global_actions.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/shared/_global_actions.html.haml b/app/views/shared/_global_actions.html.haml index 771033c8a..1fbfa2733 100644 --- a/app/views/shared/_global_actions.html.haml +++ b/app/views/shared/_global_actions.html.haml @@ -6,9 +6,9 @@ .btn-group = link_to new_planting_path, class: 'btn btn-default' do - = t('buttons.plant') + = t('plantings.plant_something') = link_to new_harvest_path, class: 'btn btn-default' do - = t('buttons.harvest') + = t('harvests.harvest_something') = link_to new_seed_path, class: 'btn btn-default' do = t('buttons.save_seeds') From 97675868bda1906192914a539a6d2dd815afd832 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 14:37:18 +1300 Subject: [PATCH 43/68] Fixed button link, using translation that exists --- app/helpers/buttons_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index ea475fa05..8697ffd4c 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -58,7 +58,7 @@ module ButtonsHelper button( new_photo_path(id: model.id, type: model_type_for_photo(model)), - 'buttons.add_a_photo', 'camera' + 'buttons.add_photo', 'camera' ) end From 655efb26eb4a661bcc4e4ac8e05be1d380cf07b4 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 14:52:17 +1300 Subject: [PATCH 44/68] Removing some unused translations --- config/locales/en.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index 850492e09..f5415f127 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -76,13 +76,11 @@ en: edit: Edit harvest: Harvest harvest_crop: Harvest %{crop_name} - harvest_something: Harvest something mark_as_active: Mark as active mark_as_finished: Mark as finished mark_as_inactive: Mark as inactive plant: Plant plant_crop: Plant %{crop_name} - plant_something: Plant something plant_something_here: Plant something here save_seeds: Save seeds write_blog_post: Write blog post From 6e433306f483964abe4c714d5101aaa8575203ba Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 14:52:40 +1300 Subject: [PATCH 45/68] Capitalise some translations --- config/locales/en.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index f5415f127..023d7b5a5 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -130,7 +130,7 @@ en: crops: our_crops: Some of our crops recently_added: Recently added crops - recently_planted: Recently planted + recently_planted: Recently Planted view_all: View all crops discuss: discussion: Discussion @@ -142,7 +142,7 @@ en: harvest: Harvest plant: Plant post: Post - recently_added: Recently added + recently_added: Recently Added welcome: Welcome to %{site_name}, %{member_name} members: title: Some of our members @@ -173,7 +173,7 @@ en: why_linktext: why Growstuff is open source wiki_linktext: Growstuff Wiki plantings: - recently_planted: Recently planted + recently_planted: Recently Planted seeds: crop: Crop description: Description From 8023d71a21e85b9d5b8232ab09db3e6b313d085c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 14:54:43 +1300 Subject: [PATCH 46/68] Removed outdated spec --- spec/views/gardens/show.html.haml_spec.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/spec/views/gardens/show.html.haml_spec.rb b/spec/views/gardens/show.html.haml_spec.rb index 5a33707b3..fd78ed08a 100644 --- a/spec/views/gardens/show.html.haml_spec.rb +++ b/spec/views/gardens/show.html.haml_spec.rb @@ -32,10 +32,6 @@ describe "gardens/show" do expect(rendered).to have_content @planting.crop.name end - it "doesn't show the note about random plantings" do - expect(rendered).to have_content "Note: these are a random selection" - end - context 'signed in' do before :each do sign_in @owner From c9be8be9e59b7d18e58af3e0c7df505e0130f9e4 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 15:01:34 +1300 Subject: [PATCH 47/68] Remove new planting button spec because it's in the button bar now --- spec/views/gardens/show.html.haml_spec.rb | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/spec/views/gardens/show.html.haml_spec.rb b/spec/views/gardens/show.html.haml_spec.rb index fd78ed08a..7451f26c8 100644 --- a/spec/views/gardens/show.html.haml_spec.rb +++ b/spec/views/gardens/show.html.haml_spec.rb @@ -31,15 +31,4 @@ describe "gardens/show" do it 'shows plantings on the garden page' do expect(rendered).to have_content @planting.crop.name end - - context 'signed in' do - before :each do - sign_in @owner - render - end - - it "links to the right crop in the planting link" do - assert_select("a[href='#{new_planting_path}?garden_id=#{@garden.id}']") - end - end end From ca75b1c8528e803cf398f82fea2e99b33cf232bc Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 15:06:56 +1300 Subject: [PATCH 48/68] Use button helper for crop wrangling --- app/helpers/buttons_helper.rb | 4 ++++ app/views/crops/_wrangle.html.haml | 11 ++--------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index 8697ffd4c..32df4d932 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -16,6 +16,10 @@ module ButtonsHelper data: { confirm: 'All plantings associated with this garden will be marked as finished. Are you sure?' } end + def crop_edit_button(crop) + edit_button(edit_crop_path(seed)) + end + def seed_edit_button(seed) edit_button(edit_seed_path(seed)) end diff --git a/app/views/crops/_wrangle.html.haml b/app/views/crops/_wrangle.html.haml index fafafd490..4260bbfe2 100644 --- a/app/views/crops/_wrangle.html.haml +++ b/app/views/crops/_wrangle.html.haml @@ -5,12 +5,5 @@ = succeed "." do %strong CROP WRANGLER - - if can? :edit, crop - %p - = link_to t(:edit_crop), edit_crop_path(crop), class: 'btn btn-default' - - if can? :destroy, crop - %p - = link_to 'Delete crop', crop, - method: :delete, - data: { confirm: t('are_you_sure') }, - class: 'btn btn-default' + %p= crop_edit_button(crop) if can? :edit, crop + %p= delete_button(crop) if can? :destroy, crop From 33ad13366511ccf66b3a0f73ab9cc00a64df26e2 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 15:49:13 +1300 Subject: [PATCH 49/68] Revert modifications to menu --- app/views/layouts/_header.html.haml | 100 ++++++++++++++-------------- 1 file changed, 49 insertions(+), 51 deletions(-) diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml index 990a23c76..ff4086c2e 100644 --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -20,63 +20,61 @@ = render 'crops/search_bar' .navbar-collapse.collapse#navbar-collapse - .navbar-right - %ul.nav.navbar-nav.navbar-right - %li.dropdown< - %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: crops_path } - = t('.crops') - %b.caret - %ul.dropdown-menu - %li= link_to t('.browse_crops'), crops_path - %li= link_to t('.seeds'), seeds_path - %li= link_to t('.plantings'), plantings_path - %li= link_to t('.harvests'), harvests_path - %li.dropdown< - %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: members_path } - = t('.community') - %b.caret - %ul.dropdown-menu - %li= link_to t('.community_map'), places_path - %li= link_to t('.browse_members'), members_path - %li= link_to t('.posts'), posts_path - %li= link_to t('.forums'), forums_path + %ul.nav.navbar-nav.navbar-right + %li.dropdown< + %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: crops_path } + = t('.crops') + %b.caret + %ul.dropdown-menu + %li= link_to t('.browse_crops'), crops_path + %li= link_to t('.seeds'), seeds_path + %li= link_to t('.plantings'), plantings_path + %li= link_to t('.harvests'), harvests_path + %li.dropdown< + %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: members_path } + = t('.community') + %b.caret + %ul.dropdown-menu + %li= link_to t('.community_map'), places_path + %li= link_to t('.browse_members'), members_path + %li= link_to t('.posts'), posts_path + %li= link_to t('.forums'), forums_path - - if member_signed_in? - %li.dropdown< - %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: root_path } + - if member_signed_in? + %li.dropdown< + %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: root_path } + - if current_member.notifications.unread_count.positive? + = t('.your_stuff', unread_count: current_member.notifications.unread_count) + - else + = t('.current_memberlogin_name', current_memberlogin_name: current_member.login_name) + %b.caret + %ul.dropdown-menu + %li= link_to t('.profile'), member_path(current_member) + %li= link_to t('.gardens'), gardens_by_owner_path(owner: current_member.slug) + %li= link_to t('.plantings'), plantings_by_owner_path(owner: current_member.slug) + %li= link_to t('.harvest'), harvests_by_owner_path(owner: current_member.slug) + %li= link_to t('.seeds'), seeds_by_owner_path(owner: current_member.slug) + %li= link_to t('.posts'), posts_by_author_path(author: current_member.slug) + %li - if current_member.notifications.unread_count.positive? - = t('.your_stuff', unread_count: current_member.notifications.unread_count) + = link_to(t('.inbox_unread', unread_count: current_member.notifications.unread_count), + notifications_path) - else - = t('.current_memberlogin_name', current_memberlogin_name: current_member.login_name) - %b.caret - %ul.dropdown-menu - %li= link_to t('.profile'), member_path(current_member) - %li= link_to t('.gardens'), gardens_by_owner_path(owner: current_member.slug) - %li= link_to t('.plantings'), plantings_by_owner_path(owner: current_member.slug) - %li= link_to t('.harvest'), harvests_by_owner_path(owner: current_member.slug) - %li= link_to t('.seeds'), seeds_by_owner_path(owner: current_member.slug) - %li= link_to t('.posts'), posts_by_author_path(author: current_member.slug) - %li - - if current_member.notifications.unread_count.positive? - = link_to(t('.inbox_unread', unread_count: current_member.notifications.unread_count), - notifications_path) - - else - = link_to(t('.inbox'), notifications_path) - - if current_member.role?(:crop_wrangler) || current_member.role?(:admin) - %li.divider{ role: 'presentation' } - - if current_member.role?(:crop_wrangler) - %li= link_to t('.crop_wrangling'), wrangle_crops_path - - if current_member.role?(:admin) - %li= link_to t('.admin'), admin_path + = link_to(t('.inbox'), notifications_path) + - if current_member.role?(:crop_wrangler) || current_member.role?(:admin) + %li.divider{ role: 'presentation' } + - if current_member.role?(:crop_wrangler) + %li= link_to t('.crop_wrangling'), wrangle_crops_path + - if current_member.role?(:admin) + %li= link_to t('.admin'), admin_path - %li= link_to t('.sign_out'), destroy_member_session_path, method: :delete + %li= link_to t('.sign_out'), destroy_member_session_path, method: :delete + + - else + %li= link_to t('.sign_in'), new_member_session_path, id: 'navbar-signin' + %li= link_to t('.sign_up'), new_member_registration_path, id: 'navbar-signup' - - else - %li= link_to t('.sign_in'), new_member_session_path, id: 'navbar-signin' - %li= link_to t('.sign_up'), new_member_registration_path, id: 'navbar-signup' - -# anchor tag for accessibility link to skip the navigation menu %a{ name: 'skipnav' } - From 99fb21eebe793e10e4c8a3107aaaf3dffec2d3dd Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 16:14:22 +1300 Subject: [PATCH 50/68] Find maze button in spec --- spec/features/plantings/planting_a_crop_spec.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spec/features/plantings/planting_a_crop_spec.rb b/spec/features/plantings/planting_a_crop_spec.rb index 1d8b7f745..de966b2fe 100644 --- a/spec/features/plantings/planting_a_crop_spec.rb +++ b/spec/features/plantings/planting_a_crop_spec.rb @@ -152,7 +152,9 @@ feature "Planting a crop", :js, :elasticsearch do scenario "Planting from crop page" do visit crop_path(maize) - click_link "Plant this" + within '.crop-actions' do + click_link "Plant maize" + end within "form#new_planting" do expect(page).to have_selector "input[value='maize']" click_button "Save" From 2a98cefedbd541d2dc511c8bb09af771edf57f80 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 16:15:09 +1300 Subject: [PATCH 51/68] Copy finish planting from view to helper --- app/helpers/buttons_helper.rb | 13 ++++++------- app/views/shared/buttons/_finish_planting.html.haml | 5 ----- 2 files changed, 6 insertions(+), 12 deletions(-) delete mode 100644 app/views/shared/buttons/_finish_planting.html.haml diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index 32df4d932..64ec66fae 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -17,7 +17,7 @@ module ButtonsHelper end def crop_edit_button(crop) - edit_button(edit_crop_path(seed)) + edit_button(edit_crop_path(crop)) end def seed_edit_button(seed) @@ -37,13 +37,12 @@ module ButtonsHelper end def planting_finish_button(planting) - return unless can?(:edit, planting) + return unless can?(:edit, planting) || planting.finished - button( - planting_path(planting, planting: { finished: 1 }), - 'buttons.mark_as_finished', - 'ok' - ) + link_to planting_path(planting, planting: { finished: 1 }), + method: :put, class: 'btn btn-default btn-xs append-date' do + render 'shared/glyphicon', icon: 'ok', title: 'buttons.mark_as_finished' + end end def planting_harvest_button(planting) diff --git a/app/views/shared/buttons/_finish_planting.html.haml b/app/views/shared/buttons/_finish_planting.html.haml deleted file mode 100644 index d0a931b41..000000000 --- a/app/views/shared/buttons/_finish_planting.html.haml +++ /dev/null @@ -1,5 +0,0 @@ -- if can?(:edit, planting) && !planting.finished - = link_to planting_path(planting, planting: { finished: 1 }), - method: :put, class: 'btn btn-default btn-xs append-date' do - = render 'shared/glyphicon', icon: 'ok', title: 'buttons.finished' - = t('buttons.mark_as_finished') From 81ee8ec56ec8958c302acdf21d73f7645b74dc34 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 16:19:08 +1300 Subject: [PATCH 52/68] Add crop name to actions --- app/views/crops/_index_card.html.haml | 4 ++-- spec/features/harvests/harvesting_a_crop_spec.rb | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/views/crops/_index_card.html.haml b/app/views/crops/_index_card.html.haml index 99b4a1a7e..1c94573cf 100644 --- a/app/views/crops/_index_card.html.haml +++ b/app/views/crops/_index_card.html.haml @@ -31,6 +31,6 @@ days after planting - if can? :create, Planting - = link_to 'Plant this', new_planting_path(params: { crop_id: crop.id }), class: 'btn btn-primary' + = link_to "Plant #{crop.name}", new_planting_path(params: { crop_id: crop.id }), class: 'btn btn-primary' - if can? :create, Seed - = link_to 'Add seeds to stash', new_seed_path(params: { crop_id: crop.id }), class: 'btn btn-primary' + = link_to "Add #{crop.name} seeds to stash", new_seed_path(params: { crop_id: crop.id }), class: 'btn btn-primary' diff --git a/spec/features/harvests/harvesting_a_crop_spec.rb b/spec/features/harvests/harvesting_a_crop_spec.rb index 5f6d85fa2..afb182120 100644 --- a/spec/features/harvests/harvesting_a_crop_spec.rb +++ b/spec/features/harvests/harvesting_a_crop_spec.rb @@ -64,7 +64,9 @@ feature "Harvesting a crop", :js, :elasticsearch do scenario "Harvesting from crop page" do visit crop_path(maize) - click_link "Harvest this" + within '.crop-actions' do + click_link "Harvest #{maize.name}" + end within "form#new_harvest" do select plant_part.name, from: 'harvest[plant_part_id]' expect(page).to have_selector "input[value='maize']" From 28422bfd1d081f6949774d2d71bf8668edf25c53 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 16:25:01 +1300 Subject: [PATCH 53/68] Seperate some specs --- spec/features/crops/crop_wranglers_spec.rb | 10 +++++----- .../features/plantings/planting_a_crop_spec.rb | 18 +++++++++--------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/spec/features/crops/crop_wranglers_spec.rb b/spec/features/crops/crop_wranglers_spec.rb index eafc7039f..86dc8a1c0 100644 --- a/spec/features/crops/crop_wranglers_spec.rb +++ b/spec/features/crops/crop_wranglers_spec.rb @@ -32,11 +32,11 @@ feature "crop wranglers", js: true do end end - scenario "visiting a crop can see wrangler links" do - visit crop_path(crops.first) - expect(page).to have_content 'You are a CROP WRANGLER' - expect(page).to have_link 'Edit crop' - expect(page).to have_link 'Delete crop' + describe "visiting a crop can see wrangler links" do + before { visit crop_path(crops.first) } + it { expect(page).to have_content 'You are a CROP WRANGLER' } + it { expect(page).to have_link 'Edit' } + it { expect(page).to have_link 'Delete' } end scenario "can create a new crop" do diff --git a/spec/features/plantings/planting_a_crop_spec.rb b/spec/features/plantings/planting_a_crop_spec.rb index de966b2fe..376c42569 100644 --- a/spec/features/plantings/planting_a_crop_spec.rb +++ b/spec/features/plantings/planting_a_crop_spec.rb @@ -21,15 +21,15 @@ feature "Planting a crop", :js, :elasticsearch do expect(page).to have_content "* denotes a required field" end - it "displays required and optional fields properly" do - expect(page).to have_selector ".form-group.required", text: "What did you plant?" - expect(page).to have_selector ".form-group.required", text: "Where did you plant it?" - expect(page).to have_optional 'input#planting_planted_at' - expect(page).to have_optional 'input#planting_quantity' - expect(page).to have_optional 'select#planting_planted_from' - expect(page).to have_optional 'select#planting_sunniness' - expect(page).to have_optional 'textarea#planting_description' - expect(page).to have_optional 'input#planting_finished_at' + describe "displays required and optional fields properly" do + it { expect(page).to have_selector ".form-group.required", text: "What did you plant?" } + it { expect(page).to have_selector ".form-group.required", text: "Where did you plant it?" } + it { expect(page).to have_optional 'input#planting_planted_at' } + it { expect(page).to have_optional 'input#planting_quantity' } + it { expect(page).to have_optional 'select#planting_planted_from' } + it { expect(page).to have_optional 'select#planting_sunniness' } + it { expect(page).to have_optional 'textarea#planting_description' } + it { expect(page).to have_optional 'input#planting_finished_at' } end scenario "Creating a new planting" do From 1460d4822a9d42678a902911ef70dd2456ff7767 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 16:31:44 +1300 Subject: [PATCH 54/68] Crop name is in button label - add to spec --- spec/features/seeds/adding_seeds_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/features/seeds/adding_seeds_spec.rb b/spec/features/seeds/adding_seeds_spec.rb index 67a8b7717..021a24336 100644 --- a/spec/features/seeds/adding_seeds_spec.rb +++ b/spec/features/seeds/adding_seeds_spec.rb @@ -59,7 +59,7 @@ feature "Seeds", :js, :elasticsearch do describe "Adding a seed from crop page" do before do visit crop_path(maize) - click_link "Add seeds to stash" + click_link "Add maize seeds to stash" within "form#new_seed" do expect(page).to have_selector "input[value='maize']" click_button "Save" From 2380d622581d6819e0d1086837bbf3e86cc8d606 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 16:35:12 +1300 Subject: [PATCH 55/68] Use new finish button on planting badges --- app/views/plantings/_badges.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/plantings/_badges.html.haml b/app/views/plantings/_badges.html.haml index e7ac1f6d3..acd244da4 100644 --- a/app/views/plantings/_badges.html.haml +++ b/app/views/plantings/_badges.html.haml @@ -3,7 +3,7 @@ - if planting.finish_is_predicatable? - if planting.super_late? %span.badge.badge-super-late= t('.super_late') - = render 'shared/buttons/finish_planting', planting: planting + = planting_finish_button(planting) - elsif planting.late? %span.badge.badge-late= t('.late_finishing') - else From a09c6603e23ee4495e72fe242b3d7b877a0ea81c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 16:49:06 +1300 Subject: [PATCH 56/68] Fixed photo specs to find the button on the actions view --- spec/features/photos/new_photo_spec.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/spec/features/photos/new_photo_spec.rb b/spec/features/photos/new_photo_spec.rb index 0bf696f06..3c486fa5b 100644 --- a/spec/features/photos/new_photo_spec.rb +++ b/spec/features/photos/new_photo_spec.rb @@ -13,7 +13,9 @@ feature "new photo page" do scenario "add photo" do visit planting_path(planting) - click_link('Add photo', match: :first) + within '.planting-actions' do + click_link('Add photo') + end expect(page).to have_text planting.crop.name end end @@ -23,7 +25,9 @@ feature "new photo page" do scenario "add photo" do visit harvest_path(harvest) - click_link "Add photo" + within '.harvest-actions' do + click_link "Add photo" + end expect(page).to have_text harvest.crop.name end end From 4e82584a0a1f769fafbba143e67ecbfe5726a308 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 16:54:07 +1300 Subject: [PATCH 57/68] Fixed label on link in spec --- spec/features/gardens_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/features/gardens_spec.rb b/spec/features/gardens_spec.rb index 368389719..0c58f8fdf 100644 --- a/spec/features/gardens_spec.rb +++ b/spec/features/gardens_spec.rb @@ -82,7 +82,7 @@ feature "Planting a crop", js: true do fill_in "Name", with: "New garden" click_button "Save" visit garden_path(Garden.last) - click_link 'delete_garden_link' + click_link 'Delete' expect(page).to have_content "Garden was successfully deleted" expect(page).to have_content "#{garden.owner}'s gardens" end From e912211ceea603640348ca8bfb3afbd326d7ebeb Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 17:34:32 +1300 Subject: [PATCH 58/68] DRY the icons --- app/helpers/icons_helper.rb | 17 +++++++++++++++++ app/views/crops/_actions.html.haml | 5 ++++- app/views/shared/_global_actions.html.haml | 15 +++++++++------ 3 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 app/helpers/icons_helper.rb diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb new file mode 100644 index 000000000..636884133 --- /dev/null +++ b/app/helpers/icons_helper.rb @@ -0,0 +1,17 @@ +module IconsHelper + def garden_icon + icon('far', 'square') + end + + def planting_icon + icon('fas', 'seedling') + end + + def harvest_icon + icon('fas', 'carrot') + end + + def seed_icon + icon('fas', 'heart') + end +end diff --git a/app/views/crops/_actions.html.haml b/app/views/crops/_actions.html.haml index 5cc80036b..92ae2b00f 100644 --- a/app/views/crops/_actions.html.haml +++ b/app/views/crops/_actions.html.haml @@ -2,12 +2,15 @@ .btn-group - if can? :create, Planting = link_to new_planting_path(crop_id: crop.id), class: 'btn btn-default' do + = planting_icon = t('buttons.plant_crop', crop_name: crop.name) - if can? :create, Harvest = link_to new_harvest_path(crop_id: crop.id), class: 'btn btn-default' do + = harvest_icon = t('buttons.harvest_crop', crop_name: crop.name) - + - if can? :create, Seed = link_to new_seed_path(crop_id: crop.id), class: 'btn btn-default' do + = seed_icon = t('buttons.add_seed_to_stash', crop_name: crop.name) diff --git a/app/views/shared/_global_actions.html.haml b/app/views/shared/_global_actions.html.haml index 1fbfa2733..638ce87d0 100644 --- a/app/views/shared/_global_actions.html.haml +++ b/app/views/shared/_global_actions.html.haml @@ -1,19 +1,22 @@ - if signed_in? - .global-actions + .global-actions.pull-right .btn-group = link_to gardens_by_owner_path(owner: current_member.slug), class: 'btn btn-default' do - = t('links.my_gardens') - + = garden_icon + = t('links.my_gardens') + .btn-group = link_to new_planting_path, class: 'btn btn-default' do + = planting_icon = t('plantings.plant_something') + = link_to new_harvest_path, class: 'btn btn-default' do + = harvest_icon = t('harvests.harvest_something') + = link_to new_seed_path, class: 'btn btn-default' do + = seed_icon = t('buttons.save_seeds') .btn-group = link_to t('posts.write_blog_post'), new_post_path, class: 'btn btn-default' - -- content_for(:attributions) do - seed by Template from the Noun Project \ No newline at end of file From 88a277c6ed2aeb7ac5200f00a289e816e513a4fd Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 21:49:11 +1300 Subject: [PATCH 59/68] Move consistent icons --- app/helpers/buttons_helper.rb | 35 +++++++++++++++++----------- app/helpers/icons_helper.rb | 16 +++++++++++++ app/views/gardens/_actions.html.haml | 5 ++-- 3 files changed, 40 insertions(+), 16 deletions(-) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index 64ec66fae..30c992946 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -1,6 +1,8 @@ module ButtonsHelper def garden_plant_something_button(garden) - button(new_planting_path(garden_id: garden.id), 'buttons.plant_something_here', 'leaf') + link_to new_planting_path(garden_id: garden.id), class: "btn btn-default btn-xs btn-primary" do + planting_icon + ' ' + t('buttons.plant_something_here') + end end def garden_mark_active_button(garden) @@ -41,39 +43,46 @@ module ButtonsHelper link_to planting_path(planting, planting: { finished: 1 }), method: :put, class: 'btn btn-default btn-xs append-date' do - render 'shared/glyphicon', icon: 'ok', title: 'buttons.mark_as_finished' + finished_icon + ' ' + t('buttons.mark_as_finished') end end def planting_harvest_button(planting) return unless planting.active? && can?(:create, Harvest) && can?(:edit, planting) - button(new_planting_harvest_path(planting), 'buttons.harvest', 'apple') + link_to new_planting_harvest_path(planting), class: "btn btn-default btn-xs" do + harvest_icon + ' ' + t('buttons.harvest') + end end def planting_save_seeds_button(planting) - button(new_planting_seed_path(planting), 'buttons.save_seeds', 'heart') if can?(:edit, planting) + return unless can?(:edit, planting) + + link_to new_planting_seed_path(planting), class: "btn btn-default btn-xs" do + seed_icon + ' ' + t('buttons.save_seeds') + end end - # Generic buttons (works out which model) def add_photo_button(model) return unless can?(:edit, model) && can?(:create, Photo) - button( - new_photo_path(id: model.id, type: model_type_for_photo(model)), - 'buttons.add_photo', 'camera' - ) + link_to new_photo_path(id: model.id, type: model_type_for_photo(model)), + class: "btn btn-default btn-xs" do + photo_icon + ' ' + t('buttons.add_photo') + end end def edit_button(path) - button(path, 'buttons.edit', 'pencil') + link_to path, class: "btn btn-default btn-xs" do + edit_icon + ' ' + t('buttons.edit') + end end def delete_button(model, message: 'are_you_sure') return unless can? :destroy, model link_to model, method: :delete, data: { confirm: t(message) }, class: 'btn btn-default btn-xs' do - render 'shared/glyphicon', icon: 'trash', title: 'buttons.delete' + delete_icon + ' ' + t('buttons.delete') end end @@ -83,9 +92,9 @@ module ButtonsHelper ActiveModel::Name.new(model.class).to_s.downcase end - def button(path, title, icon, size = 'btn-xs') + def button(path, button_title, icon, size = 'btn-xs') link_to path, class: "btn btn-default #{size}" do - render 'shared/glyphicon', icon: icon, title: title + icon + ' ' + button_title end end end diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb index 636884133..ab3a042b5 100644 --- a/app/helpers/icons_helper.rb +++ b/app/helpers/icons_helper.rb @@ -14,4 +14,20 @@ module IconsHelper def seed_icon icon('fas', 'heart') end + + def finished_icon + icon('fas', 'calendar') + end + + def edit_icon + icon('far', 'edit') + end + + def delete_icon + icon('fas', 'trash-alt') + end + + def photo_icon + icon('fas', 'camera-retro') + end end diff --git a/app/views/gardens/_actions.html.haml b/app/views/gardens/_actions.html.haml index 3834d4787..ea97a3931 100644 --- a/app/views/gardens/_actions.html.haml +++ b/app/views/gardens/_actions.html.haml @@ -1,8 +1,8 @@ .garden-actions - if can?(:edit, garden) + = garden_plant_something_button(garden) if garden.active .btn-group - if garden.active - = garden_plant_something_button(garden) = garden_mark_inactive_button(garden) - else = garden_mark_active_button(garden) @@ -11,5 +11,4 @@ = add_photo_button(garden) - if can?(:destroy, garden) - .pull-right - = delete_button(garden, message: 'All plantings associated with this garden will also be deleted. Are you sure?') + = delete_button(garden, message: 'All plantings associated with this garden will also be deleted. Are you sure?') From 94a5411a79733deada412934a2626bff170d4906 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 21:49:17 +1300 Subject: [PATCH 60/68] Wider action bar --- app/views/layouts/application.html.haml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 3ac9f7cf6..f7fc3f5de 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -8,7 +8,7 @@ #maincontainer = render partial: "shared/flash_messages", flash: flash .row - .col-md-8 + .col-md-6 - if content_for?(:title) %h1#title = yield(:title) @@ -19,8 +19,7 @@ .btn-group.layout-actions = yield(:buttonbar) - .col-md-4 - + .col-md-6 = render 'shared/global_actions' = yield From 5218685bd93269aa0ac953a9d2869d8f800b5109 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 21:57:21 +1300 Subject: [PATCH 61/68] Tidy up member edit buttons --- app/views/members/show.html.haml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/views/members/show.html.haml b/app/views/members/show.html.haml index 621f35c51..a786b8077 100644 --- a/app/views/members/show.html.haml +++ b/app/views/members/show.html.haml @@ -7,11 +7,17 @@ = tag("meta", property: "og:type", content: "profile") = tag("meta", property: "og:url", content: request.original_url) = tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME']) + + - content_for :buttonbar do - - if can? :update, @member - = link_to 'Edit profile', edit_member_registration_path, class: 'btn btn-default pull-right' - - if can?(:create, Notification) && current_member != @member - = link_to 'Send message', new_notification_path(recipient_id: @member.id), class: 'btn btn-default pull-right' + %p.btn-group + - if can? :update, @member + = link_to edit_member_registration_path, class: 'btn btn-default pull-right' do + = edit_icon + = t('members.edit_profile') + + - if can?(:create, Notification) && current_member != @member + = link_to 'Send message', new_notification_path(recipient_id: @member.id), class: 'btn btn-default' - if current_member && current_member != @member # must be logged in, can't follow yourself - follow = current_member.get_follow(@member) From 80e0d964e15a58f75cecd09b41f24869a8ce21bc Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 21:59:06 +1300 Subject: [PATCH 62/68] indentation clean up --- app/helpers/buttons_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index 30c992946..df4a48f6c 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -43,7 +43,7 @@ module ButtonsHelper link_to planting_path(planting, planting: { finished: 1 }), method: :put, class: 'btn btn-default btn-xs append-date' do - finished_icon + ' ' + t('buttons.mark_as_finished') + finished_icon + ' ' + t('buttons.mark_as_finished') end end From a54db7d5ffecd41e53a95a410fbdcd1953ee491a Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 22:30:44 +1300 Subject: [PATCH 63/68] Tidied up the planting actions on gardens#index --- app/assets/stylesheets/overrides.sass | 6 ++++-- app/views/plantings/_thumbnail.html.haml | 27 +++++++++++++++--------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/app/assets/stylesheets/overrides.sass b/app/assets/stylesheets/overrides.sass index b255536ea..1e9374184 100644 --- a/app/assets/stylesheets/overrides.sass +++ b/app/assets/stylesheets/overrides.sass @@ -132,11 +132,13 @@ p.stats padding: 0 border: 1px solid darken($beige, 10%) border-radius: 4px - .planting-actions - top: -8em .planting-name position: relative top: -1em + .planting-quick-actions + position: absolute + top: 0 + right: 2em dl.planting-attributes dt diff --git a/app/views/plantings/_thumbnail.html.haml b/app/views/plantings/_thumbnail.html.haml index a6b8349b8..bfe4892a8 100644 --- a/app/views/plantings/_thumbnail.html.haml +++ b/app/views/plantings/_thumbnail.html.haml @@ -1,13 +1,20 @@ .planting .planting-badges = render 'plantings/badges', planting: planting - .hover-wrapper - .thumbnail - .planting-thumbnail{ class: planting_classes(planting) } - = link_to image_tag(planting_image_path(planting), - alt: planting.crop.name, class: 'img'), planting_path(planting) - = render 'plantings/progress', planting: planting, show_explanation: false - .planting-name - = link_to planting.crop.name, planting - .text - .planting-actions= render 'plantings/actions', planting: planting + + .planting-quick-actions.pull-right + %a.btn.btn-default.btn-xs#actionsMenu.nav-link.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", href: "#"} + =icon('fas', 'bars') + .dropdown-menu{"aria-labelledby" => "actionsMenu"} + %p= render 'plantings/actions', planting: planting + + .thumbnail + + .planting-thumbnail{ class: planting_classes(planting) } + = link_to image_tag(planting_image_path(planting), + alt: planting.crop.name, class: 'img'), planting_path(planting) + = render 'plantings/progress', planting: planting, show_explanation: false + + .planting-name + = link_to planting.crop.name, planting + From 8bfe3278cc4fd9510e2a53e997e5bed871119b88 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 24 Jan 2019 09:17:13 +1300 Subject: [PATCH 64/68] Include icon helper from button helper --- app/helpers/buttons_helper.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index df4a48f6c..ad31f45c4 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -1,4 +1,5 @@ module ButtonsHelper + include IconHelper def garden_plant_something_button(garden) link_to new_planting_path(garden_id: garden.id), class: "btn btn-default btn-xs btn-primary" do planting_icon + ' ' + t('buttons.plant_something_here') From e202c73584549f236a7fe184ab3ad0b0e77d0dc9 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 24 Jan 2019 09:18:46 +1300 Subject: [PATCH 65/68] Update buttons_helper.rb --- app/helpers/buttons_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index ad31f45c4..7ae28247e 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -1,5 +1,5 @@ module ButtonsHelper - include IconHelper + include IconsHelper def garden_plant_something_button(garden) link_to new_planting_path(garden_id: garden.id), class: "btn btn-default btn-xs btn-primary" do planting_icon + ' ' + t('buttons.plant_something_here') From d73f8716c07018429d5df828c4fbb6f57c520cc8 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 24 Jan 2019 11:51:48 +1300 Subject: [PATCH 66/68] Include font awesome (so specs pass) --- app/helpers/icons_helper.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb index ab3a042b5..a42aaf5d8 100644 --- a/app/helpers/icons_helper.rb +++ b/app/helpers/icons_helper.rb @@ -1,4 +1,5 @@ module IconsHelper + include FontAwesome::Sass::Rails::ViewHelpers def garden_icon icon('far', 'square') end From 449e8da25a984593718fe6e362ea3dc20d376389 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 24 Jan 2019 11:54:55 +1300 Subject: [PATCH 67/68] Added missing translation for Edit profile button --- config/locales/en.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/config/locales/en.yml b/config/locales/en.yml index 023d7b5a5..12942554f 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -221,6 +221,7 @@ en: links: my_gardens: My gardens members: + edit_profile: Edit profile index: title: "%{site_name} members" signup: From f6deaffb94ec75aa80d7b1d0cb5f2b0a8d6cc370 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 24 Jan 2019 11:58:58 +1300 Subject: [PATCH 68/68] Fixed nested row on layout, that was breaking photo add page --- app/views/layouts/application.html.haml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index f7fc3f5de..d36f217b8 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -6,7 +6,8 @@ = render partial: "layouts/header" #maincontainer - = render partial: "shared/flash_messages", flash: flash + .row + .col-md-12= render partial: "shared/flash_messages", flash: flash .row .col-md-6 - if content_for?(:title) @@ -21,10 +22,13 @@ .col-md-6 = render 'shared/global_actions' - = yield + + .row + .col-md-12 + = yield %footer - = render partial: "layouts/footer" + = render "layouts/footer" / Javascripts \==================================================