diff --git a/CHANGELOG.md b/CHANGELOG.md index 69be6319b..2a3283f75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- Considered the availability of the date range selector in the assistant per view +- Considered the availability of the filters in the assistant per view - Optimized the portfolio calculations with smarter cloning of activities - Integrated the add currency functionality into the market data section of the admin control panel - Improved the language localization for German (`de`) diff --git a/apps/client/src/app/app.component.html b/apps/client/src/app/app.component.html index db6a00e7b..ff21a229d 100644 --- a/apps/client/src/app/app.component.html +++ b/apps/client/src/app/app.component.html @@ -31,6 +31,8 @@ class="position-fixed w-100" [currentRoute]="currentRoute" [deviceType]="deviceType" + [hasPermissionToChangeDateRange]="hasPermissionToChangeDateRange" + [hasPermissionToChangeFilters]="hasPermissionToChangeFilters" [hasTabs]="hasTabs" [info]="info" [pageTitle]="pageTitle" diff --git a/apps/client/src/app/app.component.ts b/apps/client/src/app/app.component.ts index 44a554173..eed29a757 100644 --- a/apps/client/src/app/app.component.ts +++ b/apps/client/src/app/app.component.ts @@ -47,6 +47,7 @@ export class AppComponent implements OnDestroy, OnInit { public canCreateAccount: boolean; public currentRoute: string; + public currentSubRoute: string; public currentYear = new Date().getFullYear(); public deviceType: string; public hasImpersonationId: boolean; @@ -54,6 +55,8 @@ export class AppComponent implements OnDestroy, OnInit { public hasPermissionForStatistics: boolean; public hasPermissionForSubscription: boolean; public hasPermissionToAccessFearAndGreedIndex: boolean; + public hasPermissionToChangeDateRange: boolean; + public hasPermissionToChangeFilters: boolean; public hasTabs = false; public info: InfoItem; public pageTitle: string; @@ -147,6 +150,35 @@ export class AppComponent implements OnDestroy, OnInit { const urlSegmentGroup = urlTree.root.children[PRIMARY_OUTLET]; const urlSegments = urlSegmentGroup.segments; this.currentRoute = urlSegments[0].path; + this.currentSubRoute = urlSegments[1]?.path; + + if ( + (this.currentRoute === 'home' && !this.currentSubRoute) || + (this.currentRoute === 'home' && + this.currentSubRoute === 'holdings') || + (this.currentRoute === 'portfolio' && !this.currentSubRoute) || + (this.currentRoute === 'zen' && !this.currentSubRoute) || + (this.currentRoute === 'zen' && this.currentSubRoute === 'holdings') + ) { + this.hasPermissionToChangeDateRange = true; + } else { + this.hasPermissionToChangeDateRange = false; + } + + if ( + (this.currentRoute === 'home' && + this.currentSubRoute === 'holdings') || + (this.currentRoute === 'portfolio' && !this.currentSubRoute) || + (this.currentRoute === 'portfolio' && + this.currentSubRoute === 'activities') || + (this.currentRoute === 'portfolio' && + this.currentSubRoute === 'allocations') || + (this.currentRoute === 'zen' && this.currentSubRoute === 'holdings') + ) { + this.hasPermissionToChangeFilters = true; + } else { + this.hasPermissionToChangeFilters = false; + } this.hasTabs = (this.currentRoute === this.routerLinkAbout[0].slice(1) || @@ -182,6 +214,8 @@ export class AppComponent implements OnDestroy, OnInit { this.changeDetectorRef.markForCheck(); }); } + + this.changeDetectorRef.markForCheck(); }); this.userService.stateChanged diff --git a/apps/client/src/app/components/header/header.component.html b/apps/client/src/app/components/header/header.component.html index b545c40aa..2e9c03122 100644 --- a/apps/client/src/app/components/header/header.component.html +++ b/apps/client/src/app/components/header/header.component.html @@ -121,7 +121,7 @@ matBadge="✓" matBadgeSize="small" [mat-menu-trigger-for]="assistantMenu" - [matBadgeHidden]="!hasFilters" + [matBadgeHidden]="!hasFilters || !hasPermissionToChangeFilters" [matMenuTriggerRestoreFocus]="false" (menuOpened)="onOpenAssistant()" > @@ -140,6 +140,8 @@ [hasPermissionToAccessAdminControl]=" hasPermissionToAccessAdminControl " + [hasPermissionToChangeDateRange]="hasPermissionToChangeDateRange" + [hasPermissionToChangeFilters]="hasPermissionToChangeFilters" [user]="user" (closed)="closeAssistant()" (dateRangeChanged)="onDateRangeChange($event)" diff --git a/apps/client/src/app/components/header/header.component.ts b/apps/client/src/app/components/header/header.component.ts index 8909c15a4..be90fbc8e 100644 --- a/apps/client/src/app/components/header/header.component.ts +++ b/apps/client/src/app/components/header/header.component.ts @@ -56,6 +56,8 @@ export class HeaderComponent implements OnChanges { @Input() currentRoute: string; @Input() deviceType: string; + @Input() hasPermissionToChangeDateRange: boolean; + @Input() hasPermissionToChangeFilters: boolean; @Input() hasTabs: boolean; @Input() info: InfoItem; @Input() pageTitle: string; @@ -197,7 +199,7 @@ export class HeaderComponent implements OnChanges { } public onLogoClick() { - if (this.currentRoute === 'home' || this.currentRoute === 'zen') { + if (['home', 'zen'].includes(this.currentRoute)) { this.layoutService.getShouldReloadSubject().next(); } } diff --git a/libs/ui/src/lib/assistant/assistant.component.ts b/libs/ui/src/lib/assistant/assistant.component.ts index fea32d255..1da5e682e 100644 --- a/libs/ui/src/lib/assistant/assistant.component.ts +++ b/libs/ui/src/lib/assistant/assistant.component.ts @@ -110,6 +110,8 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { @Input() deviceType: string; @Input() hasPermissionToAccessAdminControl: boolean; + @Input() hasPermissionToChangeDateRange: boolean; + @Input() hasPermissionToChangeFilters: boolean; @Input() user: User; @Output() closed = new EventEmitter(); @@ -254,8 +256,20 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { { label: $localize`Max`, value: 'max' } ]); + this.dateRangeFormControl.disable({ emitEvent: false }); + + if (this.hasPermissionToChangeDateRange) { + this.dateRangeFormControl.enable({ emitEvent: false }); + } + this.dateRangeFormControl.setValue(this.user?.settings?.dateRange ?? null); + this.filterForm.disable({ emitEvent: false }); + + if (this.hasPermissionToChangeFilters) { + this.filterForm.enable({ emitEvent: false }); + } + this.filterForm.setValue( { account: this.user?.settings?.['filters.accounts']?.[0] ?? null, diff --git a/libs/ui/src/lib/assistant/assistant.html b/libs/ui/src/lib/assistant/assistant.html index 76808cf37..648c791ab 100644 --- a/libs/ui/src/lib/assistant/assistant.html +++ b/libs/ui/src/lib/assistant/assistant.html @@ -150,7 +150,9 @@