Add important validators #134
This commit is contained in:
parent
55db2069f7
commit
9dc3eb28cb
@ -21,7 +21,7 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="isin">isin</label>
|
<label for="isin">isin</label>
|
||||||
<input
|
<input
|
||||||
type="isin"
|
type="text"
|
||||||
class="form-control"
|
class="form-control"
|
||||||
name="isin"
|
name="isin"
|
||||||
[(ngModel)]="data.isin"
|
[(ngModel)]="data.isin"
|
||||||
@ -45,7 +45,7 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="count">Count</label>
|
<label for="count">Count</label>
|
||||||
<input
|
<input
|
||||||
type="count"
|
type="number"
|
||||||
class="form-control"
|
class="form-control"
|
||||||
name="count"
|
name="count"
|
||||||
[(ngModel)]="data.count"
|
[(ngModel)]="data.count"
|
||||||
@ -53,6 +53,9 @@
|
|||||||
count
|
count
|
||||||
#count="ngModel"
|
#count="ngModel"
|
||||||
/>
|
/>
|
||||||
|
<div class="alert-danger" *ngIf="!countValid">
|
||||||
|
Password does not match, make sure it is the same!
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="price">Price in $</label>
|
<label for="price">Price in $</label>
|
||||||
@ -64,6 +67,9 @@
|
|||||||
#price="ngModel"
|
#price="ngModel"
|
||||||
type="number"
|
type="number"
|
||||||
/>
|
/>
|
||||||
|
<div class="alert-danger" *ngIf="!priceValid">
|
||||||
|
Password does not match, make sure it is the same!
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group footer-buttons">
|
<div class="form-group footer-buttons">
|
||||||
<button class="btn btn-danger btn-block" mat-dialog-close>Cancel</button>
|
<button class="btn btn-danger btn-block" mat-dialog-close>Cancel</button>
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { Component, Inject, OnInit } from '@angular/core';
|
import { Component, Inject, OnInit } from '@angular/core';
|
||||||
|
import { FormControl } from '@angular/forms';
|
||||||
import {
|
import {
|
||||||
MatDialog,
|
MatDialog,
|
||||||
MatDialogRef,
|
MatDialogRef,
|
||||||
@ -21,8 +22,14 @@ export class UserDialogComponent {
|
|||||||
@Inject(MAT_DIALOG_DATA) public data: TransactionData
|
@Inject(MAT_DIALOG_DATA) public data: TransactionData
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
countValid = true;
|
||||||
|
priceValid = true;
|
||||||
|
|
||||||
onSubmit() {
|
onSubmit() {
|
||||||
//TODO check that price is decimal
|
console.log(!isNaN(this.data.count));
|
||||||
|
if (!isNaN(this.data.count) && !isNaN(this.data.price)) {
|
||||||
|
this.priceValid = true;
|
||||||
|
this.countValid = true;
|
||||||
console.log(
|
console.log(
|
||||||
this.dataService
|
this.dataService
|
||||||
.createTransaction(
|
.createTransaction(
|
||||||
@ -37,5 +44,15 @@ export class UserDialogComponent {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
this.dialog.closeAll();
|
this.dialog.closeAll();
|
||||||
|
} else if (isNaN(this.data.count) && !isNaN(this.data.price)) {
|
||||||
|
this.priceValid = true;
|
||||||
|
this.countValid = false;
|
||||||
|
} else if (!isNaN(this.data.count) && isNaN(this.data.price)) {
|
||||||
|
this.priceValid = false;
|
||||||
|
this.countValid = true;
|
||||||
|
} else {
|
||||||
|
this.countValid = false;
|
||||||
|
this.priceValid = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,7 @@
|
|||||||
<mat-form-field class="example-full-width" appearance="fill">
|
<mat-form-field class="example-full-width" appearance="fill">
|
||||||
<mat-label>Telegram UserId</mat-label>
|
<mat-label>Telegram UserId</mat-label>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="number"
|
||||||
matInput
|
matInput
|
||||||
[formControl]="telegramIdFormControl"
|
[formControl]="telegramIdFormControl"
|
||||||
[(ngModel)]="userId"
|
[(ngModel)]="userId"
|
||||||
|
Loading…
Reference in New Issue
Block a user