Sfoglia il codice sorgente

fix updateEvent problem with allday->timed. fixes #3144

Adam Shaw 8 anni fa
parent
commit
21a34f7d33

+ 6 - 5
src/models/event/EventDefDateMutation.js

@@ -20,9 +20,14 @@ var EventDefDateMutation = Class.extend({
 		var end = null;
 		var shouldRezone = false;
 
-		if (!this.clearEnd && eventDateProfile.end) {
+		if (eventDateProfile.end && !this.clearEnd) {
 			end = eventDateProfile.end.clone();
 		}
+		// if there will be an end-date mutation, guarantee an end,
+		// ambigously-zoned according to the original allDay
+		else if (this.endDelta && !end) {
+			end = calendar.getDefaultEventEnd(eventDateProfile.isAllDay(), start);
+		}
 
 		if (this.forceTimed) {
 			shouldRezone = true;
@@ -60,10 +65,6 @@ var EventDefDateMutation = Class.extend({
 		if (this.endDelta) {
 			shouldRezone = true;
 
-			if (!end) {
-				end = calendar.getDefaultEventEnd(eventDateProfile.isAllDay(), start);
-			}
-
 			end.add(this.endDelta);
 		}
 

+ 32 - 0
tests/event-data/updateEvent.js

@@ -114,6 +114,38 @@ describe('updateEvent', function() {
 		});
 	});
 
+	describe('when changing an event from all-day to timed', function() {
+
+		it('accepts all new properties as-is', function() {
+			var event;
+
+			initCalendar({
+				defaultView: 'month',
+				defaultDate: '2016-04-29',
+				events: [
+					{
+						title: 'Test event',
+						start: '2016-04-29'
+					}
+				]
+			});
+
+			event = currentCalendar.clientEvents()[0];
+
+			event.allDay = false;
+			event.start = '2016-04-29T12:00:00'; // 12 noon
+			event.end = '2016-04-29T14:00:00'; // 2pm
+			currentCalendar.updateEvent(event);
+
+			event = currentCalendar.clientEvents()[0];
+			expect(event.allDay).toBe(false);
+			expect(moment.isMoment(event.start)).toBe(true);
+			expect(moment.isMoment(event.end)).toBe(true);
+			expect(event.start).toEqualMoment('2016-04-29T12:00:00');
+			expect(event.end).toEqualMoment('2016-04-29T14:00:00');
+		});
+	});
+
 	describe('when adding a new misc object property', function() {
 
 		it('accepts the new property', function() {