Explorar el Código

own file for EventInstanceDataSource

Adam Shaw hace 8 años
padre
commit
bcabaae0b4
Se han modificado 3 ficheros con 85 adiciones y 85 borrados
  1. 1 0
      src.json
  2. 84 0
      src/models/EventInstanceDataSource.js
  3. 0 85
      src/models/EventPeriod.js

+ 1 - 0
src.json

@@ -57,6 +57,7 @@
     "models/UnzonedRange.js",
     "models/ComponentFootprint.js",
     "models/EventManager.js",
+    "models/EventInstanceDataSource.js",
     "models/EventPeriod.js",
     "models/EventInstanceChangeset.js",
     "models/BusinessHourGenerator.js",

+ 84 - 0
src/models/EventInstanceDataSource.js

@@ -0,0 +1,84 @@
+
+var EventInstanceDataSource = Class.extend(EmitterMixin, {
+
+	instanceRepo: null,
+	freezeDepth: 0,
+	outboundChangeset: null,
+	isPopulated: false,
+
+
+	constructor: function() {
+		this.instanceRepo = new EventInstanceRepo();
+	},
+
+
+	tryReset: function() {
+		if (this.canTrigger()) {
+			this.triggerChangeset(new EventInstanceChangeset(
+				true, // isClear
+				null, // removals
+				this.instanceRepo // additions
+			));
+		}
+	},
+
+
+	// Reporting and Triggering
+	// -----------------------------------------------------------------------------------------------------------------
+
+
+	addChangeset: function(changeset) {
+		if (!this.outboundChangeset) {
+			this.outboundChangeset = new EventInstanceChangeset();
+		}
+
+		changeset.applyToChangeset(this.outboundChangeset);
+
+		this.trySendOutbound();
+	},
+
+
+	freeze: function() {
+		this.freezeDepth++;
+	},
+
+
+	thaw: function() {
+		this.freezeDepth--;
+		this.trySendOutbound();
+	},
+
+
+	trySendOutbound: function() { // also might apply outbound changes to INTERNAL data
+		var outboundChangeset = this.outboundChangeset;
+
+		if (this.canTrigger()) {
+			this.isPopulated = true; // event if empty result, consider populated
+
+			if (outboundChangeset) {
+				outboundChangeset.applyToRepo(this.instanceRepo); // finally internally record
+
+				this.outboundChangeset = null;
+				this.triggerChangeset(outboundChangeset);
+			}
+			else {
+				// hack for eventAfterAllRender
+				// also for DateComponents to know an empy, but populated, state
+				this.triggerChangeset(new EventInstanceChangeset());
+			}
+		}
+	},
+
+
+	canTrigger: function() {
+		return !this.freezeDepth;
+	},
+
+
+	triggerChangeset: function(changeset) {
+		this.trigger('before:receive');
+		this.trigger('receive', changeset);
+		this.trigger('after:receive');
+	}
+
+});

+ 0 - 85
src/models/EventPeriod.js

@@ -1,89 +1,4 @@
 
-var EventInstanceDataSource = Class.extend(EmitterMixin, {
-
-	instanceRepo: null,
-	freezeDepth: 0,
-	outboundChangeset: null,
-	isPopulated: false,
-
-
-	constructor: function() {
-		this.instanceRepo = new EventInstanceRepo();
-	},
-
-
-	tryReset: function() {
-		if (this.canTrigger()) {
-			this.triggerChangeset(new EventInstanceChangeset(
-				true, // isClear
-				null, // removals
-				this.instanceRepo // additions
-			));
-		}
-	},
-
-
-	// Reporting and Triggering
-	// -----------------------------------------------------------------------------------------------------------------
-
-
-	addChangeset: function(changeset) {
-		if (!this.outboundChangeset) {
-			this.outboundChangeset = new EventInstanceChangeset();
-		}
-
-		changeset.applyToChangeset(this.outboundChangeset);
-
-		this.trySendOutbound();
-	},
-
-
-	freeze: function() {
-		this.freezeDepth++;
-	},
-
-
-	thaw: function() {
-		this.freezeDepth--;
-		this.trySendOutbound();
-	},
-
-
-	trySendOutbound: function() { // also might apply outbound changes to INTERNAL data
-		var outboundChangeset = this.outboundChangeset;
-
-		if (this.canTrigger()) {
-			this.isPopulated = true; // event if empty result, consider populated
-
-			if (outboundChangeset) {
-				outboundChangeset.applyToRepo(this.instanceRepo); // finally internally record
-
-				this.outboundChangeset = null;
-				this.triggerChangeset(outboundChangeset);
-			}
-			else {
-				// hack for eventAfterAllRender
-				// also for DateComponents to know an empy, but populated, state
-				this.triggerChangeset(new EventInstanceChangeset());
-			}
-		}
-	},
-
-
-	canTrigger: function() {
-		return !this.freezeDepth;
-	},
-
-
-	triggerChangeset: function(changeset) {
-		this.trigger('before:receive');
-		this.trigger('receive', changeset);
-		this.trigger('after:receive');
-	}
-
-});
-
-
 var EventPeriod = EventInstanceDataSource.extend({
 
 	start: null,