Просмотр исходного кода

business hours rendering again

Adam Shaw 8 лет назад
Родитель
Сommit
39acac122f
2 измененных файлов с 25 добавлено и 20 удалено
  1. 11 3
      src/View.js
  2. 14 17
      src/component/DateComponent.js

+ 11 - 3
src/View.js

@@ -856,10 +856,18 @@ View.watch('displayingDates', [ 'isInDom', 'dateProfile' ], function(deps) {
 });
 
 
-View.watch('displayingBusinessHours', [ 'displayingDates', 'businessHourGenerator' ], function() {
-	;
+View.watch('displayingBusinessHours', [ 'displayingDates', 'businessHourGenerator' ], function(deps) {
+	var _this = this;
+
+	this.requestRender(function() {
+		_this.renderBusinessHours(deps.businessHourGenerator);
+	}, 'businessHours', 'init');
 }, function() {
-	;
+	var _this = this;
+
+	this.requestRender(function() {
+		_this.unrenderBusinessHours();
+	}, 'businessHours', 'destroy');
 });
 
 

+ 14 - 17
src/component/DateComponent.js

@@ -172,31 +172,28 @@ var DateComponent = FC.DateComponent = Component.extend({
 	// ---------------------------------------------------------------------------------------------------------------
 
 
-	// Renders business-hours onto the view. Assumes updateSize has already been called.
-	renderBusinessHours: function(businessHourPayload) { // TODO: review payload
+	renderBusinessHours: function(businessHourGenerator) {
 		var unzonedRange = this.dateProfile.activeUnzonedRange;
-		var eventInstanceGroup = businessHourPayload[this.hasAllDayBusinessHours ? 'allDay' : 'timed'];
+		var eventInstanceGroup;
 		var eventFootprints;
 
-		if (eventInstanceGroup) {
-			eventFootprints = this.eventRangesToEventFootprints(
-				eventInstanceGroup.sliceRenderRanges(unzonedRange)
-			);
-		}
-		else {
-			eventFootprints = [];
-		}
-
-		this.renderBusinessHourEventFootprints(eventFootprints);
+		if (this.businessHourRenderer) {
 
-		this.callChildren('renderBusinessHours', arguments);
-	},
+			eventInstanceGroup = businessHourGenerator.buildEventInstanceGroup(
+				this.hasAllDayBusinessHours,
+				unzonedRange
+			);
 
+			eventFootprints = eventInstanceGroup ?
+				this.eventRangesToEventFootprints(
+					eventInstanceGroup.sliceRenderRanges(unzonedRange)
+				) :
+				[];
 
-	renderBusinessHourEventFootprints: function(eventFootprints) {
-		if (this.businessHourRenderer) {
 			this.businessHourRenderer.renderEventFootprints(eventFootprints);
 		}
+
+		this.callChildren('renderBusinessHours', arguments);
 	},