Browse Source

Feature/Experimental/ Add more date ranges to pick from

- Add `Week to date` and `Month to date` to the list of possible
  date ranges to pick from.
- Instead of using toggle buttons, the date range is picked using
  a drop down selection.

Fixes #2903
pull/2905/head
Cédric Meuter 2 years ago
parent
commit
b4e700f30d
  1. 24
      libs/ui/src/lib/assistant/assistant.component.ts
  2. 17
      libs/ui/src/lib/assistant/assistant.html
  3. 5
      libs/ui/src/lib/assistant/assistant.module.ts

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

@ -17,7 +17,6 @@ import {
} from '@angular/core'; } from '@angular/core';
import { FormControl } from '@angular/forms'; import { FormControl } from '@angular/forms';
import { MatMenuTrigger } from '@angular/material/menu'; import { MatMenuTrigger } from '@angular/material/menu';
import { ToggleComponent } from '@ghostfolio/client/components/toggle/toggle.component';
import { AdminService } from '@ghostfolio/client/services/admin.service'; import { AdminService } from '@ghostfolio/client/services/admin.service';
import { DataService } from '@ghostfolio/client/services/data.service'; import { DataService } from '@ghostfolio/client/services/data.service';
import { User } from '@ghostfolio/common/interfaces'; import { User } from '@ghostfolio/common/interfaces';
@ -91,8 +90,26 @@ export class AssistantComponent implements OnChanges, OnDestroy, OnInit {
assistantListItems: QueryList<AssistantListItemComponent>; assistantListItems: QueryList<AssistantListItemComponent>;
public static readonly SEARCH_RESULTS_DEFAULT_LIMIT = 5; public static readonly SEARCH_RESULTS_DEFAULT_LIMIT = 5;
public dateRangeFormControl = new FormControl<string>(undefined);
public dateRangeOptions = ToggleComponent.DEFAULT_DATE_RANGE_OPTIONS;
public readonly dateRangeOptions = [
{ label: $localize`Today`, value: '1d' },
{
label: $localize`Week to date` + ' (' + $localize`WTD` + ')',
value: 'wtd'
},
{
label: $localize`Month to date` + ' (' + $localize`MTD` + ')',
value: 'mtd'
},
{
label: $localize`Year to date` + ' (' + $localize`YTD` + ')',
value: 'ytd'
},
{ label: $localize`1Y`, value: '1y' },
{ label: $localize`5Y`, value: '5y' },
{ label: $localize`Max`, value: 'max' }
];
public isLoading = false; public isLoading = false;
public isOpen = false; public isOpen = false;
public placeholder = $localize`Find holding...`; public placeholder = $localize`Find holding...`;
@ -163,6 +180,7 @@ export class AssistantComponent implements OnChanges, OnDestroy, OnInit {
} }
public ngOnChanges() { public ngOnChanges() {
this.dateRangeFormControl.setValue(this.user?.settings?.dateRange ?? null);
this.tagsFormControl.setValue( this.tagsFormControl.setValue(
this.user?.settings?.['filters.tags']?.[0] ?? null this.user?.settings?.['filters.tags']?.[0] ?? null
); );

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

@ -102,12 +102,17 @@
>Date Range</span >Date Range</span
></ng-template ></ng-template
> >
<div class="d-flex justify-content-center py-3"> <div class="p-3">
<gf-toggle <mat-form-field appearance="outline" class="w-100 without-hint">
[defaultValue]="user?.settings?.dateRange" <mat-select
[options]="dateRangeOptions" [formControl]="dateRangeFormControl"
(change)="onChangeDateRange($event.value)" (selectionChange)="onChangeDateRange($event.value)"
></gf-toggle> >
@for (range of dateRangeOptions; track range) {
<mat-option [value]="range.value">{{ range.label }}</mat-option>
}
</mat-select>
</mat-form-field>
</div> </div>
</mat-tab> </mat-tab>
<mat-tab> <mat-tab>

5
libs/ui/src/lib/assistant/assistant.module.ts

@ -11,6 +11,9 @@ import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader';
import { GfAssistantListItemModule } from './assistant-list-item/assistant-list-item.module'; import { GfAssistantListItemModule } from './assistant-list-item/assistant-list-item.module';
import { AssistantComponent } from './assistant.component'; import { AssistantComponent } from './assistant.component';
import { MatSelectModule } from '@angular/material/select';
import { MatFormFieldModule } from '@angular/material/form-field';
@NgModule({ @NgModule({
declarations: [AssistantComponent], declarations: [AssistantComponent],
exports: [AssistantComponent], exports: [AssistantComponent],
@ -20,7 +23,9 @@ import { AssistantComponent } from './assistant.component';
GfAssistantListItemModule, GfAssistantListItemModule,
GfToggleModule, GfToggleModule,
MatButtonModule, MatButtonModule,
MatFormFieldModule,
MatRadioModule, MatRadioModule,
MatSelectModule,
MatTabsModule, MatTabsModule,
NgxSkeletonLoaderModule, NgxSkeletonLoaderModule,
ReactiveFormsModule, ReactiveFormsModule,

Loading…
Cancel
Save