Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop 1 #2

Merged
merged 3 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
27 changes: 27 additions & 0 deletions assets/js/pages/blocked_periods.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ App.Pages.BlockedPeriods = (function () {

let filterResults = {};
let filterLimit = 20;
let backupStartDateTimeObject = undefined;

/**
* Add the page event listeners.
Expand Down Expand Up @@ -80,6 +81,9 @@ App.Pages.BlockedPeriods = (function () {
$blockedPeriods.find('.record-details .form-label span').prop('hidden', false);
$filterBlockedPeriods.find('button').prop('disabled', true);
$filterBlockedPeriods.find('.results').css('color', '#AAA');

App.Utils.UI.setDateTimePickerValue($startDateTime, moment('00:00', 'HH:mm').toDate());
App.Utils.UI.setDateTimePickerValue($endDateTime, moment('00:00', 'HH:mm').add(1, 'day').toDate());
});

/**
Expand Down Expand Up @@ -156,6 +160,27 @@ App.Pages.BlockedPeriods = (function () {
select(id, true);
}
});

$blockedPeriods.on('focus', '#start-date-time', () => {
backupStartDateTimeObject = App.Utils.UI.getDateTimePickerValue($startDateTime);
});

/**
* Event: Start Date Time Input "Change"
*/
$blockedPeriods.on('change', '#start-date-time', (event) => {
const endDateTimeObject = App.Utils.UI.getDateTimePickerValue($endDateTime);

if (!backupStartDateTimeObject || !endDateTimeObject) {
return;
}

const endDateTimeMoment = moment(endDateTimeObject);
const backupStartDateTimeMoment = moment(backupStartDateTimeObject);
const diff = endDateTimeMoment.diff(backupStartDateTimeMoment);
const newEndDateTimeMoment = endDateTimeMoment.clone().add(diff, 'milliseconds');
App.Utils.UI.setDateTimePickerValue($endDateTime, newEndDateTimeMoment.toDate());
});
}

/**
Expand Down Expand Up @@ -295,6 +320,8 @@ App.Pages.BlockedPeriods = (function () {

$blockedPeriods.find('.record-details .is-invalid').removeClass('is-invalid');
$blockedPeriods.find('.record-details .form-message').hide();

backupStartDateTimeObject = undefined;
}

/**
Expand Down