Browse Source

Feature/conditionally display date range options based on first user activity (#4945)

* Conditionally display date range options based on first user activity

* Update changelog
pull/4952/head
Tahbit Fehran 2 weeks ago
committed by GitHub
parent
commit
b0e1065f79
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 3
      CHANGELOG.md
  2. 37
      libs/ui/src/lib/assistant/assistant.component.ts

3
CHANGELOG.md

@ -7,8 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased ## Unreleased
### Changelog ### Changed
- Adapted the options of the date range selector in the assistant dynamically based on the user’s first activity
- Migrated the `@ghostfolio/ui/assistant` component to control flow - Migrated the `@ghostfolio/ui/assistant` component to control flow
- Migrated the `@ghostfolio/ui/value` component to control flow - Migrated the `@ghostfolio/ui/value` component to control flow
- Improved the language localization for Chinese (`zh`) - Improved the language localization for Chinese (`zh`)

37
libs/ui/src/lib/assistant/assistant.component.ts

@ -40,6 +40,7 @@ import { MatMenuTrigger } from '@angular/material/menu';
import { MatSelectModule } from '@angular/material/select'; import { MatSelectModule } from '@angular/material/select';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
import { Account, AssetClass, DataSource } from '@prisma/client'; import { Account, AssetClass, DataSource } from '@prisma/client';
import { differenceInYears } from 'date-fns';
import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader';
import { EMPTY, Observable, Subject, merge, of } from 'rxjs'; import { EMPTY, Observable, Subject, merge, of } from 'rxjs';
import { import {
@ -333,7 +334,10 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit {
this.accounts = this.user?.accounts ?? []; this.accounts = this.user?.accounts ?? [];
this.dateRangeOptions = [ this.dateRangeOptions = [
{ label: $localize`Today`, value: '1d' }, {
label: $localize`Today`,
value: '1d'
},
{ {
label: $localize`Week to date` + ' (' + $localize`WTD` + ')', label: $localize`Week to date` + ' (' + $localize`WTD` + ')',
value: 'wtd' value: 'wtd'
@ -345,13 +349,19 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit {
{ {
label: $localize`Year to date` + ' (' + $localize`YTD` + ')', label: $localize`Year to date` + ' (' + $localize`YTD` + ')',
value: 'ytd' value: 'ytd'
},
{
label: '1 ' + $localize`year` + ' (' + $localize`1Y` + ')',
value: '1y'
} }
]; ];
if (
this.user?.dateOfFirstActivity &&
differenceInYears(new Date(), this.user.dateOfFirstActivity) >= 1
) {
this.dateRangeOptions.push({
label: '1 ' + $localize`year` + ' (' + $localize`1Y` + ')',
value: '1y'
});
}
// TODO // TODO
// if (this.user?.settings?.isExperimentalFeatures) { // if (this.user?.settings?.isExperimentalFeatures) {
// this.dateRangeOptions = this.dateRangeOptions.concat( // this.dateRangeOptions = this.dateRangeOptions.concat(
@ -367,13 +377,20 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit {
// ); // );
// } // }
this.dateRangeOptions = this.dateRangeOptions.concat([ if (
{ this.user?.dateOfFirstActivity &&
differenceInYears(new Date(), this.user.dateOfFirstActivity) >= 5
) {
this.dateRangeOptions.push({
label: '5 ' + $localize`years` + ' (' + $localize`5Y` + ')', label: '5 ' + $localize`years` + ' (' + $localize`5Y` + ')',
value: '5y' value: '5y'
}, });
{ label: $localize`Max`, value: 'max' } }
]);
this.dateRangeOptions.push({
label: $localize`Max`,
value: 'max'
});
this.dateRangeFormControl.disable({ emitEvent: false }); this.dateRangeFormControl.disable({ emitEvent: false });

Loading…
Cancel
Save