Skip to content

Commit 48ac957

Browse files
committed
use calendarStartDate and calendarEndDate attrs in weekly dashboard calendar.
1 parent 68475ab commit 48ac957

File tree

5 files changed

+28
-9
lines changed

5 files changed

+28
-9
lines changed

packages/ilios-common/addon/components/ilios-calendar-week.gjs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,19 @@ export default class IliosCalendarWeekComponent extends Component {
4444
}
4545
get singleDayEvents() {
4646
return this.nonIlmPreWorkEvents.filter((event) =>
47-
DateTime.fromISO(event.startDate).hasSame(DateTime.fromISO(event.endDate), 'day'),
47+
DateTime.fromISO(event.calendarStartDate).hasSame(
48+
DateTime.fromISO(event.calendarEndDate),
49+
'day',
50+
),
4851
);
4952
}
5053
get multiDayEventsList() {
5154
return this.nonIlmPreWorkEvents.filter(
52-
(event) => !DateTime.fromISO(event.startDate).hasSame(DateTime.fromISO(event.endDate), 'day'),
55+
(event) =>
56+
!DateTime.fromISO(event.calendarStartDate).hasSame(
57+
DateTime.fromISO(event.calendarEndDate),
58+
'day',
59+
),
5360
);
5461
}
5562

packages/ilios-common/addon/components/weekly-calendar-event.gjs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ export default class WeeklyCalendarEventComponent extends Component {
2929

3030
get minutes() {
3131
const allMinutesInDay = Array(60 * 24).fill(0);
32-
this.args.allDayEvents.forEach(({ startDate, endDate }) => {
33-
const start = this.getMinuteInTheDay(DateTime.fromISO(startDate));
34-
const end = this.getMinuteInTheDay(DateTime.fromISO(endDate));
32+
this.args.allDayEvents.forEach(({ calendarStartDate, calendarEndDate }) => {
33+
const start = this.getMinuteInTheDay(DateTime.fromISO(calendarStartDate));
34+
const end = this.getMinuteInTheDay(DateTime.fromISO(calendarEndDate));
3535
for (let i = start; i <= end; i++) {
3636
allMinutesInDay[i - 1]++;
3737
}
@@ -41,11 +41,11 @@ export default class WeeklyCalendarEventComponent extends Component {
4141
}
4242

4343
get startDateTime() {
44-
return DateTime.fromISO(this.args.event.startDate);
44+
return DateTime.fromISO(this.args.event.calendarStartDate);
4545
}
4646

4747
get endDateTime() {
48-
return DateTime.fromISO(this.args.event.endDate);
48+
return DateTime.fromISO(this.args.event.calendarEndDate);
4949
}
5050

5151
get startDate() {

packages/ilios-common/addon/components/weekly-calendar.gjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export default class WeeklyCalendarComponent extends Component {
5454
}
5555

5656
return this.sortedEvents.reduce((earliestHour, event) => {
57-
const hour = Number(DateTime.fromISO(event.startDate).toFormat('HH'));
57+
const hour = Number(DateTime.fromISO(event.calendarStartDate).toFormat('HH'));
5858
return hour < earliestHour ? hour : earliestHour;
5959
}, 24);
6060
}
@@ -64,7 +64,7 @@ export default class WeeklyCalendarComponent extends Component {
6464
return [];
6565
}
6666

67-
return sortBy(this.args.events, ['startDate', 'endDate', 'name']);
67+
return sortBy(this.args.events, ['calendarStartDate', 'calendarEndDate', 'name']);
6868
}
6969

7070
get days() {

packages/test-app/tests/integration/components/weekly-calendar-event-test.gjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ module('Integration | Component | weekly-calendar-event', function (hooks) {
1616
this.server.create('userevent', {
1717
startDate: DateTime.fromFormat(startDate, 'yyyy-LL-dd hh:mm:ss').toISO(),
1818
endDate: DateTime.fromFormat(endDate, 'yyyy-LL-dd hh:mm:ss').toISO(),
19+
calendarStartDate: DateTime.fromFormat(startDate, 'yyyy-LL-dd hh:mm:ss').toISO(),
20+
calendarEndDate: DateTime.fromFormat(endDate, 'yyyy-LL-dd hh:mm:ss').toISO(),
1921
color,
2022
lastModified: DateTime.fromFormat(lastModified, 'yyyy-LL-dd hh:mm:ss').toISO(),
2123
isPublished,

packages/test-app/tests/integration/components/weekly-calendar-test.gjs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ module('Integration | Component | weekly-calendar', function (hooks) {
2323
this.server.create('userevent', {
2424
startDate: DateTime.fromFormat(startDate, 'yyyy-LL-dd hh:mm:ss').toISO(),
2525
endDate: DateTime.fromFormat(endDate, 'yyyy-LL-dd hh:mm:ss').toISO(),
26+
calendarStartDate: DateTime.fromFormat(startDate, 'yyyy-LL-dd hh:mm:ss').toISO(),
27+
calendarEndDate: DateTime.fromFormat(endDate, 'yyyy-LL-dd hh:mm:ss').toISO(),
2628
color: color || '#' + Math.floor(Math.random() * 16777215).toString(16),
2729
lastModified: endDate,
2830
});
@@ -213,6 +215,8 @@ module('Integration | Component | weekly-calendar', function (hooks) {
213215
this.server.create('userevent', {
214216
startDate: january9th2019.toISO(),
215217
endDate: january9th2019.plus({ hour: 1 }).toISO(),
218+
calendarStartDate: january9th2019.toISO(),
219+
calendarEndDate: january9th2019.plus({ hour: 1 }).toISO(),
216220
offering: 1,
217221
});
218222
this.set('events', this.server.db.userevents);
@@ -248,6 +252,8 @@ module('Integration | Component | weekly-calendar', function (hooks) {
248252
isMulti: true,
249253
startDate: january9th2019.toISO(),
250254
endDate: january9th2019.plus({ hour: 1 }).toISO(),
255+
calendarStartDate: january9th2019.toISO(),
256+
calendarEndDate: january9th2019.plus({ hour: 1 }).toISO(),
251257
offering: 1,
252258
});
253259
this.set('events', this.server.db.userevents);
@@ -282,6 +288,8 @@ module('Integration | Component | weekly-calendar', function (hooks) {
282288
this.server.create('userevent', {
283289
startDate: december111980.toISO(),
284290
endDate: december111980.plus({ hour: 1 }).toISO(),
291+
calendarStartDate: december111980.toISO(),
292+
calendarEndDate: december111980.plus({ hour: 1 }).toISO(),
285293
});
286294
this.set('events', this.server.db.userevents);
287295
this.set('date', december111980.toJSDate());
@@ -331,6 +339,8 @@ module('Integration | Component | weekly-calendar', function (hooks) {
331339
this.server.create('userevent', {
332340
startDate: february252020.toISO(),
333341
endDate: february252020.plus({ hour: 1 }).toISO(),
342+
calendarStartDate: february252020.toISO(),
343+
calendarEndDate: february252020.plus({ hour: 1 }).toISO(),
334344
});
335345
this.set('events', this.server.db.userevents);
336346
this.set('date', february252020.toJSDate());

0 commit comments

Comments
 (0)