From 300bc99dfe402a546145b9d4d991029525940f82 Mon Sep 17 00:00:00 2001 From: Chris Veilleux Date: Thu, 21 Mar 2019 13:16:01 -0500 Subject: [PATCH] added support for forms --- .../app/modules/device/device.component.html | 19 ++++++++- .../app/modules/device/device.component.ts | 39 ++++++++++++++++++- 2 files changed, 55 insertions(+), 3 deletions(-) diff --git a/projects/account/src/app/modules/device/device.component.html b/projects/account/src/app/modules/device/device.component.html index 92d4e24..3543a6c 100644 --- a/projects/account/src/app/modules/device/device.component.html +++ b/projects/account/src/app/modules/device/device.component.html @@ -1,12 +1,27 @@
- + - + + + + + + + + diff --git a/projects/account/src/app/modules/device/device.component.ts b/projects/account/src/app/modules/device/device.component.ts index bc7954b..c5002c2 100644 --- a/projects/account/src/app/modules/device/device.component.ts +++ b/projects/account/src/app/modules/device/device.component.ts @@ -1,4 +1,8 @@ import { Component, OnInit } from '@angular/core'; +import { FormGroup, FormBuilder, Validators } from '@angular/forms'; +import { ActivatedRoute } from '@angular/router'; +import { AccountDefaults } from '../../shared/models/defaults.model'; +import { AccountPreferences } from '../../shared/models/preferences.model'; @Component({ selector: 'account-device', @@ -6,9 +10,42 @@ import { Component, OnInit } from '@angular/core'; styleUrls: ['./device.component.scss'] }) export class DeviceComponent implements OnInit { - constructor() { + defaults: AccountDefaults; + defaultsForm: FormGroup; + preferences: AccountPreferences; + preferencesForm: FormGroup; + + constructor(private formBuilder: FormBuilder, private route: ActivatedRoute) { } ngOnInit() { + this.route.data.subscribe( + (data: {defaults: AccountDefaults, preferences: AccountPreferences}) => { + this.defaults = data.defaults; + this.preferences = data.preferences; + } + ); + + this.defaultsForm = this.formBuilder.group( + { + city: [null], + country: [null], + name: [null], + pairingCode: [null], + placement: [null], + region: [null], + timezone: [null], + wakeWord: [null], + voice: [null] + } + ); + this.preferencesForm = this.formBuilder.group( + { + dateFormat: [null, Validators.required], + measurementSystem: [null, Validators.required], + timeFormat: [null, Validators.required], + } + ); + } }