Add transaction skeletton
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
<h1 mat-dialog-title>Neue Transaktion hinzufügen</h1>
|
||||
<form
|
||||
name="form"
|
||||
(ngSubmit)="f.form.valid && onSubmit()"
|
||||
#f="ngForm"
|
||||
novalidate
|
||||
class="backgorund"
|
||||
>
|
||||
<div class="form-group">
|
||||
<label for="symbol">Symbol</label>
|
||||
<input
|
||||
type="symbol"
|
||||
class="form-control"
|
||||
name="symbol"
|
||||
[(ngModel)]="data.symbol"
|
||||
required
|
||||
symbol
|
||||
#symbol="ngModel"
|
||||
/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="time">Time</label>
|
||||
<input
|
||||
type="date"
|
||||
class="form-control"
|
||||
name="time"
|
||||
[(ngModel)]="data.time"
|
||||
required
|
||||
time
|
||||
#time="ngModel"
|
||||
/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="count">Count</label>
|
||||
<input
|
||||
type="count"
|
||||
class="form-control"
|
||||
name="count"
|
||||
[(ngModel)]="data.count"
|
||||
required
|
||||
count
|
||||
#count="ngModel"
|
||||
/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="price">Price</label>
|
||||
<input
|
||||
class="form-control"
|
||||
name="price"
|
||||
[(ngModel)]="data.price"
|
||||
required
|
||||
#price="ngModel"
|
||||
/>
|
||||
</div>
|
||||
<div class="form-group footer-buttons">
|
||||
<button class="btn btn-danger btn-block" mat-dialog-close>Cancel</button>
|
||||
<span class="spacer"></span>
|
||||
<button class="btn btn-primary btn-block">Confirm</button>
|
||||
</div>
|
||||
</form>
|
||||
@@ -0,0 +1,9 @@
|
||||
.spacer {
|
||||
flex-grow: 1;
|
||||
width: 5%;
|
||||
}
|
||||
|
||||
.footer-buttons {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { UserDialogComponent } from './user-dialog.component';
|
||||
|
||||
describe('UserDialogComponent', () => {
|
||||
let component: UserDialogComponent;
|
||||
let fixture: ComponentFixture<UserDialogComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ UserDialogComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(UserDialogComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,36 @@
|
||||
import { Component, Inject, OnInit } from '@angular/core';
|
||||
import {
|
||||
MatDialog,
|
||||
MatDialogRef,
|
||||
MAT_DIALOG_DATA,
|
||||
} from '@angular/material/dialog';
|
||||
import { DataService } from 'src/app/Services/data.service';
|
||||
|
||||
import { TransactionData } from '../dashboard.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-user-dialog',
|
||||
templateUrl: './user-dialog.component.html',
|
||||
styleUrls: ['./user-dialog.component.scss'],
|
||||
})
|
||||
export class UserDialogComponent implements OnInit {
|
||||
constructor(
|
||||
private dataService: DataService,
|
||||
public dialog: MatDialog,
|
||||
public dialogRef: MatDialogRef<UserDialogComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: TransactionData
|
||||
) {}
|
||||
|
||||
ngOnInit(): void {}
|
||||
|
||||
onSubmit() {
|
||||
console.log(this.data);
|
||||
this.dataService.createTransaction(
|
||||
this.data.symbol,
|
||||
this.data.time,
|
||||
this.data.count,
|
||||
this.data.price
|
||||
);
|
||||
this.dialog.closeAll();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user