From d14d6fe865b28b719df6d4efd50573bb1058ef45 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Mon, 13 Jan 2020 17:11:27 +0100 Subject: [PATCH] Refactor open order cycle checks --- app/helpers/shop_helper.rb | 7 +++++-- app/views/shopping_shared/_order_cycles.html.haml | 2 +- app/views/shopping_shared/tabs/_shop.html.haml | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/helpers/shop_helper.rb b/app/helpers/shop_helper.rb index 2a855dbd9f..f2d397b654 100644 --- a/app/helpers/shop_helper.rb +++ b/app/helpers/shop_helper.rb @@ -36,7 +36,10 @@ module ShopHelper end def shopfront_closed_message? - @order_cycles && @order_cycles.empty? && - current_distributor.preferred_shopfront_closed_message.present? + no_open_order_cycles? && current_distributor.preferred_shopfront_closed_message.present? + end + + def no_open_order_cycles? + @order_cycles && @order_cycles.empty? end end diff --git a/app/views/shopping_shared/_order_cycles.html.haml b/app/views/shopping_shared/_order_cycles.html.haml index df7bcddd0c..6fab77ffe9 100644 --- a/app/views/shopping_shared/_order_cycles.html.haml +++ b/app/views/shopping_shared/_order_cycles.html.haml @@ -3,6 +3,6 @@ %ordercycle{"ng-controller" => "OrderCycleCtrl"} - - unless @order_cycles and @order_cycles.empty? + - unless no_open_order_cycles? %form.custom = yield :order_cycle_form diff --git a/app/views/shopping_shared/tabs/_shop.html.haml b/app/views/shopping_shared/tabs/_shop.html.haml index 4b4c1c1fa4..7352cd0a3b 100644 --- a/app/views/shopping_shared/tabs/_shop.html.haml +++ b/app/views/shopping_shared/tabs/_shop.html.haml @@ -1,7 +1,7 @@ %script{ type: "text/ng-template", id: "shop/shop.html" } .row .small-12.columns - - if @order_cycles and @order_cycles.empty? + - if no_open_order_cycles? .content %h4 %i.ofn-i_012-warning