From 930fb06a7b1ccc65f7a36ee78d542f54e000ef0b Mon Sep 17 00:00:00 2001 From: Remco van Vugt Date: Sat, 10 Nov 2018 01:43:59 +0100 Subject: [PATCH] UI-3140: Lunch hours time of day object will only be valid on days the business is open (#78) --- submodules/strategy/strategy.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/submodules/strategy/strategy.js b/submodules/strategy/strategy.js index 1c29c11..96c0e7a 100644 --- a/submodules/strategy/strategy.js +++ b/submodules/strategy/strategy.js @@ -1639,6 +1639,18 @@ define(function(require) { if (customHours.lunchbreak.enabled) { var lunchbreakRule = strategyData.temporalRules.lunchbreak; + + // make sure the lunch rule is only valid on days the business is open + delete lunchbreakRule.wdays; + var lunchwdays = []; + _.each(customHours.opendays, function(val) { + lunchwdays.push(val.substring(4).toLowerCase()); + }); + + lunchbreakRule = $.extend(true, { + wdays: lunchwdays + }, lunchbreakRule); + lunchbreakRule.time_window_start = monster.util.timeToSeconds(customHours.lunchbreak.from); lunchbreakRule.time_window_stop = monster.util.timeToSeconds(customHours.lunchbreak.to); tmpRulesRequests.lunchbreak = function(callback) {