Calendar: fix 'owner too' filter did not show when displaying a group and the event was owned by a group member who was not participating

This commit is contained in:
nathangray 2020-04-23 14:15:08 -06:00
parent eaafd5eb1f
commit c72bd74884
2 changed files with 18 additions and 6 deletions

View File

@ -684,9 +684,11 @@ var et2_calendar_event = /** @class */ (function (_super) {
*
* @param event
* @param filter
* @param owner The owner of the target / parent, not the event owner
* @private
*/
et2_calendar_event.prototype._status_check = function (event, filter, owner) {
var _a;
if (!owner || !event) {
return false;
}
@ -717,12 +719,16 @@ 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;
return element.id == owner && element.resources;
}) || {};
if (resource && resource.resources) {
var matching_participant = resource.resources.filter(function (id) { return typeof event.participants[id] != "undefined"; });
var matching_participant = (_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);
}
else if (filter == 'owner' && resource && resource.resources.indexOf(event.owner)) {
// owner param was a group but event is owned by someone in that group
return true;
}
}
}
var status = et2_calendar_event.split_status(participant);

View File

@ -881,6 +881,7 @@ export class et2_calendar_event extends et2_valueWidget implements et2_IDetached
*
* @param event
* @param filter
* @param owner The owner of the target / parent, not the event owner
* @private
*/
_status_check(event, filter: string, owner: string | string[]): boolean
@ -929,13 +930,18 @@ export class et2_calendar_event extends et2_valueWidget implements et2_IDetached
{
let resource = options.find(function (element)
{
return element.id == owner;
return element.id == owner && element.resources;
}) || {};
if(resource && resource.resources)
let matching_participant = resource?.resources.filter(id => typeof event.participants[id] != "undefined");
if(matching_participant.length > 0)
{
let matching_participant = resource.resources.filter(id => typeof event.participants[id] != "undefined");
return this._status_check(event, filter, matching_participant);
}
else if (filter == 'owner' && resource && resource.resources.indexOf(event.owner))
{
// owner param was a group but event is owned by someone in that group
return true;
}
}
}