Skip to content

Commit 73d185a

Browse files
committed
use calendarStartDate and calendarEndDate attrs in monthly dashboard calendar.
1 parent a47ad1c commit 73d185a

File tree

5 files changed

+44
-5
lines changed

5 files changed

+44
-5
lines changed

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

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

3030
get singleDayEvents() {
3131
return this.nonIlmPreWorkEvents.filter((event) =>
32-
DateTime.fromISO(event.startDate).hasSame(DateTime.fromISO(event.endDate), 'day'),
32+
DateTime.fromISO(event.calendarStartDate).hasSame(
33+
DateTime.fromISO(event.calendarEndDate),
34+
'day',
35+
),
3336
);
3437
}
3538

3639
get multiDayEventsList() {
3740
return this.nonIlmPreWorkEvents.filter(
38-
(event) => !DateTime.fromISO(event.startDate).hasSame(DateTime.fromISO(event.endDate), 'day'),
41+
(event) =>
42+
!DateTime.fromISO(event.calendarStartDate).hasSame(
43+
DateTime.fromISO(event.calendarEndDate),
44+
'day',
45+
),
3946
);
4047
}
4148

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export default class MonthlyCalendarComponent extends Component {
2121
return [];
2222
}
2323

24-
return sortBy(this.args.events, ['startDate', 'endDate', 'name']);
24+
return sortBy(this.args.events, ['calendarStartDate', 'calendarEndDate', 'name']);
2525
}
2626

