From 4d6a2cf1b1bfdcb741fadd87055963372bcd030e Mon Sep 17 00:00:00 2001 From: nathangray Date: Wed, 6 May 2020 11:00:47 -0600 Subject: [PATCH] Calendar: Fix some client side filter bugs - Resources that weren't the first selected were not displayed properly - Selecting a group via ajax under certain conditions would not display its events --- calendar/inc/class.calendar_owner_etemplate_widget.inc.php | 4 ++-- calendar/js/et2_widget_event.js | 5 +++-- calendar/js/et2_widget_event.ts | 6 ++++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/calendar/inc/class.calendar_owner_etemplate_widget.inc.php b/calendar/inc/class.calendar_owner_etemplate_widget.inc.php index c9e671f9ac..a644811acf 100644 --- a/calendar/inc/class.calendar_owner_etemplate_widget.inc.php +++ b/calendar/inc/class.calendar_owner_etemplate_widget.inc.php @@ -206,7 +206,7 @@ class calendar_owner_etemplate_widget extends Etemplate\Widget\Taglist ); foreach($lists as $list_id => $list) { - $_results[$list_id] = array( + $_results[''+$list_id] = array( 'label' => $list, 'resources' => $bo->enum_mailing_list($type.$list_id) ); @@ -247,7 +247,7 @@ class calendar_owner_etemplate_widget extends Etemplate\Widget\Taglist )); if($id < 0) { - $value['resources'] = $GLOBALS['egw']->accounts->members($id, true); + $value['resources'] = array_map('strval',$GLOBALS['egw']->accounts->members($id, true)); } break; default : diff --git a/calendar/js/et2_widget_event.js b/calendar/js/et2_widget_event.js index 2f487819a4..388832adbe 100644 --- a/calendar/js/et2_widget_event.js +++ b/calendar/js/et2_widget_event.js @@ -748,9 +748,10 @@ var et2_calendar_event = /** @class */ (function (_super) { } if ((isNaN(parseInt(owner)) || parseInt(owner) < 0) && options && typeof options.find == "function") { var resource = options.find(function (element) { - return element.id == owner && element.resources; + return element.id == owner; }) || {}; - var matching_participant = (_a = resource) === null || _a === void 0 ? void 0 : _a.resources.filter(function (id) { return typeof event.participants[id] != "undefined"; }); + var matching_participant = typeof resource.resources == "undefined" ? + resource : (_a = resource) === null || _a === void 0 ? void 0 : _a.resources.filter(function (id) { return typeof event.participants[id] != "undefined"; }); if (matching_participant.length > 0) { return this._status_check(event, filter, matching_participant); } diff --git a/calendar/js/et2_widget_event.ts b/calendar/js/et2_widget_event.ts index 0c6c0b66b9..3c45e634be 100644 --- a/calendar/js/et2_widget_event.ts +++ b/calendar/js/et2_widget_event.ts @@ -965,9 +965,11 @@ export class et2_calendar_event extends et2_valueWidget implements et2_IDetached { let resource = options.find(function (element) { - return element.id == owner && element.resources; + return element.id == owner; }) || {}; - let matching_participant = resource?.resources.filter(id => typeof event.participants[id] != "undefined"); + let matching_participant = typeof resource.resources == "undefined" ? + resource : + resource?.resources.filter(id => typeof event.participants[id] != "undefined"); if(matching_participant.length > 0) { return this._status_check(event, filter, matching_participant);