Feature: Added feature to click a name in receive payment to fill in the amount in that column
This commit is contained in:
parent
095f4fe473
commit
47381527c2
@ -1,14 +1,14 @@
|
|||||||
import { DataSource } from '@angular/cdk/collections';
|
import { DataSource } from '@angular/cdk/collections';
|
||||||
import { Observable, of as observableOf } from 'rxjs';
|
import { Observable, of as observableOf } from 'rxjs';
|
||||||
|
|
||||||
import { SettleOption } from '../../core/settle-option';
|
import { ReceivePaymentItem } from '../../core/receive-payment-item';
|
||||||
|
|
||||||
export class ReceivePaymentDatasource extends DataSource<SettleOption> {
|
export class ReceivePaymentDatasource extends DataSource<ReceivePaymentItem> {
|
||||||
constructor(private data: SettleOption[]) {
|
constructor(private data: ReceivePaymentItem[]) {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(): Observable<SettleOption[]> {
|
connect(): Observable<ReceivePaymentItem[]> {
|
||||||
return observableOf(this.data);
|
return observableOf(this.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,9 @@
|
|||||||
<!-- Name Column -->
|
<!-- Name Column -->
|
||||||
<ng-container matColumnDef="name">
|
<ng-container matColumnDef="name">
|
||||||
<mat-header-cell *matHeaderCellDef class="bold">Amount</mat-header-cell>
|
<mat-header-cell *matHeaderCellDef class="bold">Amount</mat-header-cell>
|
||||||
<mat-cell *matCellDef="let row">{{ row.name }}</mat-cell>
|
<mat-cell *matCellDef="let row; let i = index" (click)="maxAmount(row, i)">{{
|
||||||
|
row.name
|
||||||
|
}}</mat-cell>
|
||||||
<mat-footer-cell *matFooterCellDef class="bold">Balance</mat-footer-cell>
|
<mat-footer-cell *matFooterCellDef class="bold">Balance</mat-footer-cell>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Component, ElementRef, Inject, ViewChild } from '@angular/core';
|
import { Component, ElementRef, Inject, ViewChild } from '@angular/core';
|
||||||
import { FormArray, FormBuilder, FormGroup } from '@angular/forms';
|
import { FormArray, FormBuilder, FormControl, FormGroup } from '@angular/forms';
|
||||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||||
import { distinctUntilChanged, map, tap } from 'rxjs/operators';
|
import { distinctUntilChanged, map, tap } from 'rxjs/operators';
|
||||||
|
|
||||||
@ -99,4 +99,10 @@ export class ReceivePaymentComponent {
|
|||||||
accept(): void {
|
accept(): void {
|
||||||
this.dialogRef.close({ choices: this.choices, reason: this.reason });
|
this.dialogRef.close({ choices: this.choices, reason: this.reason });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
maxAmount(row: ReceivePaymentItem, index: number) {
|
||||||
|
const array = this.form.get('amounts') as FormArray;
|
||||||
|
const ctrl = array.controls[index].get('amount') as FormControl;
|
||||||
|
ctrl.setValue('' + (row.amount + this.balance));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user