Skip to content

Commit

Permalink
BC-7936 update after review
Browse files Browse the repository at this point in the history
  • Loading branch information
UzaeirKhan committed Oct 17, 2024
1 parent 86f6a4e commit 6deaeb5
Showing 1 changed file with 11 additions and 25 deletions.
36 changes: 11 additions & 25 deletions static/scripts/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
Expand All @@ -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;
}
});
};
Expand Down Expand Up @@ -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(),
Expand All @@ -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 || {};

Expand All @@ -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({
Expand All @@ -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`);
}
Expand All @@ -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'),
Expand Down Expand Up @@ -344,4 +330,4 @@ $(document).ready(() => {
hideAreaByEvent(event);
}
});
});
});

0 comments on commit 6deaeb5

Please sign in to comment.