SaveAndAdd Button
parent
46b4e1dcd0
commit
67d9ce7802
|
|
@ -7,6 +7,7 @@ import { MatDialog } from '@angular/material';
|
||||||
import { AddTransactionPopupComponent, ValDisplay } from './add-transaction-popup/add-transaction-popup.component';
|
import { AddTransactionPopupComponent, ValDisplay } from './add-transaction-popup/add-transaction-popup.component';
|
||||||
import { TransactionType } from './transaction-type';
|
import { TransactionType } from './transaction-type';
|
||||||
import { Fund } from './fund';
|
import { Fund } from './fund';
|
||||||
|
import { OkPopupComponent } from '../popups/ok-popup/ok-popup.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-add-transaction-page',
|
selector: 'app-add-transaction-page',
|
||||||
|
|
@ -65,17 +66,20 @@ export class AddTransactionPageComponent implements OnInit {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
ref.afterClosed().subscribe((trans: Transaction) => {
|
ref.afterClosed().subscribe((res: {transaction:Transaction,saveAndAdd:boolean}) => {
|
||||||
if (trans) {
|
if (res) {
|
||||||
let contrib = this.contributions.find(c => c.contributorId === trans.contributorId);
|
let contrib = this.contributions.find(c => c.contributorId === res.transaction.contributorId);
|
||||||
if (!contrib) {
|
if (!contrib) {
|
||||||
contrib = new Contribution();
|
contrib = new Contribution();
|
||||||
contrib.contributorId = trans.contributorId;
|
contrib.contributorId = res.transaction.contributorId;
|
||||||
contrib.date = trans.date;
|
contrib.date = res.transaction.date;
|
||||||
contrib.transactions = [];
|
contrib.transactions = [];
|
||||||
this.contributions.push(contrib);
|
this.contributions.push(contrib);
|
||||||
}
|
}
|
||||||
contrib.transactions.push(trans);
|
contrib.transactions.push(res.transaction);
|
||||||
|
if (res.saveAndAdd === true) {
|
||||||
|
this.addTransaction(contrib.contributorId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -139,11 +143,18 @@ export class AddTransactionPageComponent implements OnInit {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(transactions);
|
|
||||||
this.transactionService.createFromArray(transactions).subscribe(x =>{
|
this.transactionService.createFromArray(transactions).subscribe(x =>{
|
||||||
this.submitButtonText = 'Submit Transactions';
|
this.submitButtonText = 'Submit Transactions';
|
||||||
this.submitButtonDisabled = false;
|
this.submitButtonDisabled = false;
|
||||||
}, e => console.log(e));
|
this.contributions = [];
|
||||||
|
}, e => {
|
||||||
|
this.dialogService.open(OkPopupComponent,{
|
||||||
|
data: {
|
||||||
|
title: 'Error Saving Transactions',
|
||||||
|
message: e.toString()
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,7 @@
|
||||||
.w-100 {
|
.w-100 {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-10 {
|
||||||
|
margin: 10px;
|
||||||
}
|
}
|
||||||
|
|
@ -41,8 +41,9 @@
|
||||||
<input matInput placeholder="Description" type="text" formControlName="description" >
|
<input matInput placeholder="Description" type="text" formControlName="description" >
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<br>
|
<br>
|
||||||
<button mat-raised-button type="button" (click)="cancel()" >Cancel</button>
|
<button mat-raised-button class="m-10" type="button" (click)="cancel()" >Cancel</button>
|
||||||
<button mat-raised-button type="submit" [disabled]="!form.valid || saveBtnDisabled">{{ saveBtnTxt }}</button>
|
<button mat-raised-button class="m-10" type="submit" [disabled]="!form.valid || saveBtnDisabled">{{ saveBtnTxt }}</button>
|
||||||
|
<button mat-raised-button class="m-10" type="button" (click)="onSubmit(true)" [disabled]="!form.valid || saveBtnDisabled">{{ saveAndAddBtnTxt }}</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ export class AddTransactionPopupComponent implements OnInit {
|
||||||
|
|
||||||
saveBtnDisabled: boolean = false;
|
saveBtnDisabled: boolean = false;
|
||||||
saveBtnTxt: string = 'Save';
|
saveBtnTxt: string = 'Save';
|
||||||
|
saveAndAddBtnTxt: string = 'Save and Add';
|
||||||
contributors: ValDisplay[] = [];
|
contributors: ValDisplay[] = [];
|
||||||
filteredContributors: ValDisplay[]
|
filteredContributors: ValDisplay[]
|
||||||
funds: ValDisplay[];
|
funds: ValDisplay[];
|
||||||
|
|
@ -63,7 +64,6 @@ export class AddTransactionPopupComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
contributorDisplayFn(contributor?: {value:number,display:string}): string | undefined {
|
contributorDisplayFn(contributor?: {value:number,display:string}): string | undefined {
|
||||||
console.log(contributor);
|
|
||||||
return contributor ? contributor.display : undefined;
|
return contributor ? contributor.display : undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -81,7 +81,7 @@ export class AddTransactionPopupComponent implements OnInit {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onSubmit() {
|
onSubmit(saveAndAdd: boolean = false) {
|
||||||
const trans = new Transaction();
|
const trans = new Transaction();
|
||||||
trans.amount = this.form.value.amount;
|
trans.amount = this.form.value.amount;
|
||||||
trans.checkNumber = this.form.value.checkNumber;
|
trans.checkNumber = this.form.value.checkNumber;
|
||||||
|
|
@ -91,7 +91,7 @@ export class AddTransactionPopupComponent implements OnInit {
|
||||||
trans.fundId = this.form.value.fundId;
|
trans.fundId = this.form.value.fundId;
|
||||||
trans.taxYear = this.form.value.taxYear;
|
trans.taxYear = this.form.value.taxYear;
|
||||||
trans.typeId = this.form.value.typeId;
|
trans.typeId = this.form.value.typeId;
|
||||||
this.dialogRef.close(trans);
|
this.dialogRef.close({transaction:trans,saveAndAdd:saveAndAdd});
|
||||||
}
|
}
|
||||||
|
|
||||||
cancel() {
|
cancel() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue