fully working transaction edit and delete
This commit is contained in:
parent
df6c469965
commit
390b670be5
3 changed files with 39 additions and 3 deletions
|
@ -122,7 +122,7 @@
|
|||
<div class="col-md-12">
|
||||
<div [ngSwitch]="transactionFormStatus">
|
||||
<div *ngSwitchCase="'success'" class="alert alert-success" role="alert">
|
||||
Edit Succeeded.
|
||||
{{transactionFormStatusSuccess}}
|
||||
</div>
|
||||
<div *ngSwitchCase="'send_failed'" class="alert alert-danger" role="alert">
|
||||
{{transactionFormStatusError}}
|
||||
|
|
|
@ -26,6 +26,7 @@ export class TransactionLogComponent implements OnInit {
|
|||
categoryList: any;
|
||||
categoryNameList: string[] = [];
|
||||
transactionFormStatus: string;
|
||||
transactionFormStatusSuccess: string;
|
||||
transactionFormStatusError = 'Error received, please try again.';
|
||||
|
||||
public paginateConfig: PaginationInstance = {
|
||||
|
@ -137,7 +138,32 @@ export class TransactionLogComponent implements OnInit {
|
|||
}
|
||||
|
||||
deleteRecurringTransaction() {
|
||||
|
||||
let myParams = {
|
||||
id: this.clickedRecur.id,
|
||||
};
|
||||
this.api
|
||||
.recurDelete(myParams)
|
||||
.subscribe(
|
||||
result => {
|
||||
if ( result.success === true ) {
|
||||
this.transactionFormStatus = 'success';
|
||||
this.transactionFormStatusSuccess = 'Delete Succeeded.';
|
||||
} else {
|
||||
this.transactionFormStatusError = JSON.stringify(result.status) + 'Error, ' + JSON.stringify(result.message);
|
||||
this.transactionFormStatus = 'send_failed';
|
||||
}
|
||||
},
|
||||
error => {
|
||||
console.log(error);
|
||||
try {
|
||||
console.log(error.error);
|
||||
this.transactionFormStatusError = '"' + error.error.error + '" Error, ' + error.error.message;
|
||||
} catch (e) {
|
||||
this.transactionFormStatusError = 'There was a server error, please try again later.';
|
||||
}
|
||||
this.transactionFormStatus = 'send_failed';
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -158,7 +158,7 @@ export class ApiService {
|
|||
);
|
||||
}
|
||||
|
||||
// Uploads a transaction
|
||||
// Edits a recurring transaction
|
||||
|
||||
public recurUpdate(data) {
|
||||
data.session_key = this.sessionKey;
|
||||
|
@ -168,6 +168,16 @@ export class ApiService {
|
|||
);
|
||||
}
|
||||
|
||||
// Edits a recurring transaction
|
||||
|
||||
public recurDelete(data) {
|
||||
data.session_key = this.sessionKey;
|
||||
return this.http.post<any>(
|
||||
this.apiUrl + '/recurring-transactions/delete',
|
||||
data
|
||||
);
|
||||
}
|
||||
|
||||
// gets payroll list for log
|
||||
|
||||
public payrollList(data) {
|
||||
|
|
Reference in a new issue