Feature/add total value in the create or edit transaction dialog (#192)

* Display total value

* Update changelog
pull/201/head
Thomas 4 years ago committed by GitHub
parent fbe590ddb9
commit db090229ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased ## Unreleased
### Added
- Added the total value in the create or edit transaction dialog
### Changed ### Changed
- Upgraded `@angular/cdk` and `@angular/material` from version `11.0.4` to `12.0.6` - Upgraded `@angular/cdk` and `@angular/material` from version `11.0.4` to `12.0.6`

@ -12,7 +12,7 @@ import {
import { DataService } from '@ghostfolio/client/services/data.service'; import { DataService } from '@ghostfolio/client/services/data.service';
import { UserService } from '@ghostfolio/client/services/user/user.service'; import { UserService } from '@ghostfolio/client/services/user/user.service';
import { WebAuthnService } from '@ghostfolio/client/services/web-authn.service'; import { WebAuthnService } from '@ghostfolio/client/services/web-authn.service';
import { baseCurrency, DEFAULT_DATE_FORMAT } from '@ghostfolio/common/config'; import { DEFAULT_DATE_FORMAT, baseCurrency } from '@ghostfolio/common/config';
import { Access, User } from '@ghostfolio/common/interfaces'; import { Access, User } from '@ghostfolio/common/interfaces';
import { hasPermission, permissions } from '@ghostfolio/common/permissions'; import { hasPermission, permissions } from '@ghostfolio/common/permissions';
import { Currency } from '@prisma/client'; import { Currency } from '@prisma/client';

@ -23,7 +23,7 @@ import { CreateOrUpdateTransactionDialogParams } from './interfaces/interfaces';
@Component({ @Component({
host: { class: 'h-100' }, host: { class: 'h-100' },
selector: 'create-or-update-transaction-dialog', selector: 'gf-create-or-update-transaction-dialog',
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
styleUrls: ['./create-or-update-transaction-dialog.scss'], styleUrls: ['./create-or-update-transaction-dialog.scss'],
templateUrl: 'create-or-update-transaction-dialog.html' templateUrl: 'create-or-update-transaction-dialog.html'

@ -2,6 +2,22 @@
<h1 *ngIf="data.transaction.id" mat-dialog-title i18n>Update transaction</h1> <h1 *ngIf="data.transaction.id" mat-dialog-title i18n>Update transaction</h1>
<h1 *ngIf="!data.transaction.id" mat-dialog-title i18n>Add transaction</h1> <h1 *ngIf="!data.transaction.id" mat-dialog-title i18n>Add transaction</h1>
<div class="flex-grow-1" mat-dialog-content> <div class="flex-grow-1" mat-dialog-content>
<div>
<mat-form-field appearance="outline" class="w-100">
<mat-label i18n>Account</mat-label>
<mat-select
name="accountId"
required
[(value)]="data.transaction.accountId"
>
<mat-option
*ngFor="let account of data.user?.accounts"
[value]="account.id"
>{{ account.name }}</mat-option
>
</mat-select>
</mat-form-field>
</div>
<div> <div>
<mat-form-field appearance="outline" class="w-100"> <mat-form-field appearance="outline" class="w-100">
<mat-label i18n>Symbol or ISIN</mat-label> <mat-label i18n>Symbol or ISIN</mat-label>
@ -42,7 +58,7 @@
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>
</div> </div>
<div> <div class="d-none">
<mat-form-field appearance="outline" class="w-100"> <mat-form-field appearance="outline" class="w-100">
<mat-label i18n>Currency</mat-label> <mat-label i18n>Currency</mat-label>
<mat-select <mat-select
@ -136,31 +152,25 @@
</button> </button>
</mat-form-field> </mat-form-field>
</div> </div>
</div>
<div class="d-flex" mat-dialog-actions>
<gf-value
class="flex-grow-1"
[currency]="data.transaction.currency"
[locale]="data.user?.settings?.locale"
[value]="data.transaction.fee + (data.transaction.quantity * data.transaction.unitPrice)"
></gf-value>
<div> <div>
<mat-form-field appearance="outline" class="w-100"> <button i18n mat-button (click)="onCancel()">Cancel</button>
<mat-label i18n>Account</mat-label> <button
<mat-select color="primary"
name="accountId" i18n
required mat-flat-button
[(value)]="data.transaction.accountId" [disabled]="!(addTransactionForm.form.valid && data.transaction.symbol)"
> [mat-dialog-close]="data"
<mat-option *ngFor="let account of data.accounts" [value]="account.id" >
>{{ account.name }}</mat-option Save
> </button>
</mat-select>
</mat-form-field>
</div> </div>
</div> </div>
<div class="justify-content-end" mat-dialog-actions>
<button i18n mat-button (click)="onCancel()">Cancel</button>
<button
color="primary"
i18n
mat-flat-button
[disabled]="!(addTransactionForm.form.valid && data.transaction.symbol)"
[mat-dialog-close]="data"
>
Save
</button>
</div>
</form> </form>

@ -9,6 +9,7 @@ import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input'; import { MatInputModule } from '@angular/material/input';
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner'; import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { MatSelectModule } from '@angular/material/select'; import { MatSelectModule } from '@angular/material/select';
import { GfValueModule } from '@ghostfolio/client/components/value/value.module';
import { GfSymbolModule } from '@ghostfolio/client/pipes/symbol/symbol.module'; import { GfSymbolModule } from '@ghostfolio/client/pipes/symbol/symbol.module';
import { CreateOrUpdateTransactionDialog } from './create-or-update-transaction-dialog.component'; import { CreateOrUpdateTransactionDialog } from './create-or-update-transaction-dialog.component';
@ -19,6 +20,7 @@ import { CreateOrUpdateTransactionDialog } from './create-or-update-transaction-
imports: [ imports: [
CommonModule, CommonModule,
GfSymbolModule, GfSymbolModule,
GfValueModule,
FormsModule, FormsModule,
MatAutocompleteModule, MatAutocompleteModule,
MatButtonModule, MatButtonModule,

@ -1,6 +1,12 @@
:host { :host {
display: block; display: block;
.mat-dialog-actions {
gf-value {
font-size: 0.9rem;
}
}
.mat-dialog-content { .mat-dialog-content {
max-height: unset; max-height: unset;

@ -1,7 +1,8 @@
import { User } from '@ghostfolio/common/interfaces';
import { Account, Order } from '@prisma/client'; import { Account, Order } from '@prisma/client';
export interface CreateOrUpdateTransactionDialogParams { export interface CreateOrUpdateTransactionDialogParams {
accountId: string; accountId: string;
accounts: Account[];
transaction: Order; transaction: Order;
user: User;
} }

@ -141,7 +141,6 @@ export class TransactionsPageComponent implements OnInit {
}: OrderModel): void { }: OrderModel): void {
const dialogRef = this.dialog.open(CreateOrUpdateTransactionDialog, { const dialogRef = this.dialog.open(CreateOrUpdateTransactionDialog, {
data: { data: {
accounts: this.user.accounts,
transaction: { transaction: {
accountId, accountId,
currency, currency,
@ -153,7 +152,8 @@ export class TransactionsPageComponent implements OnInit {
symbol, symbol,
type, type,
unitPrice unitPrice
} },
user: this.user
}, },
height: this.deviceType === 'mobile' ? '97.5vh' : '80vh', height: this.deviceType === 'mobile' ? '97.5vh' : '80vh',
width: this.deviceType === 'mobile' ? '100vw' : '50rem' width: this.deviceType === 'mobile' ? '100vw' : '50rem'
@ -182,7 +182,6 @@ export class TransactionsPageComponent implements OnInit {
private openCreateTransactionDialog(aTransaction?: OrderModel): void { private openCreateTransactionDialog(aTransaction?: OrderModel): void {
const dialogRef = this.dialog.open(CreateOrUpdateTransactionDialog, { const dialogRef = this.dialog.open(CreateOrUpdateTransactionDialog, {
data: { data: {
accounts: this.user?.accounts,
transaction: { transaction: {
accountId: accountId:
aTransaction?.accountId ?? aTransaction?.accountId ??
@ -197,7 +196,8 @@ export class TransactionsPageComponent implements OnInit {
symbol: aTransaction?.symbol ?? null, symbol: aTransaction?.symbol ?? null,
type: aTransaction?.type ?? 'BUY', type: aTransaction?.type ?? 'BUY',
unitPrice: null unitPrice: null
} },
user: this.user
}, },
height: this.deviceType === 'mobile' ? '97.5vh' : '80vh', height: this.deviceType === 'mobile' ? '97.5vh' : '80vh',
width: this.deviceType === 'mobile' ? '100vw' : '50rem' width: this.deviceType === 'mobile' ? '100vw' : '50rem'

Loading…
Cancel
Save