From b2015052d8f24e4a90a33cdb15531e1fc6a876d4 Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Sun, 16 Oct 2022 21:58:50 +0300 Subject: [PATCH] Do not add a dash in the event title if there are no customer first and last name provided --- assets/js/utils/calendar_default_view.js | 25 ++++++++++++++++++------ assets/js/utils/calendar_table_view.js | 25 ++++++++++++++++++------ 2 files changed, 38 insertions(+), 12 deletions(-) diff --git a/assets/js/utils/calendar_default_view.js b/assets/js/utils/calendar_default_view.js index 5b816442..9c149431 100755 --- a/assets/js/utils/calendar_default_view.js +++ b/assets/js/utils/calendar_default_view.js @@ -1098,14 +1098,27 @@ App.Utils.CalendarDefaultView = (function () { // Add appointments to calendar. response.appointments.forEach((appointment) => { + const title = [ + appointment.service.name + ]; + + const customerInfo = []; + + if (appointment.customer.first_name) { + customerInfo.push(appointment.customer.first_name); + } + + if (appointment.customer.last_name) { + customerInfo.push(appointment.customer.last_name); + } + + if (customerInfo.length) { + title.push(customerInfo.join(' ')); + } + const appointmentEvent = { id: appointment.id, - title: - appointment.service.name + - ' - ' + - appointment.customer.first_name + - ' ' + - appointment.customer.last_name, + title: title.join(' - '), start: moment(appointment.start_datetime).toDate(), end: moment(appointment.end_datetime).toDate(), allDay: false, diff --git a/assets/js/utils/calendar_table_view.js b/assets/js/utils/calendar_table_view.js index f798c8c5..c1a50778 100755 --- a/assets/js/utils/calendar_table_view.js +++ b/assets/js/utils/calendar_table_view.js @@ -969,14 +969,27 @@ App.Utils.CalendarTableView = (function () { continue; } + const title = [ + appointment.service.name + ]; + + const customerInfo = []; + + if (appointment.customer.first_name) { + customerInfo.push(appointment.customer.first_name); + } + + if (appointment.customer.last_name) { + customerInfo.push(appointment.customer.last_name); + } + + if (customerInfo.length) { + title.push(customerInfo.join(' ')); + } + calendarEvents.push({ id: appointment.id, - title: - appointment.service.name + - ' - ' + - appointment.customer.first_name + - ' ' + - appointment.customer.last_name, + title: title.join(' - '), start: moment(appointment.start_datetime).toDate(), end: moment(appointment.end_datetime).toDate(), allDay: false,