Loading src/components/Editor/Alarm/AlarmListItem.vue +15 −1 Original line number Diff line number Diff line Loading @@ -88,8 +88,10 @@ <DatePicker prefix="on" :date="alarm.absoluteDate" :timezone-id="alarm.absoluteTimezoneId" :is-all-day="false" @change="changeAbsoluteDate" /> @change="changeAbsoluteDate" @change-timezone="changeAbsoluteTimezoneId" /> </div> <div v-if="!isReadOnly" Loading Loading @@ -462,6 +464,18 @@ export default { date, }) }, /** * Changes the time zone of the absolute alarm * * @param {string} timezoneId The new time zone id of the alarm */ changeAbsoluteTimezoneId(timezoneId) { this.$store.commit('changeAlarmAbsoluteTimezoneId', { calendarObjectInstance: this.calendarObjectInstance, alarm: this.alarm, timezoneId, }) }, }, } </script> src/models/alarm.js +3 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,8 @@ const getDefaultAlarmObject = (props = {}) => Object.assign({}, { isRelative: false, // Date object of an absolute alarm (if it's absolute, it must be DATE-TIME) absoluteDate: null, // The time zone id of for absolute alarms absoluteTimezoneId: null, // Whether or not the relative alarm is before the event, relativeIsBefore: null, // Whether or not the alarm is relative to the event's start Loading Loading @@ -109,6 +111,7 @@ const mapAlarmComponentToAlarmObject = (alarmComponent) => { type: alarmComponent.action, isRelative: alarmComponent.trigger.isRelative(), absoluteDate, absoluteTimezoneId: alarmComponent.trigger.value.timezoneId, }) } } Loading tests/assets/ics/alarms/absoluteAlarmWithTimezone.ics 0 → 100644 +4 −0 Original line number Diff line number Diff line BEGIN:VALARM ACTION:DISPLAY TRIGGER;TZID=Africa/Banjul;VALUE=DATE-TIME:20220115T090000 END:VALARM tests/javascript/unit/models/alarm.test.js +40 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ describe('Test suite: Alarm model (models/alarm.js)', () => { type: null, isRelative: false, absoluteDate: null, absoluteTimezoneId: null, relativeIsBefore: null, relativeIsRelatedToStart: null, relativeUnitTimed: null, Loading @@ -64,6 +65,7 @@ describe('Test suite: Alarm model (models/alarm.js)', () => { type: 'DISPLAY', isRelative: false, absoluteDate: null, absoluteTimezoneId: null, relativeIsBefore: null, relativeIsRelatedToStart: null, relativeUnitTimed: null, Loading @@ -90,6 +92,7 @@ describe('Test suite: Alarm model (models/alarm.js)', () => { type: 'DISPLAY', isRelative: false, absoluteDate: mockDate, absoluteTimezoneId: 'UTC', relativeIsBefore: null, relativeIsRelatedToStart: null, relativeUnitTimed: null, Loading @@ -107,6 +110,38 @@ describe('Test suite: Alarm model (models/alarm.js)', () => { expect(getAmountHoursMinutesAndUnitForAllDayEvents).toHaveBeenCalledTimes(0) }) it('should properly load an absolute alarm with a time zone other than UTC', () => { const mockDate = new Date() getDateFromDateTimeValue .mockReturnValueOnce(mockDate) const alarmComponent = getAlarmComponentFromAsset('alarms/absoluteAlarmWithTimezone') const alarmModel = mapAlarmComponentToAlarmObject(alarmComponent) expect(alarmModel).toEqual({ alarmComponent, type: 'DISPLAY', isRelative: false, absoluteDate: mockDate, absoluteTimezoneId: 'Africa/Banjul', relativeIsBefore: null, relativeIsRelatedToStart: null, relativeUnitTimed: null, relativeAmountTimed: null, relativeUnitAllDay: null, relativeAmountAllDay: null, relativeHoursAllDay: null, relativeMinutesAllDay: null, relativeTrigger: null, }) expect(getDateFromDateTimeValue.mock.calls[0][0].getInUTC().jsDate.toISOString()).toEqual('2022-01-15T09:00:00.000Z') expect(getDateFromDateTimeValue.mock.calls[0][0].timezoneId).toEqual('Africa/Banjul') expect(getAmountAndUnitForTimedEvents).toHaveBeenCalledTimes(0) expect(getAmountHoursMinutesAndUnitForAllDayEvents).toHaveBeenCalledTimes(0) }) it('should properly load a relative alarm a week before the event', () => { const alarmComponent = getAlarmComponentFromAsset('alarms/relativeAlarmWeekBefore') Loading @@ -130,6 +165,7 @@ describe('Test suite: Alarm model (models/alarm.js)', () => { type: 'DISPLAY', isRelative: true, absoluteDate: null, absoluteTimezoneId: null, relativeIsBefore: true, relativeIsRelatedToStart: true, relativeUnitTimed: 'hours', Loading Loading @@ -184,6 +220,7 @@ describe('Test suite: Alarm model (models/alarm.js)', () => { type: 'DISPLAY', isRelative: true, absoluteDate: null, absoluteTimezoneId: null, relativeIsBefore: true, relativeIsRelatedToStart: true, relativeUnitTimed: 'hours', Loading Loading @@ -224,6 +261,7 @@ describe('Test suite: Alarm model (models/alarm.js)', () => { type: 'DISPLAY', isRelative: true, absoluteDate: null, absoluteTimezoneId: null, relativeIsBefore: false, relativeIsRelatedToStart: true, relativeUnitTimed: 'hours', Loading Loading @@ -264,6 +302,7 @@ describe('Test suite: Alarm model (models/alarm.js)', () => { type: 'DISPLAY', isRelative: true, absoluteDate: null, absoluteTimezoneId: null, relativeIsBefore: false, relativeIsRelatedToStart: true, relativeUnitTimed: 'hours', Loading Loading @@ -304,6 +343,7 @@ describe('Test suite: Alarm model (models/alarm.js)', () => { type: 'DISPLAY', isRelative: true, absoluteDate: null, absoluteTimezoneId: null, relativeIsBefore: true, relativeIsRelatedToStart: false, relativeUnitTimed: 'hours', Loading Loading
src/components/Editor/Alarm/AlarmListItem.vue +15 −1 Original line number Diff line number Diff line Loading @@ -88,8 +88,10 @@ <DatePicker prefix="on" :date="alarm.absoluteDate" :timezone-id="alarm.absoluteTimezoneId" :is-all-day="false" @change="changeAbsoluteDate" /> @change="changeAbsoluteDate" @change-timezone="changeAbsoluteTimezoneId" /> </div> <div v-if="!isReadOnly" Loading Loading @@ -462,6 +464,18 @@ export default { date, }) }, /** * Changes the time zone of the absolute alarm * * @param {string} timezoneId The new time zone id of the alarm */ changeAbsoluteTimezoneId(timezoneId) { this.$store.commit('changeAlarmAbsoluteTimezoneId', { calendarObjectInstance: this.calendarObjectInstance, alarm: this.alarm, timezoneId, }) }, }, } </script>
src/models/alarm.js +3 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,8 @@ const getDefaultAlarmObject = (props = {}) => Object.assign({}, { isRelative: false, // Date object of an absolute alarm (if it's absolute, it must be DATE-TIME) absoluteDate: null, // The time zone id of for absolute alarms absoluteTimezoneId: null, // Whether or not the relative alarm is before the event, relativeIsBefore: null, // Whether or not the alarm is relative to the event's start Loading Loading @@ -109,6 +111,7 @@ const mapAlarmComponentToAlarmObject = (alarmComponent) => { type: alarmComponent.action, isRelative: alarmComponent.trigger.isRelative(), absoluteDate, absoluteTimezoneId: alarmComponent.trigger.value.timezoneId, }) } } Loading
tests/assets/ics/alarms/absoluteAlarmWithTimezone.ics 0 → 100644 +4 −0 Original line number Diff line number Diff line BEGIN:VALARM ACTION:DISPLAY TRIGGER;TZID=Africa/Banjul;VALUE=DATE-TIME:20220115T090000 END:VALARM
tests/javascript/unit/models/alarm.test.js +40 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ describe('Test suite: Alarm model (models/alarm.js)', () => { type: null, isRelative: false, absoluteDate: null, absoluteTimezoneId: null, relativeIsBefore: null, relativeIsRelatedToStart: null, relativeUnitTimed: null, Loading @@ -64,6 +65,7 @@ describe('Test suite: Alarm model (models/alarm.js)', () => { type: 'DISPLAY', isRelative: false, absoluteDate: null, absoluteTimezoneId: null, relativeIsBefore: null, relativeIsRelatedToStart: null, relativeUnitTimed: null, Loading @@ -90,6 +92,7 @@ describe('Test suite: Alarm model (models/alarm.js)', () => { type: 'DISPLAY', isRelative: false, absoluteDate: mockDate, absoluteTimezoneId: 'UTC', relativeIsBefore: null, relativeIsRelatedToStart: null, relativeUnitTimed: null, Loading @@ -107,6 +110,38 @@ describe('Test suite: Alarm model (models/alarm.js)', () => { expect(getAmountHoursMinutesAndUnitForAllDayEvents).toHaveBeenCalledTimes(0) }) it('should properly load an absolute alarm with a time zone other than UTC', () => { const mockDate = new Date() getDateFromDateTimeValue .mockReturnValueOnce(mockDate) const alarmComponent = getAlarmComponentFromAsset('alarms/absoluteAlarmWithTimezone') const alarmModel = mapAlarmComponentToAlarmObject(alarmComponent) expect(alarmModel).toEqual({ alarmComponent, type: 'DISPLAY', isRelative: false, absoluteDate: mockDate, absoluteTimezoneId: 'Africa/Banjul', relativeIsBefore: null, relativeIsRelatedToStart: null, relativeUnitTimed: null, relativeAmountTimed: null, relativeUnitAllDay: null, relativeAmountAllDay: null, relativeHoursAllDay: null, relativeMinutesAllDay: null, relativeTrigger: null, }) expect(getDateFromDateTimeValue.mock.calls[0][0].getInUTC().jsDate.toISOString()).toEqual('2022-01-15T09:00:00.000Z') expect(getDateFromDateTimeValue.mock.calls[0][0].timezoneId).toEqual('Africa/Banjul') expect(getAmountAndUnitForTimedEvents).toHaveBeenCalledTimes(0) expect(getAmountHoursMinutesAndUnitForAllDayEvents).toHaveBeenCalledTimes(0) }) it('should properly load a relative alarm a week before the event', () => { const alarmComponent = getAlarmComponentFromAsset('alarms/relativeAlarmWeekBefore') Loading @@ -130,6 +165,7 @@ describe('Test suite: Alarm model (models/alarm.js)', () => { type: 'DISPLAY', isRelative: true, absoluteDate: null, absoluteTimezoneId: null, relativeIsBefore: true, relativeIsRelatedToStart: true, relativeUnitTimed: 'hours', Loading Loading @@ -184,6 +220,7 @@ describe('Test suite: Alarm model (models/alarm.js)', () => { type: 'DISPLAY', isRelative: true, absoluteDate: null, absoluteTimezoneId: null, relativeIsBefore: true, relativeIsRelatedToStart: true, relativeUnitTimed: 'hours', Loading Loading @@ -224,6 +261,7 @@ describe('Test suite: Alarm model (models/alarm.js)', () => { type: 'DISPLAY', isRelative: true, absoluteDate: null, absoluteTimezoneId: null, relativeIsBefore: false, relativeIsRelatedToStart: true, relativeUnitTimed: 'hours', Loading Loading @@ -264,6 +302,7 @@ describe('Test suite: Alarm model (models/alarm.js)', () => { type: 'DISPLAY', isRelative: true, absoluteDate: null, absoluteTimezoneId: null, relativeIsBefore: false, relativeIsRelatedToStart: true, relativeUnitTimed: 'hours', Loading Loading @@ -304,6 +343,7 @@ describe('Test suite: Alarm model (models/alarm.js)', () => { type: 'DISPLAY', isRelative: true, absoluteDate: null, absoluteTimezoneId: null, relativeIsBefore: true, relativeIsRelatedToStart: false, relativeUnitTimed: 'hours', Loading