Amended purchase validation and submission

This commit is contained in:
piratefinn 2018-03-13 12:49:30 +00:00
parent 977cee339d
commit 065aa80e98
4 changed files with 31 additions and 35 deletions

View file

@ -5,6 +5,9 @@
# v0.1.5 # v0.1.5
* Fixed category viewing on purchase * 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 # v0.1.4

View file

@ -46,29 +46,22 @@
<label class="col-md-3 form-control-label" for="text-input"><strong>Recurring Period</strong></label> <label class="col-md-3 form-control-label" for="text-input"><strong>Recurring Period</strong></label>
<div class="col-md-9"> <div class="col-md-9">
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-6 btn-group-vertical">
<div> <label class="btn btn-secondary mb-0" [class.active]="recurringType == 'daily'">
<input value="daily" type="radio" name="daily" [(ngModel)]="recurringType" (ngModelChange)="transactionFormValidate()"> <input value="daily" type="radio" name="radios" style="display:none;" [(ngModel)]="categoryId" (ngModelChange)="transactionFormValidate()">Daily
<label>Daily</label> </label>
</div> <label class="btn btn-secondary mb-0" [class.active]="recurringType == 'weekly'">
<div> <input value="weekly" type="radio" name="radios" style="display:none;" [(ngModel)]="categoryId" (ngModelChange)="transactionFormValidate()">Weekly
<input value="weekly" type="radio" name="weekly" [(ngModel)]="recurringType" (ngModelChange)="transactionFormValidate()"> </label>
<label>Weekly</label> <label class="btn btn-secondary mb-0" [class.active]="recurringType == 'fortnightly'">
</div> <input value="fortnightly" type="radio" name="radios" style="display:none;" [(ngModel)]="categoryId" (ngModelChange)="transactionFormValidate()">Fortnightly
<div> </label>
<input value="fortnightly" type="radio" name="fortnightly" [(ngModel)]="recurringType" (ngModelChange)="transactionFormValidate()"> <label class="btn btn-secondary mb-0" [class.active]="recurringType == 'monthly'">
<label>Fortnightly</label> <input value="monthly" type="radio" name="radios" style="display:none;" [(ngModel)]="categoryId" (ngModelChange)="transactionFormValidate()">Monthly
</div> </label>
</div> <label class="btn btn-secondary mb-0" [class.active]="recurringType == 'quarterly'">
<div class="col-md-6"> <input value="quarterly" type="radio" name="radios" style="display:none;" [(ngModel)]="categoryId" (ngModelChange)="transactionFormValidate()">Quarterly
<div> </label>
<input value="monthly" type="radio" name="monthly" [(ngModel)]="recurringType" (ngModelChange)="transactionFormValidate()">
<label>Monthly</label>
</div>
<div>
<input value="quarterly" type="radio" name="quarterly" [(ngModel)]="recurringType" (ngModelChange)="transactionFormValidate()">
<label>Quarterly</label>
</div>
</div> </div>
</div> </div>
<span class="help-block">Please give the period of time the purchase will recur from "Time of Transaction".</span> <span class="help-block">Please give the period of time the purchase will recur from "Time of Transaction".</span>
@ -86,7 +79,7 @@
<input [value]="category" type="radio" name="radios" style="display:none;" [(ngModel)]="categoryId">{{ leftCategoryNameList[i] }} <input [value]="category" type="radio" name="radios" style="display:none;" [(ngModel)]="categoryId">{{ leftCategoryNameList[i] }}
</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 rightCategoryIdList, let i=index" class="btn btn-secondary mb-0" [class.active]=" categoryId == category2">
<input [value]="category2" type="radio" name="radios" style="display:none;" [(ngModel)]="categoryId">{{ rightCategoryNameList[i] }} <input [value]="category2" type="radio" name="radios" style="display:none;" [(ngModel)]="categoryId">{{ rightCategoryNameList[i] }}
</label> </label>
@ -105,21 +98,21 @@
<org-table *ngIf="storeList.length > 0" [orgList]="storeList" (onClick)="addStore($event)"></org-table> <org-table *ngIf="storeList.length > 0" [orgList]="storeList" (onClick)="addStore($event)"></org-table>
<div *ngIf="showAddStore"> <div *ngIf="showAddStore">
<div class="form-group row"> <div class="form-group row">
<label class="col-md-3 form-control-label" for="text-input"><strong>Organisation Street Name</strong></label> <label class="col-md-3 form-control-label" for="text-input">Organisation Street Name</label>
<div class="col-md-9"> <div class="col-md-9">
<input type="text" class="form-control" placeholder="Which Street?" [(ngModel)]="submitOrg.street_name" (ngModelChange)="transactionFormValidate()"> <input type="text" class="form-control" placeholder="Which Street?" [(ngModel)]="submitOrg.street_name" (ngModelChange)="transactionFormValidate()">
<span class="help-block">Enter the street name where the organisation is located at.</span> <span class="help-block">Enter the street name where the organisation is located at.</span>
</div> </div>
</div> </div>
<div class="form-group row"> <div class="form-group row">
<label class="col-md-3 form-control-label" for="text-input"><strong>Organisation Town</strong></label> <label class="col-md-3 form-control-label" for="text-input">Organisation Town</label>
<div class="col-md-9"> <div class="col-md-9">
<input type="text" class="form-control" placeholder="Which Town?" [(ngModel)]="submitOrg.town" (ngModelChange)="transactionFormValidate()"> <input type="text" class="form-control" placeholder="Which Town?" [(ngModel)]="submitOrg.town" (ngModelChange)="transactionFormValidate()">
<span class="help-block">Enter the name of the town where the organisation is located at.</span> <span class="help-block">Enter the name of the town where the organisation is located at.</span>
</div> </div>
</div> </div>
<div class="form-group row"> <div class="form-group row">
<label class="col-md-3 form-control-label" for="text-input"><strong>Organisation Postcode</strong></label> <label class="col-md-3 form-control-label" for="text-input">Organisation Postcode</label>
<div class="col-md-9"> <div class="col-md-9">
<input type="text" class="form-control" placeholder="Postcode if known" [(ngModel)]="submitOrg.postcode" (ngModelChange)="transactionFormValidate()"> <input type="text" class="form-control" placeholder="Postcode if known" [(ngModel)]="submitOrg.postcode" (ngModelChange)="transactionFormValidate()">
<span class="help-block">Enter the postcode where the organisation is located at.</span> <span class="help-block">Enter the postcode where the organisation is located at.</span>

View file

@ -177,14 +177,15 @@ export class AddDataComponent implements OnInit {
} }
transactionFormValidate() { transactionFormValidate() {
if (this.submitOrg.name.length === 0 || if (this.submitOrg.name.length &&
this.submitOrg.town.length === 0 || this.amount &&
this.amount === 0 || (this.recurringPurchase &&
this.recurringPurchase && this.recurringType ||
!this.recurringType) { !this.recurringPurchase &&
this.transactionFormInvalid = true; !this.recurringType)) {
} else {
this.transactionFormInvalid = false; this.transactionFormInvalid = false;
} else {
this.transactionFormInvalid = true;
} }
} }

View file

@ -53,7 +53,6 @@ export class TransactionLogComponent implements OnInit {
} }
loadTransactions(logPage: number) { loadTransactions(logPage: number) {
console.log(logPage);
this.api.transList(logPage).subscribe( this.api.transList(logPage).subscribe(
result => { result => {
if (result.transactions.length > 0) { if (result.transactions.length > 0) {