Browse Source

Refactor showTransactions and transactionCount

pull/6266/head
Thomas Kaul 3 days ago
parent
commit
1b9cc69efa
  1. 2
      apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.html
  2. 10
      apps/client/src/app/pages/accounts/accounts-page.component.ts
  3. 2
      apps/client/src/app/pages/accounts/accounts-page.html
  4. 4
      libs/ui/src/lib/accounts-table/accounts-table.component.html
  5. 14
      libs/ui/src/lib/accounts-table/accounts-table.component.stories.ts
  6. 8
      libs/ui/src/lib/accounts-table/accounts-table.component.ts

2
apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.html

@ -380,10 +380,10 @@
[deviceType]="data.deviceType" [deviceType]="data.deviceType"
[hasPermissionToOpenDetails]="false" [hasPermissionToOpenDetails]="false"
[locale]="user?.settings?.locale" [locale]="user?.settings?.locale"
[showActivitiesCount]="false"
[showAllocationInPercentage]="user?.settings?.isExperimentalFeatures" [showAllocationInPercentage]="user?.settings?.isExperimentalFeatures"
[showBalance]="false" [showBalance]="false"
[showFooter]="false" [showFooter]="false"
[showTransactions]="false"
[showValue]="false" [showValue]="false"
[showValueInBaseCurrency]="false" [showValueInBaseCurrency]="false"
/> />

10
apps/client/src/app/pages/accounts/accounts-page.component.ts

