Merge remote-tracking branch 'origin/master' into theslby/pushapi

This commit is contained in:
Unknown 2018-01-19 13:40:17 +00:00
commit 175c2decdd
9 changed files with 2250 additions and 950 deletions

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" size="6">
<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

@ -4,15 +4,6 @@
<div class="col-sm-8">
<h4 class="card-title mb-0">All Purchases</h4>
</div><!--/.col-->
<div class="col-sm-4 hidden-sm-down">
<div class="btn-toolbar float-right" role="toolbar" aria-label="Toolbar with button groups">
<div class="btn-group mr-3" data-toggle="buttons" aria-label="First group">
<label class="btn btn-outline-secondary active">
<input type="radio" name="options" id="option2" checked> Week
</label>
</div>
</div>
</div><!--/.col-->
</div><!--/.row-->
<div class="chart-wrapper">
<canvas baseChart class="chart"

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) {