From aaaa7c7a0573ee8b1f84844275ee0ba703c9e420 Mon Sep 17 00:00:00 2001 From: piratefinn Date: Mon, 12 Mar 2018 16:36:26 +0000 Subject: [PATCH 01/16] Converted category select into buttons, no color yet --- package-lock.json | 6 +++--- package.json | 2 +- src/app/dashboard/add-data.component.html | 25 ++++++++++------------- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/package-lock.json b/package-lock.json index ecdbe1a..7334a98 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6752,9 +6752,9 @@ "integrity": "sha1-zJJ7GR2Yb+D7atKVeQdQxV3L6FE=" }, "ngx-bootstrap": { - "version": "2.0.0-beta.8", - "resolved": "https://registry.npmjs.org/ngx-bootstrap/-/ngx-bootstrap-2.0.0-beta.8.tgz", - "integrity": "sha512-e+3euXDb4nhzxn9kBO4RPWwRaI2ef7Lg+us8Yo2DBfD/Kuk/vl7ksWjoolMFLKEGpcTcKhMT/4BH5dUx+S4AtA==" + "version": "2.0.0-rc.1", + "resolved": "https://registry.npmjs.org/ngx-bootstrap/-/ngx-bootstrap-2.0.0-rc.1.tgz", + "integrity": "sha512-/ARJ2LLrT4bDghOVS16btJovJ7lsDcILmBUvGt0EXzNlU1HbTQZKfl/OKhrufmRgHQIzc6kXckVUhz5d5QIsUA==" }, "ngx-pagination": { "version": "3.0.3", diff --git a/package.json b/package.json index 11dcb5e..5d7e254 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "moment": "^2.21.0", "ng2-charts": "1.6.0", "ng2-validation-manager": "0.5.3", - "ngx-bootstrap": "2.0.0-beta.8", + "ngx-bootstrap": "2.0.0-rc.1", "ngx-pagination": "3.0.3", "rxjs": "5.5.6", "ts-helpers": "1.1.2", diff --git a/src/app/dashboard/add-data.component.html b/src/app/dashboard/add-data.component.html index a756040..d832253 100644 --- a/src/app/dashboard/add-data.component.html +++ b/src/app/dashboard/add-data.component.html @@ -78,21 +78,18 @@
-
-
- - -
-
- - -
+
+ +
-
-
- - -
+
+
Optional: Choose the Budget Type for the majority of the purchase. From dc27b286cf20163dbbb35aa36e0eb8976aadc9dd Mon Sep 17 00:00:00 2001 From: piratefinn Date: Mon, 12 Mar 2018 17:41:01 +0000 Subject: [PATCH 02/16] Placeholder recurring transaction box --- .../dashboard/transaction-log.component.html | 23 +++++++++++++++++++ .../dashboard/transaction-log.component.ts | 1 + 2 files changed, 24 insertions(+) diff --git a/src/app/dashboard/transaction-log.component.html b/src/app/dashboard/transaction-log.component.html index b4f1e30..f6f4bbf 100644 --- a/src/app/dashboard/transaction-log.component.html +++ b/src/app/dashboard/transaction-log.component.html @@ -44,6 +44,29 @@ No Transactions available.
+
+
+ Recurring Transactions + Here you can control your recurring transactions. +
+
+ + + + + + + + + + + +
SellerValuePurchase Time
+
+
+ No Recurring Transactions. +
+
diff --git a/src/app/dashboard/transaction-log.component.ts b/src/app/dashboard/transaction-log.component.ts index 34408cd..92f4822 100644 --- a/src/app/dashboard/transaction-log.component.ts +++ b/src/app/dashboard/transaction-log.component.ts @@ -15,6 +15,7 @@ export class TransactionLogComponent implements OnInit { transactionList; noTransactionList = true; + noRecurringList = true; myDate: any; minDate: any; public p: any; From 40b0a0088c0839080216980d5d9a7770dde383ee Mon Sep 17 00:00:00 2001 From: piratefinn Date: Mon, 12 Mar 2018 17:43:15 +0000 Subject: [PATCH 03/16] applied new category style to fixed category view --- src/app/dashboard/add-data.component.html | 25 ++++++++++------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/app/dashboard/add-data.component.html b/src/app/dashboard/add-data.component.html index 329c7d9..6d57253 100644 --- a/src/app/dashboard/add-data.component.html +++ b/src/app/dashboard/add-data.component.html @@ -78,21 +78,18 @@
-
-
- - -
-
- - -
+
+ +
-
-
- - -
+
+
Optional: Choose the Budget Type for the majority of the purchase. From f3c6370394b90914ee70792b12c3c69b4f99b751 Mon Sep 17 00:00:00 2001 From: piratefinn Date: Tue, 13 Mar 2018 12:49:30 +0000 Subject: [PATCH 04/16] Amended purchase validation and submission --- CHANGELOG.md | 3 ++ src/app/dashboard/add-data.component.html | 47 ++++++++----------- src/app/dashboard/add-data.component.ts | 15 +++--- .../dashboard/transaction-log.component.ts | 1 - 4 files changed, 31 insertions(+), 35 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f3c39a..636040e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ # v0.1.5 * Fixed category viewing on purchase +* Changed category view from radio buttons to full label buttons +* Amended local validation of submit +* Changed recurring purchase selection view # v0.1.4 diff --git a/src/app/dashboard/add-data.component.html b/src/app/dashboard/add-data.component.html index 6d57253..2f6ca73 100644 --- a/src/app/dashboard/add-data.component.html +++ b/src/app/dashboard/add-data.component.html @@ -46,29 +46,22 @@
-
-
- - -
-
- - -
-
- - -
-
-
-
- - -
-
- - -
+
+ + + + +
Please give the period of time the purchase will recur from "Time of Transaction". @@ -86,7 +79,7 @@ {{ leftCategoryNameList[i] }}
-
+
@@ -105,21 +98,21 @@
- +
Enter the street name where the organisation is located at.
- +
Enter the name of the town where the organisation is located at.
- +
Enter the postcode where the organisation is located at. diff --git a/src/app/dashboard/add-data.component.ts b/src/app/dashboard/add-data.component.ts index 99a1df4..4b7b838 100644 --- a/src/app/dashboard/add-data.component.ts +++ b/src/app/dashboard/add-data.component.ts @@ -177,14 +177,15 @@ export class AddDataComponent implements OnInit { } transactionFormValidate() { - if (this.submitOrg.name.length === 0 || - this.submitOrg.town.length === 0 || - this.amount === 0 || - this.recurringPurchase && - !this.recurringType) { - this.transactionFormInvalid = true; - } else { + if (this.submitOrg.name.length && + this.amount && + (this.recurringPurchase && + this.recurringType || + !this.recurringPurchase && + !this.recurringType)) { this.transactionFormInvalid = false; + } else { + this.transactionFormInvalid = true; } } diff --git a/src/app/dashboard/transaction-log.component.ts b/src/app/dashboard/transaction-log.component.ts index 92f4822..03bcd9e 100644 --- a/src/app/dashboard/transaction-log.component.ts +++ b/src/app/dashboard/transaction-log.component.ts @@ -53,7 +53,6 @@ export class TransactionLogComponent implements OnInit { } loadTransactions(logPage: number) { - console.log(logPage); this.api.transList(logPage).subscribe( result => { if (result.transactions.length > 0) { From e1dfa37f63d8e968e42255c2f29f519aa0d0d3cd Mon Sep 17 00:00:00 2001 From: piratefinn Date: Wed, 14 Mar 2018 16:49:01 +0000 Subject: [PATCH 05/16] removed unnecessary console logs --- src/app/dashboard/add-data.component.ts | 19 ------------------- src/app/dashboard/trail-map.component.ts | 1 - 2 files changed, 20 deletions(-) diff --git a/src/app/dashboard/add-data.component.ts b/src/app/dashboard/add-data.component.ts index 4b7b838..66dfa08 100644 --- a/src/app/dashboard/add-data.component.ts +++ b/src/app/dashboard/add-data.component.ts @@ -239,31 +239,23 @@ export class AddDataComponent implements OnInit { .subscribe( result => { if ( result.success === true ) { - console.log('Successful Upload'); - console.log(result); this.transactionFormStatus = 'success'; - console.log(this.transactionFormStatus); this.resetForm(); } else { - console.log('Upload Error'); this.transactionFormStatusError = JSON.stringify(result.status) + 'Error, ' + JSON.stringify(result.message); this.transactionFormStatus = 'send_failed'; - console.log(this.transactionFormStatus); } }, error => { - console.log('Upload Error'); console.log(error); try { console.log(error.error); const jsonError = error.json(); - console.log('boop'); this.transactionFormStatusError = '"' + jsonError.error + '" Error, ' + jsonError.message; } catch (e) { this.transactionFormStatusError = 'There was a server error, please try again later.'; } this.transactionFormStatus = 'send_failed'; - console.log(this.transactionFormStatus); } ); } @@ -291,14 +283,11 @@ export class AddDataComponent implements OnInit { .orgPayroll(this.payrollForm.value) .subscribe( result => { - console.log('data submitted!'); this.payrollFormStatus = 'success'; - console.log(this.payrollFormStatus); }, error => { console.log( error._body ); this.payrollFormStatus = 'send_failed'; - console.log(this.payrollFormStatus); } ); } @@ -310,14 +299,10 @@ export class AddDataComponent implements OnInit { .orgSupplier(this.singleSupplierForm.value) .subscribe( result => { - console.log('data submitted!'); this.singleSupplierFormStatus = 'success'; - console.log(this.singleSupplierFormStatus); }, error => { - console.log( error._body ); this.singleSupplierFormStatus = 'send_failed'; - console.log(this.singleSupplierFormStatus); } ); } @@ -329,14 +314,10 @@ export class AddDataComponent implements OnInit { .orgEmployee(this.employeeForm.value) .subscribe( result => { - console.log('data submitted!'); this.employeeFormStatus = 'success'; - console.log(this.employeeFormStatus); }, error => { - console.log( error._body ); this.employeeFormStatus = 'send_failed'; - console.log(this.employeeFormStatus); } ); } diff --git a/src/app/dashboard/trail-map.component.ts b/src/app/dashboard/trail-map.component.ts index 3f15c06..6390d27 100644 --- a/src/app/dashboard/trail-map.component.ts +++ b/src/app/dashboard/trail-map.component.ts @@ -51,7 +51,6 @@ export class TrailMapComponent implements OnInit, AfterViewInit { } public onMarkerClick(clickedMarker, template: TemplateRef) { - console.log(clickedMarker); this.clickedMarker = clickedMarker; this.assocLogo = 'assets/img/association/' + this.assocMap + '-logo.png'; this.openModal(template); From c45790c7e9a4164a7ccffa60bb9a23810a3be281 Mon Sep 17 00:00:00 2001 From: piratefinn Date: Wed, 14 Mar 2018 20:05:46 +0000 Subject: [PATCH 06/16] fixed upload submissions --- src/app/dashboard/add-data.component.html | 18 +++++++++--------- src/app/dashboard/add-data.component.ts | 17 ++++++----------- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/src/app/dashboard/add-data.component.html b/src/app/dashboard/add-data.component.html index 2f6ca73..c5e5f0a 100644 --- a/src/app/dashboard/add-data.component.html +++ b/src/app/dashboard/add-data.component.html @@ -48,19 +48,19 @@
@@ -75,13 +75,13 @@ -
-
diff --git a/src/app/dashboard/add-data.component.ts b/src/app/dashboard/add-data.component.ts index 66dfa08..d2e806d 100644 --- a/src/app/dashboard/add-data.component.ts +++ b/src/app/dashboard/add-data.component.ts @@ -30,8 +30,6 @@ export class AddDataComponent implements OnInit { organisationTown: string; organisationPostcode: string; amount: number; - // Assumes Groceries is 1st category - categoryId: number = 1; essentialPurchase = false; recurringPurchase = false; recurringType: string; @@ -44,8 +42,9 @@ export class AddDataComponent implements OnInit { minDate: any; leftCategoryIdList: number[] = []; rightCategoryIdList: number[] = []; - leftCategoryNameList: number[] = []; - rightCategoryNameList: number[] = []; + leftCategoryNameList: string[] = []; + rightCategoryNameList: string[] = []; + categoryList: any; constructor( private formBuilder: FormBuilder, @@ -90,13 +89,9 @@ export class AddDataComponent implements OnInit { } private setCategoryList(data: any) { - let categoryIdList = Object.keys(data.ids).map(key => data.ids[key]); - let categoryNameList = Object.keys(data.names).map(key => data.names[key]); - let halfLength = Math.floor(categoryIdList.length / 2); - this.leftCategoryIdList = categoryIdList.splice(0, halfLength); - this.leftCategoryNameList = categoryNameList.splice(0, halfLength); - this.rightCategoryIdList = categoryIdList; - this.rightCategoryNameList = categoryNameList; + let halfLength = Math.floor(data.length / 2); + this.leftCategoryList = data.splice(0, halfLength); + this.rightCategoryList = data; } getMinDate() { From b9578da5793209330f9cd2755dfc25179fa778a4 Mon Sep 17 00:00:00 2001 From: piratefinn Date: Wed, 14 Mar 2018 20:06:21 +0000 Subject: [PATCH 07/16] Added initial recurring variable viewing --- src/app/dashboard/dashboard.module.ts | 4 + .../dashboard/transaction-log.component.html | 80 ++++++++++-- .../dashboard/transaction-log.component.ts | 117 +++++++++++++++--- src/app/shared/recur-result.component.html | 6 + src/app/shared/recur-result.component.ts | 38 ++++++ src/app/shared/recur-table.component.html | 17 +++ src/app/shared/recur-table.component.ts | 27 ++++ 7 files changed, 257 insertions(+), 32 deletions(-) create mode 100644 src/app/shared/recur-result.component.html create mode 100644 src/app/shared/recur-result.component.ts create mode 100644 src/app/shared/recur-table.component.html create mode 100644 src/app/shared/recur-table.component.ts diff --git a/src/app/dashboard/dashboard.module.ts b/src/app/dashboard/dashboard.module.ts index 2e47f80..21573f4 100644 --- a/src/app/dashboard/dashboard.module.ts +++ b/src/app/dashboard/dashboard.module.ts @@ -31,6 +31,8 @@ import { PiePanel } from '../panels/pie-panel.component'; import { DashboardRoutingModule } from './dashboard.routing'; import { OrgResultComponent } from '../shared/org-result.component'; import { OrgTableComponent } from '../shared/org-table.component'; +import { RecurResultComponent } from '../shared/recur-result.component'; +import { RecurTableComponent } from '../shared/recur-table.component'; import { TransactionResultComponent } from '../shared/transaction-result.component'; import { PayrollResultComponent } from '../shared/payroll-result.component'; import { LeaderboardResultComponent } from '../shared/leaderboard-result.component'; @@ -61,6 +63,8 @@ import { environment } from '../../environments/environment'; AddDataComponent, OrgResultComponent, OrgTableComponent, + RecurResultComponent, + RecurTableComponent, TransactionLogComponent, CategoryMonthComponent, TransactionResultComponent, diff --git a/src/app/dashboard/transaction-log.component.html b/src/app/dashboard/transaction-log.component.html index f6f4bbf..5e7dde2 100644 --- a/src/app/dashboard/transaction-log.component.html +++ b/src/app/dashboard/transaction-log.component.html @@ -47,21 +47,75 @@
Recurring Transactions - Here you can control your recurring transactions. + Select a Recurring Transaction below to edit it.
- - - - - - - - - - - -
SellerValuePurchase Time
+ + + + +
No Recurring Transactions. diff --git a/src/app/dashboard/transaction-log.component.ts b/src/app/dashboard/transaction-log.component.ts index 03bcd9e..c379a9a 100644 --- a/src/app/dashboard/transaction-log.component.ts +++ b/src/app/dashboard/transaction-log.component.ts @@ -1,10 +1,8 @@ -import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; +import { Component, OnInit, EventEmitter, TemplateRef } from '@angular/core'; import { ApiService } from '../providers/api-service'; -// import { PaginatePipe } from 'ngx-pagination'; -import {PaginationInstance} from 'ngx-pagination'; -// import { PaginationControlsComponent } from 'ngx-pagination'; -// import { PaginationControlsDirective } from 'ngx-pagination'; -// import { TransactionResultComponent } from '../shared/transaction-result.component'; +import { BsModalService, ModalDirective } from 'ngx-bootstrap/modal'; +import { BsModalRef } from 'ngx-bootstrap/modal/bs-modal-ref.service'; +import { PaginationInstance } from 'ngx-pagination'; import * as moment from 'moment'; import 'rxjs/add/operator/map'; @@ -13,12 +11,19 @@ import 'rxjs/add/operator/map'; }) export class TransactionLogComponent implements OnInit { - transactionList; + transactionList: any; + recurringTransactionList: any; noTransactionList = true; noRecurringList = true; myDate: any; minDate: any; public p: any; + public modalRef: BsModalRef; + clickedRecur: any; + public updatedDate: string; + public startTime: string; + categoryIdList: number[] = []; + categoryNameList: string[] = []; public paginateConfig: PaginationInstance = { id: 'transpaginate', @@ -29,27 +34,33 @@ export class TransactionLogComponent implements OnInit { constructor( private api: ApiService, + private modalService: BsModalService, ) { this.myDate = moment().format('YYYY-MM-DD[T]HH:mm'); + this.api.categoryList().subscribe( + result => { + //this.setCategoryList(result.categories); + this.categoryIdList = result.categories; + }, + error => { + console.log('Retrieval Error'); + console.log( error._body ); + } + ); // this.myDate = new Date().toISOString().slice(0, 16); } ngOnInit(): void { - this.getMinDate(); this.loadTransactions(1); } - getMinDate() { - // gets the April 1st date of the current year - const aprilDate = moment().month(3).date(1); - const now = moment(); - // Checks if current time is before April 1st, if so returns true - const beforeApril = now.isBefore(aprilDate); - if ( beforeApril === true ) { - this.minDate = aprilDate.subtract(2, 'years').format('YYYY-MM-DD'); - } else { - this.minDate = aprilDate.subtract(1, 'years').format('YYYY-MM-DD'); - } + private setCategoryList(data: any) { + this.categoryIdList = Object.keys(data.ids).map(key => data.ids[key]); + this.categoryNameList = Object.keys(data.names).map(key => data.names[key]); + } + + byId(c1: ItemModel, c2: ItemModel) { + return c1 && c2 ? c1.id === c2.id : c1 === c2; } loadTransactions(logPage: number) { @@ -66,6 +77,13 @@ export class TransactionLogComponent implements OnInit { this.transactionList = null; this.noTransactionList = true; } + if (result.recurring_transactions) { + this.recurringTransactionList = result.recurring_transactions; + this.noRecurringList = false; + } else { + this.recurringTransactionList = null; + this.noRecurringList = true; + } }, error => { console.log(error); @@ -73,4 +91,65 @@ export class TransactionLogComponent implements OnInit { ); } + recurringTransactionDetails(clicked, template: TemplateRef) { + this.clickedRecur = clicked; + console.log(this.clickedRecur); + this.updatedTime = moment(this.clickedRecur.last_updated).format('YYYY-MM-DD[T]HH:mm'); + this.startTime = moment(this.clickedRecur.start_time).format('YYYY-MM-DD[T]HH:mm'); + this.openModal(template); + } + + openModal(template: TemplateRef) { + this.modalRef = this.modalService.show(template); + } + + editRecurringTransaction() { + let updatedDateSubmit = moment(this.updatedTime, 'YYYY-MM-DD[T]HH:mm').local().format('YYYY-MM-DD[T]HH:mm:ss.SSSZ'); + let startTimeSubmit = moment(this.startTime, 'YYYY-MM-DD[T]HH:mm').local().format('YYYY-MM-DD[T]HH:mm:ss.SSSZ'); + let myParams = { + category: this.clickedRecur.category, + essential: this.clickedRecur.essential, + id: this.clickedRecur.id, + last_updated: this.updatedDate, + recurring_period: this.updatedDateSubmit, + seller: this.clickedRecur.seller, + start_time: this.startTimeSubmit, + value: this.clickedRecur.value, + }; + /******************************/ + + this.api + .upload(myParams) + .subscribe( + result => { + if ( result.success === true ) { + console.log('Successful Upload'); + console.log(result); + this.transactionFormStatus = 'success'; + console.log(this.transactionFormStatus); + this.resetForm(); + } else { + console.log('Upload Error'); + this.transactionFormStatusError = JSON.stringify(result.status) + 'Error, ' + JSON.stringify(result.message); + this.transactionFormStatus = 'send_failed'; + console.log(this.transactionFormStatus); + } + }, + error => { + console.log('Upload Error'); + console.log(error); + try { + console.log(error.error); + const jsonError = error.json(); + console.log('boop'); + this.transactionFormStatusError = '"' + jsonError.error + '" Error, ' + jsonError.message; + } catch (e) { + this.transactionFormStatusError = 'There was a server error, please try again later.'; + } + this.transactionFormStatus = 'send_failed'; + console.log(this.transactionFormStatus); + } + ); + } + } diff --git a/src/app/shared/recur-result.component.html b/src/app/shared/recur-result.component.html new file mode 100644 index 0000000..ece4592 --- /dev/null +++ b/src/app/shared/recur-result.component.html @@ -0,0 +1,6 @@ +{{recur.seller}} +{{recur.category}} +{{recur.essential}} +{{updatedDate}} +{{recur.recurring_period}} +{{recur.value}} diff --git a/src/app/shared/recur-result.component.ts b/src/app/shared/recur-result.component.ts new file mode 100644 index 0000000..56a7954 --- /dev/null +++ b/src/app/shared/recur-result.component.ts @@ -0,0 +1,38 @@ +import { Component, Input, Output, EventEmitter } from '@angular/core'; +import * as moment from 'moment'; + +interface RecurData { + category: string; + essential: number; + id: number; + last_updated: string; + recurring_period: string; + seller: string; + start_time: string; + value: number; +} + +@Component({ + // tslint:disable-next-line + selector: '[recur-result]', + templateUrl: 'recur-result.component.html', +}) +export class RecurResultComponent { + @Input() public recur: RecurData; + @Output() public onClick = new EventEmitter(); + public updatedDate: string; + + ngOnInit(): void { + if (this.recur.last_updated) { + this.updatedDate = moment(this.recur.last_updated).format('llll'); + } else { + this.updatedDate = moment(this.recur.start_time).format('llll'); + } + } + + public recurClick(): void { + this.onClick.emit( + this.recur + ); + } +} diff --git a/src/app/shared/recur-table.component.html b/src/app/shared/recur-table.component.html new file mode 100644 index 0000000..532fbb7 --- /dev/null +++ b/src/app/shared/recur-table.component.html @@ -0,0 +1,17 @@ +
+ + + + + + + + + + + + + + +
SellerCategoryEssentialLast UpdatedRecurring PeriodValue
+
diff --git a/src/app/shared/recur-table.component.ts b/src/app/shared/recur-table.component.ts new file mode 100644 index 0000000..4cf73cb --- /dev/null +++ b/src/app/shared/recur-table.component.ts @@ -0,0 +1,27 @@ +import { Component, Input, Output, EventEmitter } from '@angular/core'; +import { RecurResultComponent } from '../shared/recur-result.component'; + +interface RecurData { + category: string; + essential: number; + id: number; + last_updated: string; + recurring_period: string; + seller: string; + start_time: string; + value: number; +} + +@Component({ + // tslint:disable-next-line + selector: 'recur-table', + templateUrl: 'recur-table.component.html', +}) +export class RecurTableComponent { + @Input() public recurList: Array; + @Output() public onClick = new EventEmitter(); + + public recurClick(event: any): void { + this.onClick.emit( event ); + } +} From f36ef00478084b0a66e3b3ec0bf74512b61031c4 Mon Sep 17 00:00:00 2001 From: piratefinn Date: Mon, 19 Mar 2018 16:28:46 +0000 Subject: [PATCH 08/16] fixed add data submission and removed unnecessary console logs --- src/app/dashboard/add-data.component.ts | 8 +++----- src/app/dashboard/transaction-log.component.ts | 18 ------------------ 2 files changed, 3 insertions(+), 23 deletions(-) diff --git a/src/app/dashboard/add-data.component.ts b/src/app/dashboard/add-data.component.ts index d2e806d..2001cf5 100644 --- a/src/app/dashboard/add-data.component.ts +++ b/src/app/dashboard/add-data.component.ts @@ -40,11 +40,9 @@ export class AddDataComponent implements OnInit { transactionFormInvalid = true; myDate: any; minDate: any; - leftCategoryIdList: number[] = []; - rightCategoryIdList: number[] = []; - leftCategoryNameList: string[] = []; - rightCategoryNameList: string[] = []; - categoryList: any; + leftCategoryList: number[] = []; + rightCategoryList: string[] = []; + categoryId: number; constructor( private formBuilder: FormBuilder, diff --git a/src/app/dashboard/transaction-log.component.ts b/src/app/dashboard/transaction-log.component.ts index c379a9a..c3e22d1 100644 --- a/src/app/dashboard/transaction-log.component.ts +++ b/src/app/dashboard/transaction-log.component.ts @@ -124,30 +124,12 @@ export class TransactionLogComponent implements OnInit { result => { if ( result.success === true ) { console.log('Successful Upload'); - console.log(result); - this.transactionFormStatus = 'success'; - console.log(this.transactionFormStatus); - this.resetForm(); } else { console.log('Upload Error'); - this.transactionFormStatusError = JSON.stringify(result.status) + 'Error, ' + JSON.stringify(result.message); - this.transactionFormStatus = 'send_failed'; - console.log(this.transactionFormStatus); } }, error => { console.log('Upload Error'); - console.log(error); - try { - console.log(error.error); - const jsonError = error.json(); - console.log('boop'); - this.transactionFormStatusError = '"' + jsonError.error + '" Error, ' + jsonError.message; - } catch (e) { - this.transactionFormStatusError = 'There was a server error, please try again later.'; - } - this.transactionFormStatus = 'send_failed'; - console.log(this.transactionFormStatus); } ); } From 3e8767e481d275f385e0670df27ed726c57e5427 Mon Sep 17 00:00:00 2001 From: piratefinn Date: Mon, 19 Mar 2018 17:52:54 +0000 Subject: [PATCH 09/16] fixed category viewing and editing on several pages --- src/app/dashboard/add-data.component.html | 8 +++---- src/app/dashboard/add-data.component.ts | 6 ++++- .../dashboard/category-month.component.html | 24 +++++++++---------- src/app/dashboard/category-month.component.ts | 12 +++------- .../dashboard/transaction-log.component.html | 8 +++---- .../dashboard/transaction-log.component.ts | 10 +++----- src/app/shared/recur-result.component.html | 2 +- src/app/shared/recur-result.component.ts | 3 ++- src/app/shared/recur-table.component.html | 2 +- src/app/shared/recur-table.component.ts | 2 ++ 10 files changed, 37 insertions(+), 40 deletions(-) diff --git a/src/app/dashboard/add-data.component.html b/src/app/dashboard/add-data.component.html index c5e5f0a..f1630c4 100644 --- a/src/app/dashboard/add-data.component.html +++ b/src/app/dashboard/add-data.component.html @@ -75,13 +75,13 @@ -
-
diff --git a/src/app/dashboard/add-data.component.ts b/src/app/dashboard/add-data.component.ts index 2001cf5..ee65cee 100644 --- a/src/app/dashboard/add-data.component.ts +++ b/src/app/dashboard/add-data.component.ts @@ -40,6 +40,8 @@ export class AddDataComponent implements OnInit { transactionFormInvalid = true; myDate: any; minDate: any; + categoryList: any; + categoryIdList: any; leftCategoryList: number[] = []; rightCategoryList: string[] = []; categoryId: number; @@ -72,7 +74,9 @@ export class AddDataComponent implements OnInit { // this.myDate = new Date().toISOString().slice(0, 16); this.api.categoryList().subscribe( result => { - this.setCategoryList(result.categories); + this.categoryList = result.categories; + this.categoryIdList = Object.keys(this.categoryList); + this.setCategoryList(this.categoryIdList); }, error => { console.log('Retrieval Error'); diff --git a/src/app/dashboard/category-month.component.html b/src/app/dashboard/category-month.component.html index 7bb83db..db24b1f 100644 --- a/src/app/dashboard/category-month.component.html +++ b/src/app/dashboard/category-month.component.html @@ -12,8 +12,8 @@
  • Essential Purchases - {{ ( weekEssential1.value || 0 ) | currency:'GBP':'symbol':'1.2-2' }} - ({{ (weekEssential1.value || 0 ) / weekListValueSum1 | percent:'1.0-0' }}) + {{ ( weekEssential1 ? weekEssential1.value : 0 ) | currency:'GBP':'symbol':'1.2-2' }} + ({{ ( weekEssential1 ? weekEssential1.value : 0 ) / weekListValueSum1 | percent:'1.0-0' }})
  • - {{ categoryNameList[categoryEntry.category - 1] || 'Uncategorised' }} + {{ categoryList[categoryEntry.category] || 'Uncategorised' }} {{ ( categoryEntry.value || 0 ) | currency:'GBP':'symbol':'1.2-2' }} ({{ (categoryEntry.value || 0 ) / weekListValueSum1 | percent:'1.0-0' }})
    @@ -54,8 +54,8 @@
    • Essential Purchases - {{ ( weekEssential2.value || 0 ) | currency:'GBP':'symbol':'1.2-2' }} - ({{ (weekEssential2.value || 0 ) / weekListValueSum2 | percent:'1.0-0' }}) + {{ ( weekEssential2 ? weekEssential2.value : 0 ) | currency:'GBP':'symbol':'1.2-2' }} + ({{ ( weekEssential2 ? weekEssential2.value : 0 ) / weekListValueSum2 | percent:'1.0-0' }})
    • - {{ categoryNameList[categoryEntry.category - 1] || 'Uncategorised' }} + {{ categoryList[categoryEntry.category] || 'Uncategorised' }} {{ ( categoryEntry.value || 0 ) | currency:'GBP':'symbol':'1.2-2' }} ({{ (categoryEntry.value || 0 ) / weekListValueSum2 | percent:'1.0-0' }})
      @@ -96,8 +96,8 @@
      • Essential Purchases - {{ ( weekEssential1.value || 0 ) | currency:'GBP':'symbol':'1.2-2' }} - ({{ (weekEssential3.value || 0 ) / weekListValueSum3 | percent:'1.0-0' }}) + {{ ( weekEssential3 ? weekEssential3.value : 0 ) | currency:'GBP':'symbol':'1.2-2' }} + ({{ ( weekEssential3 ? weekEssential3.value : 0 ) / weekListValueSum3 | percent:'1.0-0' }})
      • - {{ categoryNameList[categoryEntry.category - 1] || 'Uncategorised' }} + {{ categoryList[categoryEntry.category] || 'Uncategorised' }} {{ ( categoryEntry.value || 0 ) | currency:'GBP':'symbol':'1.2-2' }} ({{ (categoryEntry.value || 0 ) / weekListValueSum3 | percent:'1.0-0' }})
        @@ -138,8 +138,8 @@
        • Essential Purchases - {{ ( weekEssential4.value || 0 ) | currency:'GBP':'symbol':'1.2-2' }} - ({{ (weekEssential4.value || 0 ) / weekListValueSum4 | percent:'1.0-0' }}) + {{ ( weekEssential4 ? weekEssential4.value : 0 ) | currency:'GBP':'symbol':'1.2-2' }} + ({{ ( weekEssential4 ? weekEssential4.value : 0 ) / weekListValueSum4 | percent:'1.0-0' }})
        • - {{ categoryNameList[categoryEntry.category - 1] || 'Uncategorised' }} + {{ categoryList[categoryEntry.category] || 'Uncategorised' }} {{ ( categoryEntry.value || 0 ) | currency:'GBP':'symbol':'1.2-2' }} ({{ (categoryEntry.value || 0 ) / weekListValueSum4 | percent:'1.0-0' }})
          diff --git a/src/app/dashboard/category-month.component.ts b/src/app/dashboard/category-month.component.ts index 809e71f..140e8e3 100644 --- a/src/app/dashboard/category-month.component.ts +++ b/src/app/dashboard/category-month.component.ts @@ -31,15 +31,13 @@ export class CategoryMonthComponent implements OnInit { weekEssential3: number = 0; weekEssential4: number = 0; - categoryList: number[] = []; + categoryList: any; dayList: any[] = []; valueList: number[] = []; myWeek1: any; myWeek2: any; myWeek3: any; myWeek4: any; - categoryIdList: number[] = []; - categoryNameList: string[] = []; categoryLimit1: number = 6; categoryLimit2: number = 6; categoryLimit3: number = 6; @@ -51,7 +49,8 @@ export class CategoryMonthComponent implements OnInit { this.setDate(); this.api.categoryList().subscribe( result => { - this.setCategoryList(result.categories); + this.categoryList = result.categories; + console.log('Category List received'); }, error => { console.log('Retrieval Error'); @@ -72,11 +71,6 @@ export class CategoryMonthComponent implements OnInit { ngOnInit(): void { } - private setCategoryList(data: any) { - this.categoryIdList = Object.keys(data.ids).map(key => data.ids[key]); - this.categoryNameList = Object.keys(data.names).map(key => data.names[key]); - } - private setDate () { this.myWeek1 = moment().startOf('isoWeek').format('YYYY-MM-DD'); this.myWeek2 = moment(this.myWeek1).subtract(1, 'weeks').format('YYYY-MM-DD'); diff --git a/src/app/dashboard/transaction-log.component.html b/src/app/dashboard/transaction-log.component.html index 5e7dde2..d24c301 100644 --- a/src/app/dashboard/transaction-log.component.html +++ b/src/app/dashboard/transaction-log.component.html @@ -50,7 +50,7 @@ Select a Recurring Transaction below to edit it.
          - +
          +
          +
          + WARNING: Clicking "Delete" will completely remove the Recurring Transaction. +
          +
          +
          +
          + + +
          +
          +
        +
      diff --git a/src/app/dashboard/transaction-log.component.ts b/src/app/dashboard/transaction-log.component.ts index d05babe..e9e10ce 100644 --- a/src/app/dashboard/transaction-log.component.ts +++ b/src/app/dashboard/transaction-log.component.ts @@ -25,6 +25,8 @@ export class TransactionLogComponent implements OnInit { categoryIdList: number[] = []; categoryList: any; categoryNameList: string[] = []; + transactionFormStatus: string; + transactionFormStatusError = 'Error received, please try again.'; public paginateConfig: PaginationInstance = { id: 'transpaginate', @@ -89,9 +91,7 @@ export class TransactionLogComponent implements OnInit { recurringTransactionDetails(clicked, template: TemplateRef) { this.clickedRecur = clicked; - console.log(this.clickedRecur); - this.updatedTime = moment(this.clickedRecur.last_updated).format('YYYY-MM-DD[T]HH:mm'); - this.startTime = moment(this.clickedRecur.start_time).format('YYYY-MM-DD[T]HH:mm'); + this.updatedTime = moment(this.clickedRecur.display_time, 'llll').format('YYYY-MM-DD[T]HH:mm'); this.openModal(template); } @@ -100,34 +100,44 @@ export class TransactionLogComponent implements OnInit { } editRecurringTransaction() { - let updatedDateSubmit = moment(this.updatedTime, 'YYYY-MM-DD[T]HH:mm').local().format('YYYY-MM-DD[T]HH:mm:ss.SSSZ'); - let startTimeSubmit = moment(this.startTime, 'YYYY-MM-DD[T]HH:mm').local().format('YYYY-MM-DD[T]HH:mm:ss.SSSZ'); + let updatedTimeSubmit = moment(this.updatedTime, 'YYYY-MM-DD[T]HH:mm').local().format('YYYY-MM-DD[T]HH:mm:ss.SSSZ'); + this.clickedRecur.display_time = moment(this.updatedTime).format('llll'); let myParams = { - category: this.clickedRecur.category, + category: 111, essential: this.clickedRecur.essential, id: this.clickedRecur.id, - last_updated: this.updatedDate, - recurring_period: this.updatedDateSubmit, + apply_time: updatedTimeSubmit, + recurring_period: this.clickedRecur.recurring_period, seller: this.clickedRecur.seller, - start_time: this.startTimeSubmit, value: this.clickedRecur.value, }; - /******************************/ - this.api - .upload(myParams) + .recurUpdate(myParams) .subscribe( result => { if ( result.success === true ) { - console.log('Successful Upload'); + this.transactionFormStatus = 'success'; + this.resetForm(); } else { - console.log('Upload Error'); + this.transactionFormStatusError = JSON.stringify(result.status) + 'Error, ' + JSON.stringify(result.message); + this.transactionFormStatus = 'send_failed'; } }, error => { - console.log('Upload 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'; } ); } + deleteRecurringTransaction() { + + } + } diff --git a/src/app/providers/api-service.ts b/src/app/providers/api-service.ts index bbf3464..519d272 100644 --- a/src/app/providers/api-service.ts +++ b/src/app/providers/api-service.ts @@ -158,6 +158,16 @@ export class ApiService { ); } + // Uploads a transaction + + public recurUpdate(data) { + data.session_key = this.sessionKey; + return this.http.post( + this.apiUrl + '/recurring-transactions', + data + ); + } + // gets payroll list for log public payrollList(data) { diff --git a/src/app/shared/recur-result.component.html b/src/app/shared/recur-result.component.html index c716883..c494b71 100644 --- a/src/app/shared/recur-result.component.html +++ b/src/app/shared/recur-result.component.html @@ -1,6 +1,6 @@ {{recur.seller}} {{categories[recur.category] || 'Uncategorised'}} -{{recur.essential}} -{{updatedDate}} +{{recur.essential == 1 ? 'true' : 'false'}} +{{recur.display_time}} {{recur.recurring_period}} {{recur.value}} diff --git a/src/app/shared/recur-result.component.ts b/src/app/shared/recur-result.component.ts index ca495b4..3532464 100644 --- a/src/app/shared/recur-result.component.ts +++ b/src/app/shared/recur-result.component.ts @@ -10,6 +10,7 @@ interface RecurData { seller: string; start_time: string; value: number; + display_time: any; } @Component({ @@ -25,9 +26,9 @@ export class RecurResultComponent { ngOnInit(): void { if (this.recur.last_updated) { - this.updatedDate = moment(this.recur.last_updated).format('llll'); + this.recur.display_time = moment(this.recur.last_updated).format('llll'); } else { - this.updatedDate = moment(this.recur.start_time).format('llll'); + this.recur.display_time = moment(this.recur.start_time).format('llll'); } } diff --git a/src/app/shared/recur-table.component.html b/src/app/shared/recur-table.component.html index 35fd96e..a6ec55d 100644 --- a/src/app/shared/recur-table.component.html +++ b/src/app/shared/recur-table.component.html @@ -5,7 +5,7 @@ Seller Category Essential - Last Updated + Last Applied Recurring Period Value diff --git a/src/app/shared/recur-table.component.ts b/src/app/shared/recur-table.component.ts index 0b5e32d..c2f6ef0 100644 --- a/src/app/shared/recur-table.component.ts +++ b/src/app/shared/recur-table.component.ts @@ -10,6 +10,7 @@ interface RecurData { seller: string; start_time: string; value: number; + display_time: any; } @Component({ From 463bbe98a9f30cb4ce00c9c7cd54d13385cafe77 Mon Sep 17 00:00:00 2001 From: piratefinn Date: Tue, 20 Mar 2018 17:29:00 +0000 Subject: [PATCH 12/16] fully working transaction edit and delete --- .../dashboard/transaction-log.component.html | 2 +- .../dashboard/transaction-log.component.ts | 28 ++++++++++++++++++- src/app/providers/api-service.ts | 12 +++++++- 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/src/app/dashboard/transaction-log.component.html b/src/app/dashboard/transaction-log.component.html index 0638a50..09ced33 100644 --- a/src/app/dashboard/transaction-log.component.html +++ b/src/app/dashboard/transaction-log.component.html @@ -122,7 +122,7 @@