From 2a98cefedbd541d2dc511c8bb09af771edf57f80 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 16:15:09 +1300 Subject: [PATCH] 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')