From 91f8d0cccfc323ab7352136c6dea7f0b7ad8780a Mon Sep 17 00:00:00 2001 From: Joris Tirado Date: Fri, 9 Nov 2018 17:11:07 -0800 Subject: [PATCH] UI-3140: Clean up lunch hours assignment logic (#99) --- submodules/strategy/strategy.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/submodules/strategy/strategy.js b/submodules/strategy/strategy.js index 96c0e7a..418bbb8 100644 --- a/submodules/strategy/strategy.js +++ b/submodules/strategy/strategy.js @@ -1640,19 +1640,19 @@ 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()); + _.assign(lunchbreakRule, { + wdays: _.map(customHours.opendays, function(item) { + // make sure the lunch rule is only valid on days the business is open + return _ + .chain(item) + .lowerCase() + .replace(/^main/, '') + .value(); + }), + time_window_start: monster.util.timeToSeconds(customHours.lunchbreak.from), + time_window_end: monster.util.timeToSeconds(customHours.lunchbreak.to) }); - - 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) { self.callApi({ resource: 'temporalRule.update',