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. 35
      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
### 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/value` component to control flow
- Improved the language localization for Chinese (`zh`)

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

Loading…
Cancel
Save