Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5cccb875 authored by Richard Steinmetz's avatar Richard Steinmetz Committed by backportbot[bot]
Browse files

Fix reminder time zone picker and formatting

parent fc0ed116
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -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"
@@ -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>
+3 −0
Original line number Diff line number Diff line
@@ -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
@@ -109,6 +111,7 @@ const mapAlarmComponentToAlarmObject = (alarmComponent) => {
			type: alarmComponent.action,
			isRelative: alarmComponent.trigger.isRelative(),
			absoluteDate,
			absoluteTimezoneId: alarmComponent.trigger.value.timezoneId,
		})
	}
}
+4 −0
Original line number Diff line number Diff line
BEGIN:VALARM
ACTION:DISPLAY
TRIGGER;TZID=Africa/Banjul;VALUE=DATE-TIME:20220115T090000
END:VALARM
+40 −0
Original line number Diff line number Diff line
@@ -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,
@@ -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,
@@ -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,
@@ -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')

@@ -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',
@@ -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',
@@ -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',
@@ -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',
@@ -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',