Browse Source

feat(lib): resolve comments

pull/4870/head
KenTandrian 3 weeks ago
parent
commit
52ba57b408
  1. 9
      libs/ui/src/lib/assistant/assistant-list-item/assistant-list-item.component.ts
  2. 2
      libs/ui/src/lib/assistant/assistant-list-item/assistant-list-item.html
  3. 40
      libs/ui/src/lib/assistant/assistant.component.ts
  4. 35
      libs/ui/src/lib/assistant/assistant.html
  5. 10
      libs/ui/src/lib/assistant/interfaces/interfaces.ts

9
libs/ui/src/lib/assistant/assistant-list-item/assistant-list-item.component.ts

@ -74,11 +74,12 @@ export class GfAssistantListItemComponent
this.changeDetectorRef.markForCheck();
}
public isAssetProfileOrHoldingItem(
item: ISearchResultItem
): item is IAssetSearchResultItem {
public isAsset(item: ISearchResultItem): item is IAssetSearchResultItem {
return (
item.mode === SearchMode.ASSET_PROFILE || item.mode === SearchMode.HOLDING
(item.mode === SearchMode.ASSET_PROFILE ||
item.mode === SearchMode.HOLDING) &&
!!item.dataSource &&
!!item.symbol
);
}

2
libs/ui/src/lib/assistant/assistant-list-item/assistant-list-item.html

@ -7,7 +7,7 @@
><span
><b>{{ item?.name }}</b></span
>
@if (item && isAssetProfileOrHoldingItem(item)) {
@if (item && isAsset(item)) {
<br />
<small class="text-muted"
>{{ item?.symbol | gfSymbol }} · {{ item?.currency }}

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

@ -210,6 +210,7 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit {
holdings: [],
quickLinks: []
} as ISearchResults;
if (!searchTerm) {
return of(results).pipe(
tap(() => {
@ -222,17 +223,6 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit {
);
}
// QuickLinks
const quickLinksData = this.searchQuickLinks(searchTerm);
const quickLinks$: Observable<Partial<ISearchResults>> = of({
quickLinks: quickLinksData
}).pipe(
tap(() => {
this.isLoading.quickLinks = false;
this.changeDetectorRef.markForCheck();
})
);
// Asset Profiles
const assetProfiles$: Observable<Partial<ISearchResults>> = this
.hasPermissionToAccessAdminControl
@ -280,6 +270,18 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit {
this.changeDetectorRef.markForCheck();
})
);
// QuickLinks
const quickLinksData = this.searchQuickLinks(searchTerm);
const quickLinks$: Observable<Partial<ISearchResults>> = of({
quickLinks: quickLinksData
}).pipe(
tap(() => {
this.isLoading.quickLinks = false;
this.changeDetectorRef.markForCheck();
})
);
// Merge all results
return merge(quickLinks$, assetProfiles$, holdings$).pipe(
scan(
@ -599,11 +601,11 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit {
}
private searchQuickLinks(aSearchTerm: string): ISearchResultItem[] {
const term = aSearchTerm.toLowerCase();
const searchTerm = aSearchTerm.toLowerCase();
const allRoutes = Object.values(internalRoutes)
.filter((route) => {
return !route.excludeFromAssistant;
.filter(({ excludeFromAssistant }) => {
return !excludeFromAssistant;
})
.reduce((acc, route) => {
acc.push(route);
@ -614,14 +616,14 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit {
}, [] as IRoute[]);
return allRoutes
.filter((route) => {
return route.title.toLowerCase().includes(term);
.filter(({ title }) => {
return title.toLowerCase().includes(searchTerm);
})
.map((route) => {
.map(({ routerLink, title }) => {
return {
routerLink,
mode: SearchMode.QUICK_LINK as const,
name: route.title,
routerLink: route.routerLink
name: title
};
})
.sort((a, b) => {

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

@ -40,15 +40,18 @@
*ngIf="searchFormControl.value"
class="overflow-auto py-3 result-container"
>
<div>
<div class="h6 mb-1 px-2" i18n>Holdings</div>
<div
*ngIf="searchResults?.quickLinks?.length !== 0 || isLoading.quickLinks"
class="mb-3"
>
<div class="h6 mb-1 px-2" i18n>Quick Links</div>
<gf-assistant-list-item
*ngFor="let searchResultItem of searchResults?.holdings"
*ngFor="let searchResultItem of searchResults?.quickLinks"
[item]="searchResultItem"
(clicked)="onCloseAssistant()"
/>
<ng-container *ngIf="searchResults?.holdings?.length === 0">
@if (isLoading.holdings) {
<ng-container>
@if (isLoading.quickLinks) {
<ngx-skeleton-loader
animation="pulse"
class="mx-2"
@ -57,20 +60,18 @@
width: '100%'
}"
/>
} @else {
<div class="px-2 py-1" i18n>No entries...</div>
}
</ng-container>
</div>
<div *ngIf="hasPermissionToAccessAdminControl" class="mt-3">
<div class="h6 mb-1 px-2" i18n>Asset Profiles</div>
<div>
<div class="h6 mb-1 px-2" i18n>Holdings</div>
<gf-assistant-list-item
*ngFor="let searchResultItem of searchResults?.assetProfiles"
*ngFor="let searchResultItem of searchResults?.holdings"
[item]="searchResultItem"
(clicked)="onCloseAssistant()"
/>
<ng-container *ngIf="searchResults?.assetProfiles?.length === 0">
@if (isLoading.assetProfiles) {
<ng-container *ngIf="searchResults?.holdings?.length === 0">
@if (isLoading.holdings) {
<ngx-skeleton-loader
animation="pulse"
class="mx-2"
@ -84,15 +85,15 @@
}
</ng-container>
</div>
<div class="mt-3">
<div class="h6 mb-1 px-2" i18n>Quick Links</div>
<div *ngIf="hasPermissionToAccessAdminControl" class="mt-3">
<div class="h6 mb-1 px-2" i18n>Asset Profiles</div>
<gf-assistant-list-item
*ngFor="let searchResultItem of searchResults?.quickLinks"
*ngFor="let searchResultItem of searchResults?.assetProfiles"
[item]="searchResultItem"
(clicked)="onCloseAssistant()"
/>
<ng-container *ngIf="searchResults?.quickLinks?.length === 0">
@if (isLoading.quickLinks) {
<ng-container *ngIf="searchResults?.assetProfiles?.length === 0">
@if (isLoading.assetProfiles) {
<ngx-skeleton-loader
animation="pulse"
class="mx-2"

10
libs/ui/src/lib/assistant/interfaces/interfaces.ts

@ -3,11 +3,6 @@ import { DateRange } from '@ghostfolio/common/types';
import { SearchMode } from '../enums/search-mode';
export interface IDateRangeOption {
label: string;
value: DateRange;
}
export interface IAssetSearchResultItem extends AssetProfileIdentifier {
assetSubClassString: string;
currency: string;
@ -15,6 +10,11 @@ export interface IAssetSearchResultItem extends AssetProfileIdentifier {
name: string;
}
export interface IDateRangeOption {
label: string;
value: DateRange;
}
export interface IQuickLinkSearchResultItem {
mode: SearchMode.QUICK_LINK;
name: string;

Loading…
Cancel
Save