Browse Source

Fix Filter deletion

pull/5027/head
Dan 1 year ago
parent
commit
66d7d9e8f9
  1. 27
      apps/client/src/app/components/header/header.component.ts

27
apps/client/src/app/components/header/header.component.ts

@ -169,15 +169,7 @@ export class HeaderComponent implements OnChanges {
const userSetting: UpdateUserSettingDto = {}; const userSetting: UpdateUserSettingDto = {};
for (const filter of filters) { for (const filter of filters) {
let filtersType: string; let filtersType = this.getFilterType(filter.type);
if (filter.type === 'ACCOUNT') {
filtersType = 'accounts';
} else if (filter.type === 'ASSET_CLASS') {
filtersType = 'assetClasses';
} else if (filter.type === 'TAG') {
filtersType = 'tags';
}
let userFilters = filters let userFilters = filters
.filter((f) => f.type === filter.type && filter.id) .filter((f) => f.type === filter.type && filter.id)
@ -187,6 +179,14 @@ export class HeaderComponent implements OnChanges {
? userFilters ? userFilters
: null; : null;
} }
['ACCOUNT', 'ASSET_CLASS', 'TAG']
.filter(
(fitlerType) =>
!filters.some((f: Filter) => f.type.toString() === fitlerType)
)
.forEach((filterType) => {
userSetting[`filters.${this.getFilterType(filterType)}`] = null;
});
this.dataService this.dataService
.putUserSetting(userSetting) .putUserSetting(userSetting)
@ -269,4 +269,13 @@ export class HeaderComponent implements OnChanges {
this.unsubscribeSubject.next(); this.unsubscribeSubject.next();
this.unsubscribeSubject.complete(); this.unsubscribeSubject.complete();
} }
private getFilterType(filterType: string) {
if (filterType === 'ACCOUNT') {
return 'accounts';
} else if (filterType === 'ASSET_CLASS') {
return 'assetClasses';
} else if (filterType === 'TAG') {
return 'tags';
}
}
} }

Loading…
Cancel
Save