61 lines
1.3 KiB
TypeScript
61 lines
1.3 KiB
TypeScript
import { Inject, Component, OnInit, OnDestroy, ViewEncapsulation } from '@angular/core';
|
|
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
|
import { FormBuilder, Validators, FormGroup, FormControl } from '@angular/forms';
|
|
import {User} from '../user.model';
|
|
import {Owner} from '../owner.model';
|
|
|
|
@Component({
|
|
selector: 'app-settings',
|
|
templateUrl: './settings.component.html',
|
|
styleUrls: ['/settings.component.css']
|
|
})
|
|
|
|
export class SettingsComponent implements OnInit {
|
|
|
|
settingsForm: FormGroup;
|
|
owner: Owner;
|
|
coins = [
|
|
{
|
|
label: 'US Dollar',
|
|
symbol: 'usd'
|
|
},{
|
|
label: 'Euro',
|
|
symbol: 'eur'
|
|
},{
|
|
label: 'British Pound',
|
|
symbol: 'gbp'
|
|
},{
|
|
label: 'Canadian Dollar',
|
|
symbol: 'cad'
|
|
},{
|
|
label: 'Australian Dollar',
|
|
symbol: 'aud'
|
|
}
|
|
];
|
|
|
|
constructor(
|
|
private fb: FormBuilder,
|
|
private dialogRef: MatDialogRef<SettingsComponent>,
|
|
@Inject(MAT_DIALOG_DATA) public data: Owner
|
|
) {
|
|
this.settingsForm = fb.group({
|
|
name: [data.name, Validators.required],
|
|
currency: [data.currency, Validators.required]
|
|
});
|
|
this.owner = data;
|
|
}
|
|
|
|
ngOnInit() {
|
|
}
|
|
|
|
close() {
|
|
this.dialogRef.close();
|
|
}
|
|
|
|
save() {
|
|
this.owner.name = this.settingsForm.value.name;
|
|
this.owner.currency = this.settingsForm.value.currency;
|
|
this.dialogRef.close(this.owner);
|
|
}
|
|
}
|