From 9bd1df85b47e833b1bb03c805b25fb05635ba700 Mon Sep 17 00:00:00 2001 From: itshuey Date: Sun, 8 Sep 2019 17:40:28 -0700 Subject: [PATCH 1/2] Fixing menu deselection issue --- app/views/menu/index.html.erb | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/app/views/menu/index.html.erb b/app/views/menu/index.html.erb index c8bcca66..2a42f56c 100644 --- a/app/views/menu/index.html.erb +++ b/app/views/menu/index.html.erb @@ -66,7 +66,7 @@ let selectedDay = selectedDayElement.text().trim().toLowerCase(); $('#menu-day-field').val(selectedDay); - // Set the dining hall to fetch menu for + // Set the type of meal to fetch menu for let selectedMealType = selectedMealTypeElement.text().trim().toLowerCase(); $('#meal-type-field').val(selectedMealType); @@ -101,6 +101,22 @@ $(this).removeClass('is-active'); }); $(this).parent().toggleClass('is-active'); + day = $(this).parent().text().trim().toLowerCase(); + + // Fix the meal type if necessary + $('.meal-type-button').parent().each(function() { + if ($(this).attr('class') == 'is-active') { + isWeekend = day == 'saturday' || day == 'sunday'; + isBreakfastOrLunch = $(this).attr('id') == 'breakfast-button' || $(this).attr('id') == 'lunch-button'; + if (isWeekend && isBreakfastOrLunch) { + $(this).removeClass('is-active'); + $('#brunch-button').toggleClass('is-active'); + } else if (!isWeekend && $(this).attr('id') == 'brunch-button') { + $(this).removeClass('is-active'); + $('#breakfast-button').toggleClass('is-active'); + } + }; + }); // Submit the form submitMenuForm(); From 55ec9ab9f25ecbcadce3f482a297d50230e30837 Mon Sep 17 00:00:00 2001 From: itshuey Date: Sun, 8 Sep 2019 17:48:32 -0700 Subject: [PATCH 2/2] Fixing syntax --- app/views/menu/index.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/menu/index.html.erb b/app/views/menu/index.html.erb index 2a42f56c..27ea760e 100644 --- a/app/views/menu/index.html.erb +++ b/app/views/menu/index.html.erb @@ -115,7 +115,7 @@ $(this).removeClass('is-active'); $('#breakfast-button').toggleClass('is-active'); } - }; + } }); // Submit the form