|
@ -14,7 +14,17 @@ import { |
|
|
Output, |
|
|
Output, |
|
|
ViewChild |
|
|
ViewChild |
|
|
} from '@angular/core'; |
|
|
} from '@angular/core'; |
|
|
|
|
|
import { |
|
|
|
|
|
FormGroup, |
|
|
|
|
|
FormControl, |
|
|
|
|
|
Validators, |
|
|
|
|
|
ReactiveFormsModule |
|
|
|
|
|
} from '@angular/forms'; |
|
|
import { MatButtonModule } from '@angular/material/button'; |
|
|
import { MatButtonModule } from '@angular/material/button'; |
|
|
|
|
|
import { DateAdapter } from '@angular/material/core'; |
|
|
|
|
|
import { MatDatepickerModule } from '@angular/material/datepicker'; |
|
|
|
|
|
import { MatFormFieldModule } from '@angular/material/form-field'; |
|
|
|
|
|
import { MatInputModule } from '@angular/material/input'; |
|
|
import { MatMenuModule } from '@angular/material/menu'; |
|
|
import { MatMenuModule } from '@angular/material/menu'; |
|
|
import { MatSort, MatSortModule } from '@angular/material/sort'; |
|
|
import { MatSort, MatSortModule } from '@angular/material/sort'; |
|
|
import { MatTableDataSource, MatTableModule } from '@angular/material/table'; |
|
|
import { MatTableDataSource, MatTableModule } from '@angular/material/table'; |
|
@ -29,9 +39,13 @@ import { GfValueComponent } from '../value'; |
|
|
CommonModule, |
|
|
CommonModule, |
|
|
GfValueComponent, |
|
|
GfValueComponent, |
|
|
MatButtonModule, |
|
|
MatButtonModule, |
|
|
|
|
|
MatDatepickerModule, |
|
|
|
|
|
MatFormFieldModule, |
|
|
|
|
|
MatInputModule, |
|
|
MatMenuModule, |
|
|
MatMenuModule, |
|
|
MatSortModule, |
|
|
MatSortModule, |
|
|
MatTableModule |
|
|
MatTableModule, |
|
|
|
|
|
ReactiveFormsModule |
|
|
], |
|
|
], |
|
|
schemas: [CUSTOM_ELEMENTS_SCHEMA], |
|
|
schemas: [CUSTOM_ELEMENTS_SCHEMA], |
|
|
selector: 'gf-account-balances', |
|
|
selector: 'gf-account-balances', |
|
@ -43,24 +57,38 @@ export class GfAccountBalancesComponent |
|
|
implements OnChanges, OnDestroy, OnInit |
|
|
implements OnChanges, OnDestroy, OnInit |
|
|
{ |
|
|
{ |
|
|
@Input() accountBalances: AccountBalancesResponse['balances']; |
|
|
@Input() accountBalances: AccountBalancesResponse['balances']; |
|
|
|
|
|
@Input() accountCurrency: string; |
|
|
@Input() accountId: string; |
|
|
@Input() accountId: string; |
|
|
@Input() locale = getLocale(); |
|
|
@Input() locale = getLocale(); |
|
|
@Input() showActions = true; |
|
|
@Input() showActions = true; |
|
|
|
|
|
|
|
|
|
|
|
@Output() accountBalanceCreated = new EventEmitter<{ |
|
|
|
|
|
balance: number; |
|
|
|
|
|
date: Date; |
|
|
|
|
|
}>(); |
|
|
@Output() accountBalanceDeleted = new EventEmitter<string>(); |
|
|
@Output() accountBalanceDeleted = new EventEmitter<string>(); |
|
|
|
|
|
|
|
|
@ViewChild(MatSort) sort: MatSort; |
|
|
@ViewChild(MatSort) sort: MatSort; |
|
|
|
|
|
|
|
|
|
|
|
public accountBalanceForm = new FormGroup({ |
|
|
|
|
|
balance: new FormControl(0, Validators.required), |
|
|
|
|
|
date: new FormControl(new Date(), Validators.required) |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
public dataSource: MatTableDataSource< |
|
|
public dataSource: MatTableDataSource< |
|
|
AccountBalancesResponse['balances'][0] |
|
|
AccountBalancesResponse['balances'][0] |
|
|
> = new MatTableDataSource(); |
|
|
> = new MatTableDataSource(); |
|
|
|
|
|
|
|
|
public displayedColumns: string[] = ['date', 'value', 'actions']; |
|
|
public displayedColumns: string[] = ['date', 'value', 'actions']; |
|
|
|
|
|
public Validators = Validators; |
|
|
|
|
|
|
|
|
private unsubscribeSubject = new Subject<void>(); |
|
|
private unsubscribeSubject = new Subject<void>(); |
|
|
|
|
|
|
|
|
public constructor() {} |
|
|
public constructor(private dateAdapter: DateAdapter<any>) {} |
|
|
|
|
|
|
|
|
public ngOnInit() {} |
|
|
public ngOnInit() { |
|
|
|
|
|
this.dateAdapter.setLocale(this.locale); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public ngOnChanges() { |
|
|
public ngOnChanges() { |
|
|
if (this.accountBalances) { |
|
|
if (this.accountBalances) { |
|
@ -81,6 +109,10 @@ export class GfAccountBalancesComponent |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public onSubmitAccountBalance() { |
|
|
|
|
|
this.accountBalanceCreated.emit(this.accountBalanceForm.getRawValue()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public ngOnDestroy() { |
|
|
public ngOnDestroy() { |
|
|
this.unsubscribeSubject.next(); |
|
|
this.unsubscribeSubject.next(); |
|
|
this.unsubscribeSubject.complete(); |
|
|
this.unsubscribeSubject.complete(); |
|
|