Browse Source

Holdings as default options in create or update activity dialog

pull/4892/head
csehatt741 3 weeks ago
committed by Thomas Kaul
parent
commit
9689546c5f
  1. 1
      CHANGELOG.md
  2. 31
      apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.component.ts
  3. 1
      apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.html
  4. 11
      libs/ui/src/lib/symbol-autocomplete/symbol-autocomplete.component.ts

1
CHANGELOG.md

@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Included quick links in the search results of the assistant - Included quick links in the search results of the assistant
- Added a skeleton loader to the changelog page - Added a skeleton loader to the changelog page
- Extended the content of the _Self-Hosting_ section by information about additional data providers on the Frequently Asked Questions (FAQ) page - Extended the content of the _Self-Hosting_ section by information about additional data providers on the Frequently Asked Questions (FAQ) page
- Enhanced the create or update activity dialog to display the current holdings as default options
### Changed ### Changed

31
apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.component.ts

@ -2,6 +2,7 @@ import { CreateOrderDto } from '@ghostfolio/api/app/order/create-order.dto';
import { UpdateOrderDto } from '@ghostfolio/api/app/order/update-order.dto'; import { UpdateOrderDto } from '@ghostfolio/api/app/order/update-order.dto';
import { UserService } from '@ghostfolio/client/services/user/user.service'; import { UserService } from '@ghostfolio/client/services/user/user.service';
import { getDateFormatString } from '@ghostfolio/common/helper'; import { getDateFormatString } from '@ghostfolio/common/helper';
import { LookupItem } from '@ghostfolio/common/interfaces';
import { hasPermission, permissions } from '@ghostfolio/common/permissions'; import { hasPermission, permissions } from '@ghostfolio/common/permissions';
import { translate } from '@ghostfolio/ui/i18n'; import { translate } from '@ghostfolio/ui/i18n';
@ -44,6 +45,7 @@ export class CreateOrUpdateActivityDialog implements OnDestroy {
public currencyOfAssetProfile: string; public currencyOfAssetProfile: string;
public currentMarketPrice = null; public currentMarketPrice = null;
public defaultDateFormat: string; public defaultDateFormat: string;
public defaultLookupItems: LookupItem[] = [];
public hasPermissionToCreateOwnTag: boolean; public hasPermissionToCreateOwnTag: boolean;
public isLoading = false; public isLoading = false;
public isToday = isToday; public isToday = isToday;
@ -83,6 +85,35 @@ export class CreateOrUpdateActivityDialog implements OnDestroy {
this.defaultDateFormat = getDateFormatString(this.locale); this.defaultDateFormat = getDateFormatString(this.locale);
this.platforms = platforms; this.platforms = platforms;
this.dataService
.fetchPortfolioHoldings()
.pipe(takeUntil(this.unsubscribeSubject))
.subscribe(({ holdings }) => {
this.defaultLookupItems = holdings
.filter(({ assetSubClass }) => {
return !['CASH'].includes(assetSubClass);
})
.sort((a, b) => {
return a.name?.localeCompare(b.name);
})
.map((holding) => {
return {
assetClass: holding.assetClass,
assetSubClass: holding.assetSubClass,
currency: holding.currency,
dataProviderInfo: {
dataSource: holding.dataSource,
isPremium: false,
name: holding.name,
url: holding.url
},
dataSource: holding.dataSource,
name: holding.name,
symbol: holding.symbol
};
});
});
this.tagsAvailable = this.tagsAvailable =
this.data.user?.tags?.map((tag) => { this.data.user?.tags?.map((tag) => {
return { return {

1
apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.html

@ -124,6 +124,7 @@
<mat-label i18n>Name, symbol or ISIN</mat-label> <mat-label i18n>Name, symbol or ISIN</mat-label>
<gf-symbol-autocomplete <gf-symbol-autocomplete
formControlName="searchSymbol" formControlName="searchSymbol"
[defaultLookupItems]="defaultLookupItems"
[isLoading]="isLoading" [isLoading]="isLoading"
/> />
</mat-form-field> </mat-form-field>

11
libs/ui/src/lib/symbol-autocomplete/symbol-autocomplete.component.ts

@ -14,6 +14,7 @@ import {
Input, Input,
OnDestroy, OnDestroy,
OnInit, OnInit,
SimpleChanges,
ViewChild ViewChild
} from '@angular/core'; } from '@angular/core';
import { import {
@ -107,10 +108,6 @@ export class GfSymbolAutocompleteComponent
this.control.disable(); this.control.disable();
} }
if (this.defaultLookupItems?.length) {
this.showDefaultOptions();
}
this.control.valueChanges this.control.valueChanges
.pipe(takeUntil(this.unsubscribeSubject)) .pipe(takeUntil(this.unsubscribeSubject))
.subscribe(() => { .subscribe(() => {
@ -159,6 +156,12 @@ export class GfSymbolAutocompleteComponent
}); });
} }
public ngOnChanges(changes: SimpleChanges) {
if (changes['defaultLookupItems'] && this.defaultLookupItems?.length) {
this.showDefaultOptions();
}
}
public displayFn(aLookupItem: LookupItem) { public displayFn(aLookupItem: LookupItem) {
return aLookupItem?.symbol ?? ''; return aLookupItem?.symbol ?? '';
} }

Loading…
Cancel
Save