@ -38,6 +38,7 @@ import { GfTransferBalanceDialogComponent } from './transfer-balance/transfer-ba
}) })
export class GfAccountsPageComponent implements OnDestroy, OnInit { export class GfAccountsPageComponent implements OnDestroy, OnInit {
public accounts: AccountModel[]; public accounts: AccountModel[];
public activitiesCount = 0;
public deviceType: string; public deviceType: string;
public hasImpersonationId: boolean; public hasImpersonationId: boolean;
public hasPermissionToCreateAccount: boolean; public hasPermissionToCreateAccount: boolean;
@ -45,7 +46,6 @@ export class GfAccountsPageComponent implements OnDestroy, OnInit {
public routeQueryParams: Subscription; public routeQueryParams: Subscription;
public totalBalanceInBaseCurrency = 0; public totalBalanceInBaseCurrency = 0;
public totalValueInBaseCurrency = 0; public totalValueInBaseCurrency = 0;
public transactionCount = 0;
public user: User; public user: User;
private unsubscribeSubject = new Subject<void>(); private unsubscribeSubject = new Subject<void>();
@ -128,14 +128,14 @@ export class GfAccountsPageComponent implements OnDestroy, OnInit {
.subscribe( .subscribe(
({ ({
accounts, accounts,
activitiesCount,
totalBalanceInBaseCurrency, totalBalanceInBaseCurrency,
totalValueInBaseCurrency, totalValueInBaseCurrency
transactionCount
}) => { }) => {
this.accounts = accounts; this.accounts = accounts;
this.activitiesCount = activitiesCount;
this.totalBalanceInBaseCurrency = totalBalanceInBaseCurrency; this.totalBalanceInBaseCurrency = totalBalanceInBaseCurrency;
this.totalValueInBaseCurrency = totalValueInBaseCurrency; this.totalValueInBaseCurrency = totalValueInBaseCurrency;
this.transactionCount = transactionCount;
if (this.accounts?.length <= 0) { if (this.accounts?.length <= 0) {
this.router.navigate([], { queryParams: { createDialog: true } }); this.router.navigate([], { queryParams: { createDialog: true } });
@ -358,8 +358,8 @@ export class GfAccountsPageComponent implements OnDestroy, OnInit {
private reset() { private reset() {
this.accounts = undefined; this.accounts = undefined;
this.activitiesCount = 0;
this.totalBalanceInBaseCurrency = 0; this.totalBalanceInBaseCurrency = 0;
this.totalValueInBaseCurrency = 0; this.totalValueInBaseCurrency = 0;
this.transactionCount = 0;
} }
} }

2
apps/client/src/app/pages/accounts/accounts-page.html

@ -4,6 +4,7 @@
<h1 class="d-none d-sm-block h3 mb-4 text-center" i18n>Accounts</h1> <h1 class="d-none d-sm-block h3 mb-4 text-center" i18n>Accounts</h1>
<gf-accounts-table <gf-accounts-table
[accounts]="accounts" [accounts]="accounts"
[activitiesCount]="activitiesCount"
[baseCurrency]="user?.settings?.baseCurrency" [baseCurrency]="user?.settings?.baseCurrency"
[deviceType]="deviceType" [deviceType]="deviceType"
[locale]="user?.settings?.locale" [locale]="user?.settings?.locale"
@ -14,7 +15,6 @@
" "
[totalBalanceInBaseCurrency]="totalBalanceInBaseCurrency" [totalBalanceInBaseCurrency]="totalBalanceInBaseCurrency"
[totalValueInBaseCurrency]="totalValueInBaseCurrency" [totalValueInBaseCurrency]="totalValueInBaseCurrency"
[transactionCount]="transactionCount"
(accountDeleted)="onDeleteAccount($event)" (accountDeleted)="onDeleteAccount($event)"
(accountToUpdate)="onUpdateAccount($event)" (accountToUpdate)="onUpdateAccount($event)"
(transferBalance)="onTransferBalance()" (transferBalance)="onTransferBalance()"

4
libs/ui/src/lib/accounts-table/accounts-table.component.html

@ -115,7 +115,7 @@
></td> ></td>
</ng-container> </ng-container>
<ng-container matColumnDef="transactions"> <ng-container matColumnDef="activitiesCount">
<th <th
*matHeaderCellDef *matHeaderCellDef
class="justify-content-end px-1" class="justify-content-end px-1"
@ -129,7 +129,7 @@
{{ element.transactionCount }} {{ element.transactionCount }}
</td> </td>
<td *matFooterCellDef class="px-1 text-right" mat-footer-cell> <td *matFooterCellDef class="px-1 text-right" mat-footer-cell>
{{ transactionCount }} {{ activitiesCount }}
</td> </td>
</ng-container> </ng-container>

14
libs/ui/src/lib/accounts-table/accounts-table.component.stories.ts

@ -115,10 +115,10 @@ export const Loading: Story = {
hasPermissionToOpenDetails: false, hasPermissionToOpenDetails: false,
locale: 'en-US', locale: 'en-US',
showActions: false, showActions: false,
showActivitiesCount: true,
showAllocationInPercentage: false, showAllocationInPercentage: false,
showBalance: true, showBalance: true,
showFooter: true, showFooter: true,
showTransactions: true,
showValue: true, showValue: true,
showValueInBaseCurrency: true showValueInBaseCurrency: true
} }
@ -127,39 +127,39 @@ export const Loading: Story = {
export const Default: Story = { export const Default: Story = {
args: { args: {
accounts, accounts,
activitiesCount: 12,
baseCurrency: 'USD', baseCurrency: 'USD',
deviceType: 'desktop', deviceType: 'desktop',
hasPermissionToOpenDetails: false, hasPermissionToOpenDetails: false,
locale: 'en-US', locale: 'en-US',
showActions: false, showActions: false,
showActivitiesCount: true,
showAllocationInPercentage: false, showAllocationInPercentage: false,
showBalance: true, showBalance: true,
showFooter: true, showFooter: true,
showTransactions: true,
showValue: true, showValue: true,
showValueInBaseCurrency: true, showValueInBaseCurrency: true,
totalBalanceInBaseCurrency: 12428.2, totalBalanceInBaseCurrency: 12428.2,
totalValueInBaseCurrency: 107971.70321466809, totalValueInBaseCurrency: 107971.70321466809
transactionCount: 12
} }
}; };
export const WithoutFooter: Story = { export const WithoutFooter: Story = {
args: { args: {
accounts, accounts,
activitiesCount: 12,
baseCurrency: 'USD', baseCurrency: 'USD',
deviceType: 'desktop', deviceType: 'desktop',
hasPermissionToOpenDetails: false, hasPermissionToOpenDetails: false,
locale: 'en-US', locale: 'en-US',
showActions: false, showActions: false,
showActivitiesCount: true,
showAllocationInPercentage: false, showAllocationInPercentage: false,
showBalance: true, showBalance: true,
showFooter: false, showFooter: false,
showTransactions: true,
showValue: true, showValue: true,
showValueInBaseCurrency: true, showValueInBaseCurrency: true,
totalBalanceInBaseCurrency: 12428.2, totalBalanceInBaseCurrency: 12428.2,
totalValueInBaseCurrency: 107971.70321466809, totalValueInBaseCurrency: 107971.70321466809
transactionCount: 12
} }
}; };

8
libs/ui/src/lib/accounts-table/accounts-table.component.ts

@ -55,20 +55,20 @@ import { Subject, Subscription } from 'rxjs';
}) })
export class GfAccountsTableComponent implements OnChanges, OnDestroy { export class GfAccountsTableComponent implements OnChanges, OnDestroy {
@Input() accounts: Account[]; @Input() accounts: Account[];
@Input() activitiesCount: number;
@Input() baseCurrency: string; @Input() baseCurrency: string;
@Input() deviceType: string; @Input() deviceType: string;
@Input() hasPermissionToOpenDetails = true; @Input() hasPermissionToOpenDetails = true;
@Input() locale = getLocale(); @Input() locale = getLocale();
@Input() showActions: boolean; @Input() showActions: boolean;
@Input() showActivitiesCount = true;
@Input() showAllocationInPercentage: boolean; @Input() showAllocationInPercentage: boolean;
@Input() showBalance = true; @Input() showBalance = true;
@Input() showFooter = true; @Input() showFooter = true;
@Input() showTransactions = true;
@Input() showValue = true; @Input() showValue = true;
@Input() showValueInBaseCurrency = true; @Input() showValueInBaseCurrency = true;
@Input() totalBalanceInBaseCurrency: number; @Input() totalBalanceInBaseCurrency: number;
@Input() totalValueInBaseCurrency: number; @Input() totalValueInBaseCurrency: number;
@Input() transactionCount: number;
@Output() accountDeleted = new EventEmitter<string>(); @Output() accountDeleted = new EventEmitter<string>();
@Output() accountToUpdate = new EventEmitter<Account>(); @Output() accountToUpdate = new EventEmitter<Account>();
@ -101,8 +101,8 @@ export class GfAccountsTableComponent implements OnChanges, OnDestroy {
public ngOnChanges() { public ngOnChanges() {
this.displayedColumns = ['status', 'account', 'platform']; this.displayedColumns = ['status', 'account', 'platform'];
if (this.showTransactions) { if (this.showActivitiesCount) {
this.displayedColumns.push('transactions'); this.displayedColumns.push('activitiesCount');
} }
if (this.showBalance) { if (this.showBalance) {

Loading…
Cancel
Save