Skip to content

Commit

Permalink
Reset the time selection when the user changes the non-working switch
Browse files Browse the repository at this point in the history
  • Loading branch information
alextselegidis committed Apr 15, 2024
1 parent 8bdb762 commit b880356
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions assets/js/components/working_plan_exceptions_modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,11 @@ App.Components.WorkingPlanExceptionsModal = (function () {
);
}

function resetTimeSelection() {
App.Utils.UI.setDateTimePickerValue($start, moment('08:00', 'HH:mm').toDate());
App.Utils.UI.setDateTimePickerValue($end, moment('20:00', 'HH:mm').toDate());
}

/**
* Open the modal and start adding a new working plan exception.
*
Expand All @@ -224,8 +229,8 @@ App.Components.WorkingPlanExceptionsModal = (function () {
deferred = $.Deferred();

App.Utils.UI.setDateTimePickerValue($date, new Date());
App.Utils.UI.setDateTimePickerValue($start, moment('08:00', 'HH:mm').toDate());
App.Utils.UI.setDateTimePickerValue($end, moment('20:00', 'HH:mm').toDate());

resetTimeSelection();

$isNonWorkingDay.prop('checked', false);

Expand Down Expand Up @@ -450,11 +455,11 @@ App.Components.WorkingPlanExceptionsModal = (function () {
}

/**
* Event: Is Non Working Day "Change"
* Event: Is Non-Working Day "Change"
*/
function onIsNonWorkingDayChange() {
const isNonWorkingDay = $isNonWorkingDay.prop('checked');

resetTimeSelection();
toggleFieldsByNonWorkingDay(isNonWorkingDay);
}

Expand Down

0 comments on commit b880356

Please sign in to comment.