Adam Shaw 8 yıl önce
ebeveyn
işleme
6f6a804207
3 değiştirilmiş dosya ile 101 ekleme ve 102 silme
  1. 0 1
      src.json
  2. 101 0
      src/models/EventInstanceChangeset.js
  3. 0 101
      src/models/EventInstanceRepo.js

+ 0 - 1
src.json

@@ -59,7 +59,6 @@
     "models/ComponentFootprint.js",
     "models/EventManager.js",
     "models/EventPeriod.js",
-    "models/EventInstanceRepo.js",
     "models/EventInstanceChangeset.js",
     "models/BusinessHourGenerator.js",
     "models/event/EventDefParser.js",

+ 101 - 0
src/models/EventInstanceChangeset.js

@@ -0,0 +1,101 @@
+
+var EventInstanceChangeset = Class.extend({
+
+	removals: null,
+	byDefId: null,
+
+
+	constructor: function(removals, adds) {
+		this.removals = removals || [];
+		this.byDefId = {};
+	},
+
+
+	getEventInstancesForDef: function(eventDef) {
+		return (this.byDefId[eventDef.id] || []).filter(function(eventInstance) {
+			return eventInstance.def === eventDef;
+		});
+	},
+
+
+	getEventInstances: function() { // TODO: use iterator?
+		var byDefId = this.byDefId;
+		var a = [];
+		var id;
+
+		for (id in byDefId) {
+			a.push.apply(a, byDefId[id]);
+		}
+
+		return a;
+	},
+
+
+	getEventInstancesWithId: function(eventDefId) {
+		var bucket = this.byDefId[eventDefId];
+
+		if (bucket) {
+			bucket.slice(); // clone
+		}
+
+		return [];
+	},
+
+
+	getEventInstancesWithoutId: function(eventDefId) {
+		var byDefId = this.byDefId;
+		var a = [];
+		var id;
+
+		for (id in byDefId) {
+			if (id !== eventDefId) {
+				a.push.apply(a, byDefId[id]);
+			}
+		}
+
+		return a;
+	},
+
+
+	addEventInstance: function(eventInstance) {
+		var id = eventInstance.def.id;
+
+		(this.byDefId[id] || (this.byDefId[id] = []))
+			.push(eventInstance);
+	},
+
+
+	removeEventInstance: function(eventInstance) {
+		var id = eventInstance.def.id;
+		var bucket = this.byDefId[id];
+
+		if (bucket) {
+			removeExact(bucket, eventInstance);
+		}
+
+		if (!bucket.length) {
+			delete this.byDefId[id];
+		}
+	},
+
+
+	clear: function() {
+		this.byDefId = {};
+	},
+
+
+	applyChangeset: function(changeset) {
+		var ourHash = this.byDefId;
+		var theirHash = changeset.byDefId;
+		var id;
+		var ourBucket;
+
+		changeset.removals.forEach(this.removeEventInstance.bind(this));
+
+		for (id in theirHash) {
+			ourBucket = (ourHash[id] || (ourHash[id] = []));
+			ourBucket.push.apply(ourBucket, theirHash[id]);
+		}
+	}
+
+});

+ 0 - 101
src/models/EventInstanceRepo.js

@@ -1,101 +0,0 @@
-
-var EventInstanceChangeset = Class.extend({
-
-	removals: null,
-	byDefId: null,
-
-
-	constructor: function(removals, adds) {
-		this.removals = removals || [];
-		this.byDefId = {};
-	},
-
-
-	getEventInstancesForDef: function(eventDef) {
-		return (this.byDefId[eventDef.id] || []).filter(function(eventInstance) {
-			return eventInstance.def === eventDef;
-		});
-	},
-
-
-	getEventInstances: function() { // TODO: use iterator?
-		var byDefId = this.byDefId;
-		var a = [];
-		var id;
-
-		for (id in byDefId) {
-			a.push.apply(a, byDefId[id]);
-		}
-
-		return a;
-	},
-
-
-	getEventInstancesWithId: function(eventDefId) {
-		var bucket = this.byDefId[eventDefId];
-
-		if (bucket) {
-			bucket.slice(); // clone
-		}
-
-		return [];
-	},
-
-
-	getEventInstancesWithoutId: function(eventDefId) {
-		var byDefId = this.byDefId;
-		var a = [];
-		var id;
-
-		for (id in byDefId) {
-			if (id !== eventDefId) {
-				a.push.apply(a, byDefId[id]);
-			}
-		}
-
-		return a;
-	},
-
-
-	addEventInstance: function(eventInstance) {
-		var id = eventInstance.def.id;
-
-		(this.byDefId[id] || (this.byDefId[id] = []))
-			.push(eventInstance);
-	},
-
-
-	removeEventInstance: function(eventInstance) {
-		var id = eventInstance.def.id;
-		var bucket = this.byDefId[id];
-
-		if (bucket) {
-			removeExact(bucket, eventInstance);
-		}
-
-		if (!bucket.length) {
-			delete this.byDefId[id];
-		}
-	},
-
-
-	clear: function() {
-		this.byDefId = {};
-	},
-
-
-	applyChangeset: function(changeset) {
-		var ourHash = this.byDefId;
-		var theirHash = changeset.byDefId;
-		var id;
-		var ourBucket;
-
-		changeset.removals.forEach(this.removeEventInstance.bind(this));
-
-		for (id in theirHash) {
-			ourBucket = (ourHash[id] || (ourHash[id] = []));
-			ourBucket.push.apply(ourBucket, theirHash[id]);
-		}
-	}
-
-});