Przeglądaj źródła

fix constraint regression

Adam Shaw 9 lat temu
rodzic
commit
67f6d63f2b
1 zmienionych plików z 17 dodań i 14 usunięć
  1. 17 14
      src/EventManager.js

+ 17 - 14
src/EventManager.js

@@ -1153,26 +1153,24 @@ Calendar.prototype.isSpanAllowed = function(span, constraint, overlap, event) {
 	var peerOverlap;
 
 	// the range must be fully contained by at least one of produced constraint events
-	if (
-		constraint != null &&
-		constraint.start != null &&
-		constraint.end != null
-	) {
+	if (constraint != null) {
 
 		// not treated as an event! intermediate data structure
 		// TODO: use ranges in the future
 		constraintEvents = this.constraintToEvents(constraint);
+		if (constraintEvents) { // not invalid
 
-		anyContainment = false;
-		for (i = 0; i < constraintEvents.length; i++) {
-			if (this.spanContainsSpan(constraintEvents[i], span)) {
-				anyContainment = true;
-				break;
+			anyContainment = false;
+			for (i = 0; i < constraintEvents.length; i++) {
+				if (this.spanContainsSpan(constraintEvents[i], span)) {
+					anyContainment = true;
+					break;
+				}
 			}
-		}
 
-		if (!anyContainment) {
-			return false;
+			if (!anyContainment) {
+				return false;
+			}
 		}
 	}
 
@@ -1227,7 +1225,12 @@ Calendar.prototype.constraintToEvents = function(constraintInput) {
 	}
 
 	if (typeof constraintInput === 'object') {
-		return this.expandEvent(this.buildEventFromInput(constraintInput));
+		if (constraintInput.start != null) { // needs to be event-like input
+			return this.expandEvent(this.buildEventFromInput(constraintInput));
+		}
+		else {
+			return null; // invalid
+		}
 	}
 
 	return this.clientEvents(constraintInput); // probably an ID