fixed upload submissions

This commit is contained in:
piratefinn 2018-03-14 20:05:46 +00:00
parent e1dfa37f63
commit c45790c7e9
2 changed files with 15 additions and 20 deletions

View file

@ -48,19 +48,19 @@
<div class="row"> <div class="row">
<div class="col-md-6 btn-group-vertical"> <div class="col-md-6 btn-group-vertical">
<label class="btn btn-secondary mb-0" [class.active]="recurringType == 'daily'"> <label class="btn btn-secondary mb-0" [class.active]="recurringType == 'daily'">
<input value="daily" type="radio" name="radios" style="display:none;" [(ngModel)]="categoryId" (ngModelChange)="transactionFormValidate()">Daily <input value="daily" type="radio" name="radios" style="display:none;" [(ngModel)]="recurringType" (ngModelChange)="transactionFormValidate()">Daily
</label> </label>
<label class="btn btn-secondary mb-0" [class.active]="recurringType == 'weekly'"> <label class="btn btn-secondary mb-0" [class.active]="recurringType == 'weekly'">
<input value="weekly" type="radio" name="radios" style="display:none;" [(ngModel)]="categoryId" (ngModelChange)="transactionFormValidate()">Weekly <input value="weekly" type="radio" name="radios" style="display:none;" [(ngModel)]="recurringType" (ngModelChange)="transactionFormValidate()">Weekly
</label> </label>
<label class="btn btn-secondary mb-0" [class.active]="recurringType == 'fortnightly'"> <label class="btn btn-secondary mb-0" [class.active]="recurringType == 'fortnightly'">
<input value="fortnightly" type="radio" name="radios" style="display:none;" [(ngModel)]="categoryId" (ngModelChange)="transactionFormValidate()">Fortnightly <input value="fortnightly" type="radio" name="radios" style="display:none;" [(ngModel)]="recurringType" (ngModelChange)="transactionFormValidate()">Fortnightly
</label> </label>
<label class="btn btn-secondary mb-0" [class.active]="recurringType == 'monthly'"> <label class="btn btn-secondary mb-0" [class.active]="recurringType == 'monthly'">
<input value="monthly" type="radio" name="radios" style="display:none;" [(ngModel)]="categoryId" (ngModelChange)="transactionFormValidate()">Monthly <input value="monthly" type="radio" name="radios" style="display:none;" [(ngModel)]="recurringType" (ngModelChange)="transactionFormValidate()">Monthly
</label> </label>
<label class="btn btn-secondary mb-0" [class.active]="recurringType == 'quarterly'"> <label class="btn btn-secondary mb-0" [class.active]="recurringType == 'quarterly'">
<input value="quarterly" type="radio" name="radios" style="display:none;" [(ngModel)]="categoryId" (ngModelChange)="transactionFormValidate()">Quarterly <input value="quarterly" type="radio" name="radios" style="display:none;" [(ngModel)]="recurringType" (ngModelChange)="transactionFormValidate()">Quarterly
</label> </label>
</div> </div>
</div> </div>
@ -75,13 +75,13 @@
<label class="btn btn-secondary mb-0" [class.active]="categoryId == ''"> <label class="btn btn-secondary mb-0" [class.active]="categoryId == ''">
<input value="" type="radio" name="radios" style="display:none;" [(ngModel)]="categoryId">Uncategorised <input value="" type="radio" name="radios" style="display:none;" [(ngModel)]="categoryId">Uncategorised
</label> </label>
<label *ngFor="let category of leftCategoryIdList, let i=index" class="btn btn-secondary mb-0" [class.active]="categoryId == category"> <label *ngFor="let category of leftCategoryList" class="btn btn-secondary mb-0" [class.active]="categoryId == category.id">
<input [value]="category" type="radio" name="radios" style="display:none;" [(ngModel)]="categoryId">{{ leftCategoryNameList[i] }} <input [value]="category.id" type="radio" name="radios" style="display:none;" [(ngModel)]="categoryId">{{ category.name }}
</label> </label>
</div> </div>
<div class="col-md-6 btn-group-vertical"> <div class="col-md-6 btn-group-vertical">
<label *ngFor="let category2 of rightCategoryIdList, let i=index" class="btn btn-secondary mb-0" [class.active]=" categoryId == category2"> <label *ngFor="let category2 of rightCategoryList" class="btn btn-secondary mb-0" [class.active]=" categoryId == category2.id">
<input [value]="category2" type="radio" name="radios" style="display:none;" [(ngModel)]="categoryId">{{ rightCategoryNameList[i] }} <input [value]="category2.id" type="radio" name="radios" style="display:none;" [(ngModel)]="categoryId">{{ category2.name }}
</label> </label>
</div> </div>
</div> </div>

View file

@ -30,8 +30,6 @@ export class AddDataComponent implements OnInit {
organisationTown: string; organisationTown: string;
organisationPostcode: string; organisationPostcode: string;
amount: number; amount: number;
// Assumes Groceries is 1st category
categoryId: number = 1;
essentialPurchase = false; essentialPurchase = false;
recurringPurchase = false; recurringPurchase = false;
recurringType: string; recurringType: string;
@ -44,8 +42,9 @@ export class AddDataComponent implements OnInit {
minDate: any; minDate: any;
leftCategoryIdList: number[] = []; leftCategoryIdList: number[] = [];
rightCategoryIdList: number[] = []; rightCategoryIdList: number[] = [];
leftCategoryNameList: number[] = []; leftCategoryNameList: string[] = [];
rightCategoryNameList: number[] = []; rightCategoryNameList: string[] = [];
categoryList: any;
constructor( constructor(
private formBuilder: FormBuilder, private formBuilder: FormBuilder,
@ -90,13 +89,9 @@ export class AddDataComponent implements OnInit {
} }
private setCategoryList(data: any) { private setCategoryList(data: any) {
let categoryIdList = Object.keys(data.ids).map(key => data.ids[key]); let halfLength = Math.floor(data.length / 2);
let categoryNameList = Object.keys(data.names).map(key => data.names[key]); this.leftCategoryList = data.splice(0, halfLength);
let halfLength = Math.floor(categoryIdList.length / 2); this.rightCategoryList = data;
this.leftCategoryIdList = categoryIdList.splice(0, halfLength);
this.leftCategoryNameList = categoryNameList.splice(0, halfLength);
this.rightCategoryIdList = categoryIdList;
this.rightCategoryNameList = categoryNameList;
} }
getMinDate() { getMinDate() {