Browse Source

Feature/consider availability of date range selector and filters in assistant per view (#3824)

* Consider availability of date range selector and filters in assistant per view

* Update changelog
pull/3837/head
Thomas Kaul 7 days ago
committed by GitHub
parent
commit
e8f0d2bb14
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 2
      CHANGELOG.md
  2. 2
      apps/client/src/app/app.component.html
  3. 34
      apps/client/src/app/app.component.ts
  4. 4
      apps/client/src/app/components/header/header.component.html
  5. 4
      apps/client/src/app/components/header/header.component.ts
  6. 14
      libs/ui/src/lib/assistant/assistant.component.ts
  7. 6
      libs/ui/src/lib/assistant/assistant.html

2
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`)

2
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"

34
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

4
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)"

4
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();
}
}

14
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<void>();
@ -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,

6
libs/ui/src/lib/assistant/assistant.html

@ -150,7 +150,9 @@
<button
i18n
mat-button
[disabled]="!hasFilter(filterForm.value)"
[disabled]="
!hasFilter(filterForm.value) || !hasPermissionToChangeFilters
"
(click)="onResetFilters()"
>
Reset Filters
@ -160,7 +162,7 @@
color="primary"
i18n
mat-flat-button
[disabled]="!filterForm.dirty"
[disabled]="!filterForm.dirty || !hasPermissionToChangeFilters"
(click)="onApplyFilters()"
>
Apply Filters

Loading…
Cancel
Save