Adam Shaw 8 лет назад
Родитель
Сommit
1e14f35024

+ 15 - 0
src/Calendar.constraints.js

@@ -10,6 +10,8 @@ Calendar.prototype.isEventRangeGroupAllowed = function(eventRangeGroup) {
 	var constraintVal = eventDef.getConstraint();
 	var overlapVal = eventDef.getOverlap();
 
+	var eventAllowFunc = this.opt('eventAllow');
+
 	for (i = 0; i < eventFootprints.length; i++) {
 		if (
 			!this.isFootprintAllowed(
@@ -24,6 +26,19 @@ Calendar.prototype.isEventRangeGroupAllowed = function(eventRangeGroup) {
 		}
 	}
 
+	if (eventAllowFunc) {
+		for (i = 0; i < eventFootprints.length; i++) {
+			if (
+				eventAllowFunc(
+					convertFootprintToLegacySelection(eventFootprints[i].componentFootprint, this),
+					eventFootprints[i].toLegacy()
+				) === false
+			) {
+				return false;
+			}
+		}
+	}
+
 	return true;
 };
 

+ 0 - 13
src/common/View.js

@@ -1005,16 +1005,3 @@ function convertEventsPayloadToLegacyArray(eventsPayload) {
 
 	return legacyEvents;
 }
-
-
-function convertFootprintToLegacySelection(footprint, calendar) {
-	var start = calendar.moment(footprint.dateRange.startMs);
-	var end = calendar.moment(footprint.dateRange.endMs);
-
-	if (footprint.isAllDay) {
-		start.stripTime();
-		end.stripTime();
-	}
-
-	return { start: start, end: end };
-}

+ 13 - 0
src/models/ComponentFootprint.js

@@ -16,3 +16,16 @@ var ComponentFootprint = Class.extend({
 	}
 
 });
+
+
+function convertFootprintToLegacySelection(footprint, calendar) {
+	var start = calendar.moment(footprint.dateRange.startMs);
+	var end = calendar.moment(footprint.dateRange.endMs);
+
+	if (footprint.isAllDay) {
+		start.stripTime();
+		end.stripTime();
+	}
+
+	return { start: start, end: end };
+}

+ 1 - 1
src/models/event/SingleEventDef.js

@@ -85,7 +85,7 @@ SingleEventDef.pluckAndParse = function(rawProps, source) {
 		if (!start.hasTime()) {
 			start.time(0);
 		}
-		if (end && !start.hasTime()) {
+		if (end && !end.hasTime()) {
 			end.time(0);
 		}
 	}

+ 1 - 1
tests/legacy/event-obj.js

@@ -109,7 +109,7 @@ describe('event object creation', function() {
 	it('strips times of dates when event is all-day', function() {
 		init({
 			start: '2014-05-01T01:00:00-12:00',
-			end: '2014-05-02T01:00:00+12:00',
+			end: '2014-05-02T01:00:00-12:00',
 			allDay: true
 		});
 		expect(event.start.hasTime()).toEqual(false);

+ 24 - 0
tests/legacy/event-resize.js

@@ -44,7 +44,10 @@ describe('eventResize', function() {
 
 						expect(event.start).toEqualMoment('2014-06-11');
 						expect(event.end).toEqualMoment('2014-06-17');
+
 						revertFunc();
+						event = $('#cal').fullCalendar('clientEvents')[0];
+
 						expect(event.start).toEqualMoment('2014-06-11');
 						expect(event.end).toBeNull();
 
@@ -94,7 +97,10 @@ describe('eventResize', function() {
 
 								expect(event.start).toEqualMoment('2014-06-11');
 								expect(event.end).toEqualMoment('2014-06-17');
+
 								revertFunc();
+								event = $('#cal').fullCalendar('clientEvents')[0];
+
 								expect(event.start).toEqualMoment('2014-06-11');
 								expect(event.end).toBeNull();
 
@@ -151,7 +157,10 @@ describe('eventResize', function() {
 
 						expect(event.start).toEqualMoment('2014-06-11');
 						expect(event.end).toEqualMoment('2014-06-14');
+
 						revertFunc();
+						event = $('#cal').fullCalendar('clientEvents')[0];
+
 						expect(event.start).toEqualMoment('2014-06-11');
 						expect(event.end).toBeNull();
 
@@ -188,7 +197,10 @@ describe('eventResize', function() {
 
 						expect(event.start).toEqualMoment('2014-06-11T05:00:00');
 						expect(event.end).toEqualMoment('2014-06-11T09:30:00');
+
 						revertFunc();
+						event = $('#cal').fullCalendar('clientEvents')[0];
+
 						expect(event.start).toEqualMoment('2014-06-11T05:00:00');
 						expect(event.end).toEqualMoment('2014-06-11T07:00:00');
 
@@ -223,7 +235,10 @@ describe('eventResize', function() {
 
 						expect(event.start).toEqualMoment('2014-06-11T05:00:00');
 						expect(event.end).toEqualMoment('2014-06-11T09:30:00');
+
 						revertFunc();
+						event = $('#cal').fullCalendar('clientEvents')[0];
+
 						expect(event.start).toEqualMoment('2014-06-11T05:00:00');
 						expect(event.end).toEqualMoment('2014-06-11T07:00:00');
 
@@ -251,7 +266,10 @@ describe('eventResize', function() {
 
 						expect(event.start).toEqualMoment('2014-06-11T05:00:00');
 						expect(event.end).toEqualMoment('2014-06-12T09:30:00');
+
 						revertFunc();
+						event = $('#cal').fullCalendar('clientEvents')[0];
+
 						expect(event.start).toEqualMoment('2014-06-11T05:00:00');
 						expect(event.end).toEqualMoment('2014-06-11T07:00:00');
 
@@ -278,7 +296,10 @@ describe('eventResize', function() {
 
 						expect(event.start).toEqualMoment(moment('2014-06-11T05:00:00')); // compate to local moment
 						expect(event.end).toEqualMoment(moment('2014-06-11T09:30:00'));
+
 						revertFunc();
+						event = $('#cal').fullCalendar('clientEvents')[0];
+
 						expect(event.start).toEqualMoment(moment('2014-06-11T05:00:00'));
 						expect(event.end).toEqualMoment(moment('2014-06-11T07:00:00'));
 
@@ -305,7 +326,10 @@ describe('eventResize', function() {
 
 						expect(event.start).toEqualMoment('2014-06-11T05:00:00+00:00');
 						expect(event.end).toEqualMoment('2014-06-11T09:30:00+00:00');
+
 						revertFunc();
+						event = $('#cal').fullCalendar('clientEvents')[0];
+
 						expect(event.start).toEqualMoment('2014-06-11T05:00:00+00:00');
 						expect(event.end).toEqualMoment('2014-06-11T07:00:00+00:00');