diff --git a/static/scripts/calendar.js b/static/scripts/calendar.js index 8e1d5813b3..41f28b801c 100644 --- a/static/scripts/calendar.js +++ b/static/scripts/calendar.js @@ -49,7 +49,8 @@ const getCalendarLanguage = (langAttribute) => { } }; -// Add data-testid attributes to navigation buttons in calendar page +// Add data-testid attributes to navigation buttons in calendar page as the calendar module +// that is used (https://fullcalendar.io) does not support configuration of data-testids for buttons in used version const addDatatestidsToCalendarNavigation = () => { const buttonData = [ { selector: '.fc-right .fc-prev-button', testId: 'right-prev-button' }, @@ -63,7 +64,7 @@ const addDatatestidsToCalendarNavigation = () => { buttonData.forEach(({ selector, testId }) => { const button = document.querySelector(selector); if (button) { - button.setAttribute('data-testid', testId); + button.dataset.testid = testId; } }); }; @@ -138,12 +139,7 @@ $(document).ready(() => { const getLangAttribute = () => document.querySelector('html').getAttribute('lang'); const calendar = new Calendar(getCalendarElement(), { - plugins: [ - dayGridPlugin, - timeGridPlugin, - interactionPlugin, - momentTimezonePlugin, - ], + plugins: [dayGridPlugin, timeGridPlugin, interactionPlugin, momentTimezonePlugin], defaultView: getView() || 'dayGridMonth', editable: false, timeZone: getCalendarTimezone(), @@ -167,12 +163,8 @@ $(document).ready(() => { return false; } // personal event - const startDate = toMoment(event.start, calendar).format( - $t('format.dateTimeToPicker'), - ); - const endDate = toMoment(event.end || event.start, calendar).format( - $t('format.dateTimeToPicker'), - ); + const startDate = toMoment(event.start, calendar).format($t('format.dateTimeToPicker')); + const endDate = toMoment(event.end || event.start, calendar).format($t('format.dateTimeToPicker')); const eventData = event.extendedProps || {}; @@ -191,8 +183,7 @@ $(document).ready(() => { action: URI.getSingleEvent(eventData._id), }); - if (!eventData['x-sc-teamId']) { - // course or non-course event + if (!eventData['x-sc-teamId']) { // course or non-course event transformCourseOrTeamEvent($editEventModal, eventData); $editEventModal.find('.btn-delete').click(() => { $.ajax({ @@ -207,8 +198,7 @@ $(document).ready(() => { $editEventModal.appendTo('body').modal('show'); } - if (eventData['x-sc-teamId']) { - // team event + if (eventData['x-sc-teamId']) { // team event const teamId = eventData['x-sc-teamId']; window.location.assign(`/teams/${teamId}?activeTab=events`); } @@ -219,12 +209,8 @@ $(document).ready(() => { const { date } = info; // open create event modal - const startDate = toMoment(date, calendar).format( - $t('format.dateTimeToPicker'), - ); - const endDate = toMoment(date, calendar) - .add(1, 'hour') - .format($t('format.dateTimeToPicker')); + const startDate = toMoment(date, calendar).format($t('format.dateTimeToPicker')); + const endDate = toMoment(date, calendar).add(1, 'hour').format($t('format.dateTimeToPicker')); populateModalForm($createEventModal, { title: $t('global.headline.addDate'), @@ -344,4 +330,4 @@ $(document).ready(() => { hideAreaByEvent(event); } }); -}); +}); \ No newline at end of file