|
|
|
@ -106,20 +106,7 @@ export class TransactionsPageComponent implements OnDestroy, OnInit {
|
|
|
|
|
.pipe(takeUntil(this.unsubscribeSubject))
|
|
|
|
|
.subscribe((state) => {
|
|
|
|
|
if (state?.user) {
|
|
|
|
|
this.user = state.user;
|
|
|
|
|
|
|
|
|
|
this.defaultAccountId = this.user?.accounts.find((account) => {
|
|
|
|
|
return account.isDefault;
|
|
|
|
|
})?.id;
|
|
|
|
|
|
|
|
|
|
this.hasPermissionToCreateOrder = hasPermission(
|
|
|
|
|
this.user.permissions,
|
|
|
|
|
permissions.createOrder
|
|
|
|
|
);
|
|
|
|
|
this.hasPermissionToDeleteOrder = hasPermission(
|
|
|
|
|
this.user.permissions,
|
|
|
|
|
permissions.deleteOrder
|
|
|
|
|
);
|
|
|
|
|
this.updateUser(state.user);
|
|
|
|
|
|
|
|
|
|
this.changeDetectorRef.markForCheck();
|
|
|
|
|
}
|
|
|
|
@ -352,6 +339,12 @@ export class TransactionsPageComponent implements OnDestroy, OnInit {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private openCreateTransactionDialog(aTransaction?: OrderModel): void {
|
|
|
|
|
this.userService
|
|
|
|
|
.get()
|
|
|
|
|
.pipe(takeUntil(this.unsubscribeSubject))
|
|
|
|
|
.subscribe((user) => {
|
|
|
|
|
this.updateUser(user);
|
|
|
|
|
|
|
|
|
|
const dialogRef = this.dialog.open(CreateOrUpdateTransactionDialog, {
|
|
|
|
|
data: {
|
|
|
|
|
accounts: this.user?.accounts?.filter((account) => {
|
|
|
|
@ -390,6 +383,7 @@ export class TransactionsPageComponent implements OnDestroy, OnInit {
|
|
|
|
|
|
|
|
|
|
this.router.navigate(['.'], { relativeTo: this.route });
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private openPositionDialog({ symbol }: { symbol: string }) {
|
|
|
|
@ -397,7 +391,7 @@ export class TransactionsPageComponent implements OnDestroy, OnInit {
|
|
|
|
|
.get()
|
|
|
|
|
.pipe(takeUntil(this.unsubscribeSubject))
|
|
|
|
|
.subscribe((user) => {
|
|
|
|
|
this.user = user;
|
|
|
|
|
this.updateUser(user);
|
|
|
|
|
|
|
|
|
|
const dialogRef = this.dialog.open(PositionDetailDialog, {
|
|
|
|
|
autoFocus: false,
|
|
|
|
@ -419,4 +413,21 @@ export class TransactionsPageComponent implements OnDestroy, OnInit {
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private updateUser(aUser: User) {
|
|
|
|
|
this.user = aUser;
|
|
|
|
|
|
|
|
|
|
this.defaultAccountId = this.user?.accounts.find((account) => {
|
|
|
|
|
return account.isDefault;
|
|
|
|
|
})?.id;
|
|
|
|
|
|
|
|
|
|
this.hasPermissionToCreateOrder = hasPermission(
|
|
|
|
|
this.user.permissions,
|
|
|
|
|
permissions.createOrder
|
|
|
|
|
);
|
|
|
|
|
this.hasPermissionToDeleteOrder = hasPermission(
|
|
|
|
|
this.user.permissions,
|
|
|
|
|
permissions.deleteOrder
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|