diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 28fc611..2a5ce6c 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,44 +1,38 @@ import { Component } from '@angular/core'; -import { forms } from "src/assets/forms"; +import { checkin, checkout } from "src/assets/forms"; @Component({ selector: 'app-root', template: ` - + - + - + + + ` }) export class AppComponent { - templates: Form[] = forms; + checkin: Form = checkin; + checkout: Form = checkout; - form: Form; /* Active */ + action: string = "checkout"; - ngOnInit() { this.set(this.templates[0]); } + ngOnInit() { } - set(template: Form) { - - this.form = Object.assign({}, template); - - console.log("Setting", this.form); - - } - - change(template: Form) { + switch(action: string) { alert("Are you sure?"); - this.set(template); + this.action = action; } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 8294ccc..b79eb98 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -6,8 +6,6 @@ import { AppComponent } from './app.component'; import { FormComponent } from './form.component'; import { TextComponent } from './text.component'; import { RadioComponent } from './radio.component'; -import { MenuComponent } from './menu.component'; -import { BarComponent } from './bar.component'; import { StepComponent } from './step.component'; @NgModule({ @@ -16,8 +14,6 @@ import { StepComponent } from './step.component'; FormComponent, TextComponent, RadioComponent, - MenuComponent, - BarComponent, StepComponent, ], imports: [ diff --git a/src/app/bar.component.ts b/src/app/bar.component.ts deleted file mode 100644 index b1232a1..0000000 --- a/src/app/bar.component.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { Component, OnInit } from '@angular/core'; - -@Component({ - selector: 'app-bar', - template: ` -

- bar works! -

- `, - styles: [ - ] -}) -export class BarComponent implements OnInit { - - constructor() { } - - ngOnInit(): void { - } - -} diff --git a/src/app/form.component.ts b/src/app/form.component.ts index 31014ec..699009d 100644 --- a/src/app/form.component.ts +++ b/src/app/form.component.ts @@ -33,9 +33,13 @@ import { Component, OnInit, Input } from '@angular/core'; }) export class FormComponent implements OnInit { - @Input() form: Form; + @Input() template: Form; - ngOnInit() { console.log("Form", this.form); } + form: Form; + + ngOnInit() { this.set() } + + set() { this.form = Object.assign({}, this.template); } next() { @@ -47,7 +51,12 @@ export class FormComponent implements OnInit { back() { this.form.step--; } - /* Extract the values from the fields into a dict */ - submit() { console.log("Submitting", this.form); } + submit() { + + console.log("Submitting", this.form); + + this.set(); + + } } diff --git a/src/app/menu.component.ts b/src/app/menu.component.ts deleted file mode 100644 index 03f4694..0000000 --- a/src/app/menu.component.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { Component, OnInit } from '@angular/core'; - -@Component({ - selector: 'app-menu', - template: ` -

- menu works! -

- `, - styles: [ - ] -}) -export class MenuComponent implements OnInit { - - constructor() { } - - ngOnInit(): void { - } - -} diff --git a/src/assets/forms.ts b/src/assets/forms.ts index 531b29e..0dbe1b1 100644 --- a/src/assets/forms.ts +++ b/src/assets/forms.ts @@ -1,4 +1,4 @@ -export const forms: Form[] = [{ +export const checkout: Form = { name: "Check Out", submit: "/api/checkout", @@ -47,7 +47,9 @@ export const forms: Form[] = [{ }] }] -}, { +} + +export const checkin: Form = { name: "Check In", submit: "/api/checkin", @@ -89,4 +91,4 @@ export const forms: Form[] = [{ }] }] -}]; +};