diff --git a/src/app/choice-card/choice-card.component.ts b/src/app/choice-card/choice-card.component.ts
index 94cb525..a248369 100644
--- a/src/app/choice-card/choice-card.component.ts
+++ b/src/app/choice-card/choice-card.component.ts
@@ -28,7 +28,6 @@ export class ChoiceCardComponent implements OnInit {
}
choiceUpdated() {
- console.log('Hey');
this.choiceDataService.updateChoiceById(this.choice.id,this.groupId,this.choice);
}
diff --git a/src/app/choice-group-detail/choice-group-detail.component.html b/src/app/choice-group-detail/choice-group-detail.component.html
index b8b5f9b..91f308d 100755
--- a/src/app/choice-group-detail/choice-group-detail.component.html
+++ b/src/app/choice-group-detail/choice-group-detail.component.html
@@ -1,37 +1,52 @@
Choices
- Add a new choice
-
+
+ Name
+
+
+
-
-
- @for (choice of choiceGroup.choices; track choice.id) {
-
- }
-
+
0" class="choice-list">
+ @for (choice of choiceGroup.choices; track choice.id) {
+
+ }
Settings
- Selections/Day
-
+
+
+ Selections/Day
+
+
Analytics
Distribution of choices for the next {{ numberOfDays }} days
+
+ Number of Days
+
+
-
-
+
-
diff --git a/src/app/choice-group-detail/choice-group-detail.component.ts b/src/app/choice-group-detail/choice-group-detail.component.ts
index 890c5cd..d41b367 100755
--- a/src/app/choice-group-detail/choice-group-detail.component.ts
+++ b/src/app/choice-group-detail/choice-group-detail.component.ts
@@ -1,9 +1,11 @@
import { Component, inject, OnInit } from '@angular/core';
-import { ActivatedRoute } from "@angular/router";
import { NgFor, NgIf } from '@angular/common';
-import { FormsModule } from '@angular/forms';
+import { FormControl, FormsModule, ReactiveFormsModule, Validators } from '@angular/forms';
+import { MatButtonModule } from '@angular/material/button';
import { MAT_DIALOG_DATA, MatDialogModule } from '@angular/material/dialog';
+import { MatFormFieldModule } from '@angular/material/form-field';
+import { MatInputModule } from '@angular/material/input';
import { ChoiceCardComponent } from '../choice-card/choice-card.component';
import { Choice } from "./../shared/choice";
import { ChoiceDataService } from "./../shared/choice-data.service";
@@ -21,7 +23,7 @@ export interface AnalyticResult {
styleUrls: ['./choice-group-detail.component.css'],
providers: [SelectorService],
standalone: true,
- imports: [FormsModule, NgIf, NgFor, ChoiceCardComponent, MatDialogModule]
+ imports: [ReactiveFormsModule, FormsModule, NgIf, NgFor, ChoiceCardComponent, MatButtonModule, MatDialogModule, MatFormFieldModule, MatInputModule]
})
export class ChoiceGroupDetailComponent implements OnInit {
@@ -30,15 +32,17 @@ export class ChoiceGroupDetailComponent implements OnInit {
numberOfDays: number = 100;
choiceGroup: ChoiceGroup;
- newChoice: Choice = new Choice();
+ newChoiceNameControl = new FormControl('', Validators.required);
analytics: Array = [];
- constructor(private route: ActivatedRoute, private choiceDataService: ChoiceDataService, private md5Service: SelectorService) { }
+ constructor(private choiceDataService: ChoiceDataService, private md5Service: SelectorService) { }
addChoice() {
- this.choiceDataService.addChoice(this.newChoice,this.choiceGroup.id);
- this.newChoice = new Choice();
+ let newChoice: Choice = new Choice();
+ newChoice.title = this.newChoiceNameControl.value;
+ this.choiceDataService.addChoice(newChoice, this.choiceGroup.id);
+ this.newChoiceNameControl.reset();
}
ngOnInit() {
diff --git a/src/app/dashboard/dashboard.component.css b/src/app/dashboard/dashboard.component.css
index a4581cf..268b6db 100755
--- a/src/app/dashboard/dashboard.component.css
+++ b/src/app/dashboard/dashboard.component.css
@@ -2,4 +2,5 @@
padding-top: 32px;
display: flex;
gap: 16px;
+ flex-wrap: wrap;
}
\ No newline at end of file
diff --git a/src/app/dashboard/dashboard.component.html b/src/app/dashboard/dashboard.component.html
index 440d1aa..bf574dd 100755
--- a/src/app/dashboard/dashboard.component.html
+++ b/src/app/dashboard/dashboard.component.html
@@ -1,7 +1,9 @@
-Add a new Choice Group
-
-
+
+ Name
+
+
+
0">
@for (group of choiceGroups; track group.id) {
diff --git a/src/app/dashboard/dashboard.component.ts b/src/app/dashboard/dashboard.component.ts
index c05591b..0838df1 100755
--- a/src/app/dashboard/dashboard.component.ts
+++ b/src/app/dashboard/dashboard.component.ts
@@ -1,7 +1,10 @@
import { Component, OnInit } from '@angular/core';
import { NgFor, NgIf } from '@angular/common';
-import { FormsModule } from '@angular/forms';
+import { FormControl, ReactiveFormsModule, Validators } from '@angular/forms';
+import { MatButtonModule } from '@angular/material/button';
+import { MatFormFieldModule } from '@angular/material/form-field';
+import { MatInputModule } from '@angular/material/input';
import { ChoiceGroupCardComponent } from '../choice-group-card/choice-group-card.component';
import { ChoiceDataService } from "./../shared/choice-data.service";
import { ChoiceGroup } from "./../shared/choice-group";
@@ -13,17 +16,19 @@ import { SelectorService } from "./../shared/selector.service";
styleUrls: ['./dashboard.component.css'],
providers: [SelectorService],
standalone: true,
- imports: [FormsModule, NgIf, NgFor, ChoiceGroupCardComponent]
+ imports: [ReactiveFormsModule, NgIf, NgFor, ChoiceGroupCardComponent, MatButtonModule, MatFormFieldModule, MatInputModule]
})
export class DashboardComponent implements OnInit {
- newChoiceGroup: ChoiceGroup = new ChoiceGroup();
+ newChoiceGroupNameControl = new FormControl('', Validators.required);
constructor(private choiceDataService: ChoiceDataService, private md5Service: SelectorService) { }
addChoiceGroup() {
- this.choiceDataService.addChoiceGroup(this.newChoiceGroup);
- this.newChoiceGroup = new ChoiceGroup();
+ const newChoiceGroup = new ChoiceGroup();
+ newChoiceGroup.title = this.newChoiceGroupNameControl.value;
+ this.choiceDataService.addChoiceGroup(newChoiceGroup);
+ this.newChoiceGroupNameControl.reset();
}
get choiceGroups() {
diff --git a/src/app/shared/choice-group.ts b/src/app/shared/choice-group.ts
index 44ecee2..f43901e 100755
--- a/src/app/shared/choice-group.ts
+++ b/src/app/shared/choice-group.ts
@@ -1,4 +1,4 @@
-import {Choice} from "./choice";
+import { Choice } from "./choice";
export class ChoiceGroup {
id: number;
@@ -11,4 +11,4 @@ export class ChoiceGroup {
Object.assign(this,values);
}
-}
+}
\ No newline at end of file