Do not display the working plan exception option if no direct provider is selected

This commit is contained in:
Alex Tselegidis 2022-05-20 18:03:03 +02:00
parent bea53207d9
commit ffb19f113a
4 changed files with 29 additions and 18 deletions

View file

@ -50,6 +50,7 @@ define('DB_SLUG_PROVIDER', 'provider');
define('DB_SLUG_ADMIN', 'admin'); define('DB_SLUG_ADMIN', 'admin');
define('DB_SLUG_SECRETARY', 'secretary'); define('DB_SLUG_SECRETARY', 'secretary');
define('FILTER_TYPE_ALL', 'all');
define('FILTER_TYPE_PROVIDER', 'provider'); define('FILTER_TYPE_PROVIDER', 'provider');
define('FILTER_TYPE_SERVICE', 'service'); define('FILTER_TYPE_SERVICE', 'service');

View file

@ -629,7 +629,7 @@ class Calendar extends EA_Controller {
$filter_type = request('filter_type'); $filter_type = request('filter_type');
if ( ! $filter_type && $record_id !== 'all') if ( ! $filter_type && $record_id !== FILTER_TYPE_ALL)
{ {
json_response([ json_response([
'appointments' => [], 'appointments' => [],

View file

@ -26,7 +26,7 @@ App.Pages.Calendar = (function () {
$calendarPage.on('click', '#toggle-fullscreen', (event) => { $calendarPage.on('click', '#toggle-fullscreen', (event) => {
const $toggleFullscreen = $(event.target); const $toggleFullscreen = $(event.target);
const element = document.documentElement; const element = document.documentElement;
const isFullScreen = document.fullScreenElement || document.mozFullScreen || document.webkitIsFullScreen; const isFullScreen = document.fullScreenElement || document.mozFullScreen || document.webkitIsFullScreen || false;
if (isFullScreen) { if (isFullScreen) {
// Exit fullscreen mode. // Exit fullscreen mode.
@ -59,6 +59,10 @@ App.Pages.Calendar = (function () {
$insertWorkingPlanException.on('click', () => { $insertWorkingPlanException.on('click', () => {
const providerId = $('#select-filter-item').val(); const providerId = $('#select-filter-item').val();
if (providerId === App.Utils.CalendarDefaultView.FILTER_TYPE_ALL) {
return;
}
const provider = vars('available_providers').find((availableProvider) => { const provider = vars('available_providers').find((availableProvider) => {
return Number(availableProvider.id) === Number(providerId); return Number(availableProvider.id) === Number(providerId);
}); });
@ -105,8 +109,6 @@ App.Pages.Calendar = (function () {
* This function makes the necessary initialization for the default backend calendar page. * This function makes the necessary initialization for the default backend calendar page.
* *
* If this module is used in another page then this function might not be needed. * If this module is used in another page then this function might not be needed.
*
* @param {String} view Optional (default), the calendar view to be loaded.
*/ */
function initialize() { function initialize() {
// Load and initialize the calendar view. // Load and initialize the calendar view.

View file

@ -27,6 +27,7 @@ App.Utils.CalendarDefaultView = (function () {
const $footer = $('#footer'); const $footer = $('#footer');
const $notification = $('#notification'); const $notification = $('#notification');
const $calendarToolbar = $('#calendar-toolbar'); const $calendarToolbar = $('#calendar-toolbar');
const FILTER_TYPE_ALL = 'all';
const FILTER_TYPE_PROVIDER = 'provider'; const FILTER_TYPE_PROVIDER = 'provider';
const FILTER_TYPE_SERVICE = 'service'; const FILTER_TYPE_SERVICE = 'service';
let fullCalendar = null; let fullCalendar = null;
@ -311,6 +312,8 @@ App.Utils.CalendarDefaultView = (function () {
$('#enable-sync span').text(lang('enable_sync')); $('#enable-sync span').text(lang('enable_sync'));
$('#google-sync').prop('disabled', true); $('#google-sync').prop('disabled', true);
} }
$('#insert-working-plan-exception').toggle(providerId !== App.Utils.CalendarDefaultView.FILTER_TYPE_ALL);
} }
$reloadAppointments.trigger('click'); $reloadAppointments.trigger('click');
@ -465,8 +468,8 @@ App.Utils.CalendarDefaultView = (function () {
$('<span/>', { $('<span/>', {
'text': info.event.extendedProps.data 'text': info.event.extendedProps.data
? info.event.extendedProps.data.provider.first_name + ? info.event.extendedProps.data.provider.first_name +
' ' + ' ' +
info.event.extendedProps.data.provider.last_name info.event.extendedProps.data.provider.last_name
: '-' : '-'
}), }),
$('<br/>'), $('<br/>'),
@ -478,8 +481,8 @@ App.Utils.CalendarDefaultView = (function () {
$('<span/>', { $('<span/>', {
'text': App.Utils.Date.format( 'text': App.Utils.Date.format(
info.event.extendedProps.data.date + info.event.extendedProps.data.date +
' ' + ' ' +
info.event.extendedProps.data.workingPlanException.start, info.event.extendedProps.data.workingPlanException.start,
vars('date_format'), vars('date_format'),
vars('time_format'), vars('time_format'),
true true
@ -494,8 +497,8 @@ App.Utils.CalendarDefaultView = (function () {
$('<span/>', { $('<span/>', {
'text': App.Utils.Date.format( 'text': App.Utils.Date.format(
info.event.extendedProps.data.date + info.event.extendedProps.data.date +
' ' + ' ' +
info.event.extendedProps.data.workingPlanException.end, info.event.extendedProps.data.workingPlanException.end,
vars('date_format'), vars('date_format'),
vars('time_format'), vars('time_format'),
true true
@ -1336,9 +1339,9 @@ App.Utils.CalendarDefaultView = (function () {
start: calendarDate.clone().toDate(), start: calendarDate.clone().toDate(),
end: moment( end: moment(
calendarDate.format('YYYY-MM-DD') + calendarDate.format('YYYY-MM-DD') +
' ' + ' ' +
sortedWorkingPlan[weekdayName].start + sortedWorkingPlan[weekdayName].start +
':00' ':00'
).toDate(), ).toDate(),
allDay: false, allDay: false,
color: '#BEBEBE', color: '#BEBEBE',
@ -1360,9 +1363,9 @@ App.Utils.CalendarDefaultView = (function () {
title: lang('not_working'), title: lang('not_working'),
start: moment( start: moment(
calendarDate.format('YYYY-MM-DD') + calendarDate.format('YYYY-MM-DD') +
' ' + ' ' +
sortedWorkingPlan[weekdayName].end + sortedWorkingPlan[weekdayName].end +
':00' ':00'
).toDate(), ).toDate(),
end: calendarDate.clone().add(1, 'day').toDate(), end: calendarDate.clone().add(1, 'day').toDate(),
allDay: false, allDay: false,
@ -1594,7 +1597,9 @@ App.Utils.CalendarDefaultView = (function () {
// Trigger once to set the proper footer position after calendar initialization. // Trigger once to set the proper footer position after calendar initialization.
onWindowResize(); onWindowResize();
$selectFilterItem.append(new Option(lang('all'), 'all', true, true)); $selectFilterItem.append(new Option(lang('all'), FILTER_TYPE_ALL, true, true));
$('#insert-working-plan-exception').hide();
// Fill the select list boxes of the page. // Fill the select list boxes of the page.
if (vars('available_providers').length > 0) { if (vars('available_providers').length > 0) {
@ -1709,6 +1714,9 @@ App.Utils.CalendarDefaultView = (function () {
} }
return { return {
initialize initialize,
FILTER_TYPE_ALL,
FILTER_TYPE_PROVIDER,
FILTER_TYPE_SERVICE
}; };
})(); })();