mirror of
https://github.com/alextselegidis/easyappointments.git
synced 2024-11-09 17:42:21 +03:00
Update working_plan_exceptions_modal.js
On working plan exception use company_working_plan hours for that vweekday as baseline instead of hardcoded hours. If the given weekday does not have a working plan, then hardcoded values will be used
This commit is contained in:
parent
7c0b7127cc
commit
961b9b4f7c
1 changed files with 32 additions and 5 deletions
|
@ -216,8 +216,23 @@ 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());
|
||||
const dateTimeObject = App.Utils.UI.getDateTimePickerValue($date);
|
||||
const plannedHours = getWeekdaysPlannedHours(App.Utils.Date.getWeekdayName(moment(dateTimeObject).day()));
|
||||
App.Utils.UI.setDateTimePickerValue($start, moment(plannedHours['start'], 'HH:mm').toDate());
|
||||
App.Utils.UI.setDateTimePickerValue($end, moment(plannedHours['end'], 'HH:mm').toDate());
|
||||
}
|
||||
|
||||
function getWeekdaysPlannedHours(weekDay) {
|
||||
hours = {};
|
||||
const company_working_plan = JSON.parse(vars('company_working_plan'));
|
||||
if (company_working_plan[weekDay]) {
|
||||
hours["start"] = company_working_plan[weekDay]['start'];
|
||||
hours["end"] = company_working_plan[weekDay]['end'];
|
||||
} else {
|
||||
hours["start"] = '08:00';
|
||||
hours["end"] = '16:00';
|
||||
}
|
||||
return hours;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -272,8 +287,9 @@ App.Components.WorkingPlanExceptionsModal = (function () {
|
|||
$breaks.find('tbody .working-plan-exceptions-break-start, tbody .working-plan-exceptions-break-end'),
|
||||
);
|
||||
} else {
|
||||
App.Utils.UI.setDateTimePickerValue($start, moment('08:00', 'HH:mm').toDate());
|
||||
App.Utils.UI.setDateTimePickerValue($end, moment('20:00', 'HH:mm').toDate());
|
||||
const plannedHours = getWeekdaysPlannedHours(App.Utils.Date.getWeekdayName(moment(date).day()));
|
||||
App.Utils.UI.setDateTimePickerValue($start, moment(plannedHours['start'], 'HH:mm').toDate());
|
||||
App.Utils.UI.setDateTimePickerValue($end, moment(plannedHours['end'], 'HH:mm').toDate());
|
||||
$breaks.find('tbody').html(renderNoBreaksRow());
|
||||
}
|
||||
|
||||
|
@ -454,6 +470,16 @@ App.Components.WorkingPlanExceptionsModal = (function () {
|
|||
$addBreak.prop('disabled', false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Event: Edit Date "Change"
|
||||
*/
|
||||
function onEditDateChange() {
|
||||
const dateTimeObject = App.Utils.UI.getDateTimePickerValue($date);
|
||||
const plannedHours = getWeekdaysPlannedHours(App.Utils.Date.getWeekdayName(moment(dateTimeObject).day()));
|
||||
App.Utils.UI.setDateTimePickerValue($start, moment(plannedHours['start'], 'HH:mm').toDate());
|
||||
App.Utils.UI.setDateTimePickerValue($end, moment(plannedHours['end'], 'HH:mm').toDate());
|
||||
}
|
||||
|
||||
/**
|
||||
* Event: Is Non-Working Day "Change"
|
||||
*/
|
||||
|
@ -477,7 +503,8 @@ App.Components.WorkingPlanExceptionsModal = (function () {
|
|||
.on('click', '.working-plan-exceptions-edit-break', onEditBreakClick)
|
||||
.on('click', '.working-plan-exceptions-delete-break', onDeleteBreakClick)
|
||||
.on('click', '.working-plan-exceptions-save-break', onSaveBreakClick)
|
||||
.on('click', '.working-plan-exceptions-cancel-break', onCancelBreakClick);
|
||||
.on('click', '.working-plan-exceptions-cancel-break', onCancelBreakClick)
|
||||
.on('change', '#working-plan-exceptions-date', onEditDateChange);
|
||||
|
||||
$save.on('click', onSaveClick);
|
||||
|
||||
|
|
Loading…
Reference in a new issue