From d8b4baab1128841b3b878eefdd40f09ad21676cb Mon Sep 17 00:00:00 2001 From: Dirk Peter Date: Mon, 2 Sep 2024 10:55:08 +0200 Subject: [PATCH] fixes issues when no type config is set --- .../components/reminder-drawer/reminder-drawer.component.ts | 3 ++- src/app/reminder-plugin/services/reminder.service.ts | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/app/reminder-plugin/components/reminder-drawer/reminder-drawer.component.ts b/src/app/reminder-plugin/components/reminder-drawer/reminder-drawer.component.ts index 2f5c5fc..cd2e25e 100644 --- a/src/app/reminder-plugin/components/reminder-drawer/reminder-drawer.component.ts +++ b/src/app/reminder-plugin/components/reminder-drawer/reminder-drawer.component.ts @@ -1,5 +1,6 @@ import { Component, OnDestroy } from '@angular/core'; import { AlertService, HeaderService } from '@c8y/ngx-components'; +import { has } from 'lodash'; import { BsModalService } from 'ngx-bootstrap/modal'; import { BehaviorSubject, Subscription } from 'rxjs'; import { @@ -132,7 +133,7 @@ export class ReminderDrawerComponent implements OnDestroy { } private handleConfigChange(config: ReminderConfig): void { - if (this.reminderTypeFilter !== config.filter?.reminderType) { + if (has(config.filter, 'remidnerType') && this.reminderTypeFilter !== config.filter?.reminderType) { this.reminderTypeFilter = config.filter.reminderType; this.filterByType(); } diff --git a/src/app/reminder-plugin/services/reminder.service.ts b/src/app/reminder-plugin/services/reminder.service.ts index 5542d94..9a35ee0 100644 --- a/src/app/reminder-plugin/services/reminder.service.ts +++ b/src/app/reminder-plugin/services/reminder.service.ts @@ -214,7 +214,8 @@ export class ReminderService { const config = this.config$.getValue(); // populate filters - filters[REMINDER_TYPE_FRAGMENT] = config.filter[REMINDER_TYPE_FRAGMENT]; + if (has(config.filter, 'remidnerType')) + filters[REMINDER_TYPE_FRAGMENT] = config.filter[REMINDER_TYPE_FRAGMENT]; return Object.keys(filters).length > 0 ? filters : null; } @@ -387,7 +388,8 @@ export class ReminderService { const filter = this.buildTypeFilter(); this.setConfig('filter', filter); - if (filter[REMINDER_TYPE_FRAGMENT] === '') return groups; + const config = this.config$.getValue(); + if (!has(config.filter, 'remidnerType') || filter[REMINDER_TYPE_FRAGMENT] === '') return groups; const keys = Object.keys(filter); if (!keys.length) return groups;