From 04bf5580c8fff99bd484c3cd5a528262adf9fc22 Mon Sep 17 00:00:00 2001
From: nathangray <nathangray.bsc+github@gmail.com>
Date: Mon, 20 Apr 2020 12:00:42 -0600
Subject: [PATCH] * Calendar: Fix events later in the day would not show if one
 was filtered out

---
 calendar/js/et2_widget_daycol.js | 3 ++-
 calendar/js/et2_widget_daycol.ts | 3 ++-
 calendar/js/et2_widget_event.js  | 4 ++++
 calendar/js/et2_widget_event.ts  | 5 +++++
 4 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/calendar/js/et2_widget_daycol.js b/calendar/js/et2_widget_daycol.js
index 734d5e520b..77102101cf 100644
--- a/calendar/js/et2_widget_daycol.js
+++ b/calendar/js/et2_widget_daycol.js
@@ -470,7 +470,8 @@ var et2_calendar_daycol = /** @class */ (function (_super) {
             }, this);
         }
         // Seperate loop so column sorting finds all children in the right place
-        for (c = 0; c < events.length && c < this._children.length; c++) {
+        var child_length = this._children.length;
+        for (c = 0; c < events.length && c < child_length; c++) {
             var event_2 = this.getWidgetById('event_' + events[c].id);
             if (!event_2)
                 continue;
diff --git a/calendar/js/et2_widget_daycol.ts b/calendar/js/et2_widget_daycol.ts
index 5ea852bdde..5957cada4d 100644
--- a/calendar/js/et2_widget_daycol.ts
+++ b/calendar/js/et2_widget_daycol.ts
@@ -605,7 +605,8 @@ export class et2_calendar_daycol extends et2_valueWidget implements et2_IDetache
 		}
 
 		// Seperate loop so column sorting finds all children in the right place
-		for(c = 0; c < events.length && c < this._children.length; c++)
+		let child_length = this._children.length;
+		for(c = 0; c < events.length && c < child_length; c++)
 		{
 			let event = this.getWidgetById('event_'+events[c].id);
 			if(!event) continue;
diff --git a/calendar/js/et2_widget_event.js b/calendar/js/et2_widget_event.js
index 9303d9af7a..071877ba8b 100644
--- a/calendar/js/et2_widget_event.js
+++ b/calendar/js/et2_widget_event.js
@@ -171,6 +171,9 @@ var et2_calendar_event = /** @class */ (function (_super) {
         var value = event === null ? null : jQuery.extend({}, event);
         var parent = this.getParent();
         var parent_owner = parent.getDOMNode(parent).dataset['owner'] || parent.getParent().options.owner;
+        if (parent_owner.indexOf(',')) {
+            parent_owner = parent_owner.split(',');
+        }
         // Make sure id is a string, check values
         if (value) {
             this._values_check(value);
@@ -912,6 +915,7 @@ var et2_calendar_event = /** @class */ (function (_super) {
                     var resource = options.find(function (element) { return element.id == parent_owner[i]; }) || {};
                     if (resource && resource.resources) {
                         parent_owner.splice(i, 1);
+                        i--;
                         parent_owner = parent_owner.concat(resource.resources);
                     }
                 }
diff --git a/calendar/js/et2_widget_event.ts b/calendar/js/et2_widget_event.ts
index bc9e5e26dd..30be710b0f 100644
--- a/calendar/js/et2_widget_event.ts
+++ b/calendar/js/et2_widget_event.ts
@@ -211,6 +211,10 @@ export class et2_calendar_event extends et2_valueWidget implements et2_IDetached
 		const value = event === null ? null : jQuery.extend({}, event);
 		let parent = <et2_DOMWidget>this.getParent();
 		let parent_owner = parent.getDOMNode(parent).dataset['owner'] || parent.getParent().options.owner;
+		if(parent_owner.indexOf(','))
+		{
+			parent_owner = parent_owner.split(',');
+		}
 
 		// Make sure id is a string, check values
 		if(value)
@@ -1170,6 +1174,7 @@ export class et2_calendar_event extends et2_valueWidget implements et2_IDetached
 					if(resource && resource.resources)
 					{
 						parent_owner.splice(i,1);
+						i--;
 						parent_owner = parent_owner.concat(resource.resources);
 
 					}