2727
get firstDayOfMonth() {
@@ -51,7 +51,9 @@ export default class MonthlyCalendarComponent extends Component {
5151
month: 'numeric',
5252
day: 'numeric',
5353
}),
54-
events: this.sortedEvents.filter((e) => date.hasSame(DateTime.fromISO(e.startDate), 'day')),
54+
events: this.sortedEvents.filter((e) =>
55+
date.hasSame(DateTime.fromISO(e.calendarStartDate), 'day'),
56+
),
5557
};
5658
});
5759
}
@@ -104,7 +106,7 @@ export default class MonthlyCalendarComponent extends Component {
104106
{{#if event.isMulti}}
105107
<IliosCalendarEventMonth
106108
@event={{event}}
107-
@selectEvent={{fn @changeToDayView event.startDate}}
109+
@selectEvent={{fn @changeToDayView event.calendarStartDate}}
108110
/>
109111
{{else}}
110112
<IliosCalendarEventMonth @event={{event}} @selectEvent={{fn @selectEvent event}} />

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ module('Integration | Component | ilios calendar event month', function (hooks)
1515
color: '#00cc65',
1616
startDate: november111984.toJSDate(),
1717
endDate: november111984.plus({ hour: 1 }).toJSDate(),
18+
calendarStartDate: november111984.toJSDate(),
19+
calendarEndDate: november111984.plus({ hour: 1 }).toJSDate(),
1820
lastModified: november111984.toJSDate(),
1921
name: 'test',
2022
});

packages/test-app/tests/integration/components/ilios-calendar-month-test.gjs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,20 @@ module('Integration | Component | ilios calendar month', function (hooks) {
1717
firstEvent.name = 'Some new thing';
1818
firstEvent.startDate = date.toISO();
1919
firstEvent.endDate = date.plus({ hour: 1 }).toISO();
20+
firstEvent.calendarStartDate = firstEvent.startDate;
21+
firstEvent.calendarEndDate = firstEvent.endDate;
2022
const secondEvent = createUserEventObject();
2123
secondEvent.name = 'Second new thing';
2224
secondEvent.startDate = date.plus({ hour: 1 }).toISO();
2325
secondEvent.endDate = date.plus({ hour: 3 }).toISO();
26+
secondEvent.calendarStartDate = secondEvent.startDate;
27+
secondEvent.calendarEndDate = secondEvent.endDate;
2428
const thirdEvent = createUserEventObject();
2529
thirdEvent.name = 'Third new thing';
2630
thirdEvent.startDate = date.plus({ hour: 3 }).toISO();
2731
thirdEvent.endDate = date.plus({ hour: 4 }).toISO();
32+
thirdEvent.calendarStartDate = thirdEvent.startDate;
33+
thirdEvent.calendarEndDate = thirdEvent.endDate;
2834
this.set('events', [firstEvent, secondEvent, thirdEvent]);
2935
await render(
3036
<template>
@@ -47,10 +53,14 @@ module('Integration | Component | ilios calendar month', function (hooks) {
4753
firstEvent.name = 'Some new thing';
4854
firstEvent.startDate = date.toISO();
4955
firstEvent.endDate = date.plus({ hour: 1 }).toISO();
56+
firstEvent.calendarStartDate = firstEvent.startDate;
57+
firstEvent.calendarEndDate = firstEvent.endDate;
5058
const secondEvent = createUserEventObject();
5159
secondEvent.name = 'Second new thing';
5260
secondEvent.startDate = date.plus({ hour: 1 }).toISO();
5361
secondEvent.endDate = date.plus({ hour: 3 }).toISO();
62+
secondEvent.calendarStartDate = secondEvent.startDate;
63+
secondEvent.calendarEndDate = secondEvent.endDate;
5464
this.set('events', [firstEvent, secondEvent]);
5565
await render(
5666
<template>
@@ -114,9 +124,13 @@ module('Integration | Component | ilios calendar month', function (hooks) {
114124
const event = createUserEventObject();
115125
event.startDate = date.toISO();
116126
event.endDate = date.plus({ hour: 24 }).toISO();
127+
event.calendarStartDate = event.startDate;
128+
event.calendarEndDate = event.endDate;
117129
const event2 = createUserEventObject();
118130
event2.startDate = date.plus({ hour: 48 }).toISO();
119131
event2.endDate = date.plus({ hour: 72 }).toISO();
132+
event2.calendarStartDate = event2.startDate;
133+
event2.calendarEndDate = event2.endDate;
120134
this.set('date', date.toJSDate());
121135
this.set('events', [event, event2]);
122136
await render(

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ module('Integration | Component | monthly-calendar', function (hooks) {
6666
this.server.createList('userevent', 2, {
6767
startDate: january9th2019.toISO(),
6868
endDate: january9th2019.plus({ hour: 1 }).toISO(),
69+
calendarStartDate: january9th2019.toISO(),
70+
calendarEndDate: january9th2019.plus({ hour: 1 }).toISO(),
6971
});
7072
this.set('events', this.server.db.userevents);
7173
this.set('date', january9th2019.toJSDate());
@@ -103,6 +105,8 @@ module('Integration | Component | monthly-calendar', function (hooks) {
103105
this.server.createList('userevent', 3, {
104106
startDate: january9th2019.toISO(),
105107
endDate: january9th2019.plus({ hour: 1 }).toISO(),
108+
calendarStartDate: january9th2019.toISO(),
109+
calendarEndDate: january9th2019.plus({ hour: 1 }).toISO(),
106110
});
107111
this.set('events', this.server.db.userevents);
108112
this.set('date', january9th2019.toJSDate());
@@ -167,6 +171,8 @@ module('Integration | Component | monthly-calendar', function (hooks) {
167171
this.server.create('userevent', {
168172
startDate: january9th2019.toISO(),
169173
endDate: january9th2019.plus({ hour: 1 }).toISO(),
174+
calendarStartDate: january9th2019.toISO(),
175+
calendarEndDate: january9th2019.plus({ hour: 1 }).toISO(),
170176
offering: 1,
171177
});
172178
this.set('events', this.server.db.userevents);
@@ -201,6 +207,8 @@ module('Integration | Component | monthly-calendar', function (hooks) {
201207
this.server.createList('userevent', 3, {
202208
startDate: january9th2019.toISO(),
203209
endDate: january9th2019.plus({ hour: 1 }).toISO(),
210+
calendarStartDate: january9th2019.toISO(),
211+
calendarEndDate: january9th2019.plus({ hour: 1 }).toISO(),
204212
});
205213
this.set('events', this.server.db.userevents);
206214
this.set('date', january9th2019.toJSDate());
@@ -235,6 +243,8 @@ module('Integration | Component | monthly-calendar', function (hooks) {
235243
isMulti: true,
236244
startDate: january9th2019.toISO(),
237245
endDate: january9th2019.plus({ hour: 1 }).toISO(),
246+
calendarStartDate: january9th2019.toISO(),
247+
calendarEndDate: january9th2019.plus({ hour: 1 }).toISO(),
238248
offering: 1,
239249
});
240250
this.set('events', this.server.db.userevents);
@@ -269,6 +279,8 @@ module('Integration | Component | monthly-calendar', function (hooks) {
269279
this.server.create('userevent', {
270280
startDate: december112017.toISO(),
271281
endDate: december112017.plus({ hour: 1 }).toISO(),
282+
calendarStartDate: december112017.toISO(),
283+
calendarEndDate: december112017.plus({ hour: 1 }).toISO(),
272284
});
273285
this.set('events', this.server.db.userevents);
274286
this.set('date', december112017.toJSDate());
@@ -311,6 +323,8 @@ module('Integration | Component | monthly-calendar', function (hooks) {
311323
this.server.create('userevent', {
312324
startDate: february1st2020.toISO(),
313325
endDate: february1st2020.plus({ hour: 1 }).toISO(),
326+
calendarStartDate: february1st2020.toISO(),
327+
calendarEndDate: february1st2020.plus({ hour: 1 }).toISO(),
314328
});
315329
this.set('events', this.server.db.userevents);
316330
this.set('date', february1st2020.toJSDate());

0 commit comments

Comments
 (0)