Merge pull request #59 from Pear-Trading/finn/categories

Added categories to transactions
This commit is contained in:
Finn 2018-01-17 14:51:46 +00:00 committed by GitHub
commit a2ff339a84
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 2232 additions and 941 deletions

View file

@ -2,6 +2,11 @@
# Next Release
# v0.1.1
* Redid layout on circle customer view
* Renamed customer dashboard headers
# v0.1.0
* Changed Story Trail choosing to modals

3096
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
{
"name": "localloop-web",
"version": "0.1.0",
"version": "0.1.1",
"description": "LocalLoop Web - Web interface for LocalLoop app",
"author": "",
"url": "http://www.peartrade.org",
@ -20,14 +20,14 @@
"dependencies": {
"@agm/core": "1.0.0-beta.2",
"@agm/js-marker-clusterer": "1.0.0-beta.2",
"@angular/common": "5.0.1",
"@angular/compiler": "5.0.1",
"@angular/core": "5.0.1",
"@angular/forms": "5.0.1",
"@angular/platform-browser": "5.0.1",
"@angular/platform-browser-dynamic": "5.0.1",
"@angular/router": "5.0.1",
"@angular/upgrade": "5.0.1",
"@angular/common": "5.2.0",
"@angular/compiler": "5.2.0",
"@angular/core": "5.2.0",
"@angular/forms": "5.2.0",
"@angular/platform-browser": "5.2.0",
"@angular/platform-browser-dynamic": "5.2.0",
"@angular/router": "5.2.0",
"@angular/upgrade": "5.2.0",
"@types/moment": "2.13.0",
"chart.js": "2.7.1",
"core-js": "2.5.1",
@ -37,15 +37,15 @@
"ng2-validation-manager": "0.5.3",
"ngx-bootstrap": "2.0.0-beta.8",
"ngx-pagination": "3.0.3",
"rxjs": "5.5.2",
"rxjs": "5.5.6",
"ts-helpers": "1.1.2",
"webpack": "3.8.1",
"webpack-dev-server": "2.9.4",
"zone.js": "0.8.18"
},
"devDependencies": {
"@angular/cli": "1.5.0",
"@angular/compiler-cli": "5.0.1",
"@angular/cli": "1.6.4",
"@angular/compiler-cli": "5.2.0",
"@types/jasmine": "2.8.2",
"@types/jasminewd2": "2.0.3",
"@types/node": "8.0.52",
@ -61,6 +61,6 @@
"protractor": "5.2.0",
"ts-node": "3.3.0",
"tslint": "5.8.0",
"typescript": "2.4.2"
"typescript": "2.6.x"
}
}

View file

@ -24,6 +24,20 @@
<span class="help-block">Enter the amount spent, such as 5.35 for £5.35.</span>
</div>
</div>
<div class="form-group row">
<label class="col-md-3 form-control-label" for="text-input">Category</label>
<div class="col-md-9">
<div class="input-group">
<select type="text" class="form-control" [(ngModel)]="categoryId">
<option value="">Uncategorised</option>
<option *ngFor="let category of categoryIdList, let i=index" [ngValue]="category" >
{{ categoryNameList[i] }}
</option>
</select>
</div>
<span class="help-block"><strong>Optional:</strong> Choose the relevant Category for the purchase.</span>
</div>
</div>
<div class="form-group row">
<label class="col-md-3 form-control-label" for="text-input"><strong>Organisation Name</strong></label>
<div class="col-md-9">

View file

@ -30,6 +30,8 @@ export class AddDataComponent implements OnInit {
organisationTown: string;
organisationPostcode: string;
amount: number;
// Assumes Groceries is 1st category
categoryId: number = 1;
transactionAdditionType = 1;
storeList = [];
showAddStore = false;
@ -37,6 +39,8 @@ export class AddDataComponent implements OnInit {
transactionFormInvalid = true;
myDate: any;
minDate: any;
categoryIdList: number[] = [];
categoryNameList: string[] = [];
constructor(
private formBuilder: FormBuilder,
@ -64,6 +68,15 @@ export class AddDataComponent implements OnInit {
});
this.myDate = moment().format('YYYY-MM-DD[T]HH:mm');
// this.myDate = new Date().toISOString().slice(0, 16);
this.api.categoryList().subscribe(
result => {
this.setCategoryList(result.categories);
},
error => {
console.log('Retrieval Error');
console.log( error._body );
}
);
}
ngOnInit(): void {
@ -71,6 +84,11 @@ export class AddDataComponent implements OnInit {
this.accountType = localStorage.getItem('usertype');
}
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]);
}
getMinDate() {
// gets the April 1st date of the current year
const aprilDate = moment().month(3).date(1);
@ -170,6 +188,7 @@ export class AddDataComponent implements OnInit {
transaction_value : this.amount,
purchase_time : purchaseTime,
organisation_id : this.organisationId,
category : this.categoryId,
};
break;
case 2:
@ -178,6 +197,7 @@ export class AddDataComponent implements OnInit {
transaction_value : this.amount,
purchase_time : purchaseTime,
organisation_id : this.organisationId,
category : this.categoryId,
};
break;
case 3:
@ -189,6 +209,7 @@ export class AddDataComponent implements OnInit {
street_name : this.submitOrg.street_name,
town : this.submitOrg.town,
postcode : this.submitOrg.postcode,
category : this.categoryId,
};
break;
}

View file

@ -116,6 +116,17 @@ export class ApiService {
);
}
// Basic Customer User stats API
public categoryList() {
const key = this.sessionKey;
return this.http.post<any>(
this.apiUrl + '/search/category',
{
session_key : key,
}
);
}
// Searches organisations used for transaction submission
public search(data) {