Added completion rate to project item

This commit is contained in:
Marta Borgia Leiva 2026-02-10 13:50:02 +01:00
parent 0c8f11a463
commit a7f506b873
3 changed files with 41 additions and 6 deletions

View file

@ -77,6 +77,28 @@
-webkit-box-orient: vertical; -webkit-box-orient: vertical;
} }
.completion-row {
display: flex;
align-items: center;
justify-content: flex-end;
gap: .5rem;
font-size: 13px;
color: #4b5563;
width: fit-content;
}
.completion-label {
text-transform: uppercase;
letter-spacing: 0.04em;
font-weight: 600;
color: #6b7280;
}
.completion-value {
font-weight: 700;
color: #10b981;
}
/* Footer */ /* Footer */
.project-footer { .project-footer {
display: flex; display: flex;

View file

@ -1,8 +1,4 @@
<div <div class="project-item" [class.is-disabled]="!projectRoute" [routerLink]="projectRoute">
class="project-item"
[class.is-disabled]="!projectRoute"
[routerLink]="projectRoute"
>
<div class="project-header"> <div class="project-header">
<h3 class="project-title">{{ project.name }}</h3> <h3 class="project-title">{{ project.name }}</h3>
</div> </div>
@ -10,4 +6,11 @@
@if (project.description) { @if (project.description) {
<p class="project-description">{{ project.description }}</p> <p class="project-description">{{ project.description }}</p>
} }
@if (completionPercentage != null) {
<div class="completion-row">
<span class="completion-label">Completion</span>
<span class="completion-value">{{ completionPercentage }}%</span>
</div>
}
</div> </div>

View file

@ -8,11 +8,21 @@ import { Project } from '../../models/projects.models';
standalone: true, standalone: true,
imports: [CommonModule, RouterLink], imports: [CommonModule, RouterLink],
templateUrl: './project-item.component.html', templateUrl: './project-item.component.html',
styleUrl: './project-item.component.css' styleUrl: './project-item.component.css',
}) })
export class ProjectItemComponent { export class ProjectItemComponent {
@Input({ required: true }) project!: Project; @Input({ required: true }) project!: Project;
get completionPercentage(): number | null {
const tasks = this.project.tasks ?? [];
if (tasks.length === 0) {
return null;
}
const completedCount = tasks.filter((task) => task.status === 'completed').length;
return Math.round((completedCount / tasks.length) * 100);
}
get projectRoute(): Array<string | number> | null { get projectRoute(): Array<string | number> | null {
const id = this.getProjectId(); const id = this.getProjectId();
return id == null ? null : ['/projects', id]; return id == null ? null : ['/projects', id];