adding complete and undo-complete on click

This commit is contained in:
Will Baumbach
2026-04-17 12:09:32 -05:00
parent 349ac48fa2
commit 1eb77cd6b6
5 changed files with 38 additions and 4 deletions

View File

@@ -17,13 +17,13 @@
<div>Week {{planWeek.week}}</div> <div>Week {{planWeek.week}}</div>
</td> </td>
@for (workout of planWeek.workouts; track $index) { @for (workout of planWeek.workouts; track $index) {
<td class="hoverOverWorkout"> <td class="incompleteWorkout" (click)="onCellClick($event)">
<div>{{workout.type}}</div> <div>{{workout.type}}</div>
<div>{{workout.totalDistance == 0 ? '' : workout.totalDistance + ' miles'}}</div> <div>{{workout.totalDistance == 0 ? '' : workout.totalDistance + ' miles'}}</div>
<div>{{workout.description}}</div> <div>{{workout.description}}</div>
</td> </td>
} }
<td>43</td> <td>{{planWeek.totalMilage}}</td>
</tr> </tr>
} }
</table> </table>

View File

@@ -33,7 +33,13 @@ td {
supported by Chrome, Edge, Opera and Firefox */ supported by Chrome, Edge, Opera and Firefox */
} }
.hoverOverWorkout:hover { .incompleteWorkout:hover {
background-color: rgb(211, 211, 211); background-color: rgb(235, 235, 235);
} }
.completedWorkout {
background-color: rgb(107, 194, 107);
}
.completedWorkout:hover {
background-color: rgb(89, 161, 89);
}

View File

@@ -15,4 +15,13 @@ export class CalendarComponent {
ngOnInit(): void { ngOnInit(): void {
} }
onCellClick(event: Event) {
const target = event.currentTarget as HTMLElement;
if (target.classList.contains('incompleteWorkout')) {
target.classList.replace('incompleteWorkout', 'completedWorkout')
} else if (target.classList.contains('completedWorkout')) {
target.classList.replace('completedWorkout', 'incompleteWorkout')
}
}
} }

View File

@@ -11,5 +11,6 @@ export interface Plan {
export interface Week { export interface Week {
week: number, week: number,
totalMilage: number,
workouts: Workout[] workouts: Workout[]
} }

View File

@@ -10,6 +10,7 @@ export const examplePlan: Plan = {
planDetials: [ planDetials: [
{ {
week: 1, week: 1,
totalMilage: 31,
workouts: [ workouts: [
{ {
day: 0, day: 0,
@@ -57,6 +58,7 @@ export const examplePlan: Plan = {
}, },
{ {
week: 2, week: 2,
totalMilage: 33,
workouts: [ workouts: [
{ {
day: 0, day: 0,
@@ -104,6 +106,7 @@ export const examplePlan: Plan = {
}, },
{ {
week: 3, week: 3,
totalMilage: 39,
workouts: [ workouts: [
{ {
day: 0, day: 0,
@@ -151,6 +154,7 @@ export const examplePlan: Plan = {
}, },
{ {
week: 4, week: 4,
totalMilage: 40,
workouts: [ workouts: [
{ {
day: 0, day: 0,
@@ -198,6 +202,7 @@ export const examplePlan: Plan = {
}, },
{ {
week: 5, week: 5,
totalMilage: 42,
workouts: [ workouts: [
{ {
day: 0, day: 0,
@@ -245,6 +250,7 @@ export const examplePlan: Plan = {
}, },
{ {
week: 6, week: 6,
totalMilage: 33,
workouts: [ workouts: [
{ {
day: 0, day: 0,
@@ -292,6 +298,7 @@ export const examplePlan: Plan = {
}, },
{ {
week: 7, week: 7,
totalMilage: 48,
workouts: [ workouts: [
{ {
day: 0, day: 0,
@@ -339,6 +346,7 @@ export const examplePlan: Plan = {
}, },
{ {
week: 8, week: 8,
totalMilage: 51,
workouts: [ workouts: [
{ {
day: 0, day: 0,
@@ -386,6 +394,7 @@ export const examplePlan: Plan = {
}, },
{ {
week: 9, week: 9,
totalMilage: 46,
workouts: [ workouts: [
{ {
day: 0, day: 0,
@@ -433,6 +442,7 @@ export const examplePlan: Plan = {
}, },
{ {
week: 10, week: 10,
totalMilage: 40,
workouts: [ workouts: [
{ {
day: 0, day: 0,
@@ -480,6 +490,7 @@ export const examplePlan: Plan = {
}, },
{ {
week: 11, week: 11,
totalMilage: 52,
workouts: [ workouts: [
{ {
day: 0, day: 0,
@@ -527,6 +538,7 @@ export const examplePlan: Plan = {
}, },
{ {
week: 12, week: 12,
totalMilage: 48,
workouts: [ workouts: [
{ {
day: 0, day: 0,
@@ -574,6 +586,7 @@ export const examplePlan: Plan = {
}, },
{ {
week: 13, week: 13,
totalMilage: 48,
workouts: [ workouts: [
{ {
day: 0, day: 0,
@@ -621,6 +634,7 @@ export const examplePlan: Plan = {
}, },
{ {
week: 14, week: 14,
totalMilage: 48,
workouts: [ workouts: [
{ {
day: 0, day: 0,
@@ -668,6 +682,7 @@ export const examplePlan: Plan = {
}, },
{ {
week: 15, week: 15,
totalMilage: 49,
workouts: [ workouts: [
{ {
day: 0, day: 0,
@@ -715,6 +730,7 @@ export const examplePlan: Plan = {
}, },
{ {
week: 16, week: 16,
totalMilage: 41,
workouts: [ workouts: [
{ {
day: 0, day: 0,
@@ -762,6 +778,7 @@ export const examplePlan: Plan = {
}, },
{ {
week: 17, week: 17,
totalMilage: 31,
workouts: [ workouts: [
{ {
day: 0, day: 0,
@@ -809,6 +826,7 @@ export const examplePlan: Plan = {
}, },
{ {
week: 18, week: 18,
totalMilage: 16,
workouts: [ workouts: [
{ {
day: 0, day: 0,