Browse Source

Respect watchedByCount in delete asset profile checkbox

pull/4609/head
Thomas Kaul 4 months ago
parent
commit
2fa2c46754
  1. 12
      apps/api/src/app/admin/admin.service.ts
  2. 3
      apps/client/src/app/components/admin-market-data/admin-market-data.html
  3. 11
      apps/client/src/app/components/admin-market-data/admin-market-data.service.ts
  4. 1
      libs/common/src/lib/interfaces/admin-market-data.interface.ts

12
apps/api/src/app/admin/admin.service.ts

@ -238,7 +238,10 @@ export class AdminService {
where, where,
select: { select: {
_count: { _count: {
select: { Order: true } select: {
Order: true,
watchedBy: true
}
}, },
assetClass: true, assetClass: true,
assetSubClass: true, assetSubClass: true,
@ -375,7 +378,9 @@ export class AdminService {
sectorsCount, sectorsCount,
activitiesCount: _count.Order, activitiesCount: _count.Order,
date: Order?.[0]?.date, date: Order?.[0]?.date,
isUsedByUsersWithSubscription: await isUsedByUsersWithSubscription isUsedByUsersWithSubscription:
await isUsedByUsersWithSubscription,
watchedByCount: _count.watchedBy
}; };
} }
) )
@ -752,7 +757,8 @@ export class AdminService {
id: undefined, id: undefined,
isActive: true, isActive: true,
name: symbol, name: symbol,
sectorsCount: 0 sectorsCount: 0,
watchedByCount: 0
}; };
} }
); );

3
apps/client/src/app/components/admin-market-data/admin-market-data.html

@ -55,7 +55,8 @@
adminMarketDataService.hasPermissionToDeleteAssetProfile({ adminMarketDataService.hasPermissionToDeleteAssetProfile({
activitiesCount: element.activitiesCount, activitiesCount: element.activitiesCount,
isBenchmark: element.isBenchmark, isBenchmark: element.isBenchmark,
symbol: element.symbol symbol: element.symbol,
watchedByCount: element.watchedByCount
}) })
) { ) {
<mat-checkbox <mat-checkbox

11
apps/client/src/app/components/admin-market-data/admin-market-data.service.ts

@ -72,14 +72,19 @@ export class AdminMarketDataService {
public hasPermissionToDeleteAssetProfile({ public hasPermissionToDeleteAssetProfile({
activitiesCount, activitiesCount,
isBenchmark, isBenchmark,
symbol symbol,
}: Pick<AdminMarketDataItem, 'activitiesCount' | 'isBenchmark' | 'symbol'>) { watchedByCount
}: Pick<
AdminMarketDataItem,
'activitiesCount' | 'isBenchmark' | 'symbol' | 'watchedByCount'
>) {
return ( return (
activitiesCount === 0 && activitiesCount === 0 &&
!isBenchmark && !isBenchmark &&
!isDerivedCurrency(getCurrencyFromSymbol(symbol)) && !isDerivedCurrency(getCurrencyFromSymbol(symbol)) &&
!isRootCurrency(getCurrencyFromSymbol(symbol)) && !isRootCurrency(getCurrencyFromSymbol(symbol)) &&
!symbol.startsWith(ghostfolioScraperApiSymbolPrefix) !symbol.startsWith(ghostfolioScraperApiSymbolPrefix) &&
watchedByCount === 0
); );
} }
} }

1
libs/common/src/lib/interfaces/admin-market-data.interface.ts

@ -22,4 +22,5 @@ export interface AdminMarketDataItem {
name: string; name: string;
sectorsCount: number; sectorsCount: number;
symbol: string; symbol: string;
watchedByCount: number;
} }

Loading…
Cancel
Save