From 4e2368c5447b73b7ecb1f70027c90a7398e2a52a Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Sun, 24 Jul 2016 11:23:56 +0200 Subject: [PATCH] Do not display the hour if its the same as the row one (calendar table view). --- src/assets/js/backend_calendar_table_view.js | 28 ++++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/assets/js/backend_calendar_table_view.js b/src/assets/js/backend_calendar_table_view.js index 159c6973..a8a21ae3 100644 --- a/src/assets/js/backend_calendar_table_view.js +++ b/src/assets/js/backend_calendar_table_view.js @@ -601,8 +601,8 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {}; var eventDuration = Math.round((endDate - startDate) / 60000); $event.html( - (appointment.customer.first_name + ' ' + appointment.customer.last_name).trim() + - ' ' + startDate.toString('HH:mm') + ' (' + eventDuration + '\')' + appointment.customer.last_name + + ' ' + startDate.toString('HH:mm') + ' (' + eventDuration + '\')' ); $event.data(appointment); @@ -622,6 +622,11 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {}; $event.appendTo($(tr).prev().find('td').eq(cellIndex)); + // Remove the hour from the event if it is the same as the row. + if (eventDate.toString('HH:mm') === $(tr).prev().find('td').eq(0).text()) { + $event.find('.hour').remove(); + } + return false; } }); @@ -656,8 +661,8 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {}; var eventDuration = Math.round((endDate - eventDate) / 60000); var $event = $('
'); - $event.html((unavailability.notes || EALang['unavailable']) + ' ' + eventDate.toString('HH:mm') - + ' (' + eventDuration + '\')'); + $event.html((unavailability.notes || EALang['unavailable']) + + ' ' + eventDate.toString('HH:mm') + ' (' + eventDuration + '\')'); $event.data(unavailability); @@ -671,6 +676,12 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {}; if (eventDate < cellDate) { $event.appendTo($(tr).prev().find('td').eq(1)); + + // Remove the hour from the event if it is the same as the row. + if (eventDate.toString('HH:mm') === $(tr).prev().find('td').eq(0).text()) { + $event.find('.hour').remove(); + } + return false; } }); @@ -700,7 +711,9 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {}; var eventDuration = Math.round((endDate - eventDate) / 60000); var $event = $('
'); - $event.html(EALang['break'] + ' ' + eventDate.toString('HH:mm') + ' (' + eventDuration + '\')'); + $event.html( + EALang['break'] + + ' ' + eventDate.toString('HH:mm') + ' (' + eventDuration + '\')'); $event.data(entry); @@ -713,6 +726,11 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {}; }); if (eventDate < cellDate) { + // Remove the hour from the event if it is the same as the row. + if (eventDate.toString('HH:mm') === $(tr).prev().find('td').eq(0).text()) { + $event.find('.hour').remove(); + } + $(tr).prev().find('td:gt(0)').each(function(index, td) { $event.clone().appendTo($(td)); });