mirror of
https://github.com/a-mayb3/KanbanCloneAngular.git
synced 2026-03-21 18:05:38 +01:00
Made project item redirect to project details on click
This commit is contained in:
parent
d31630db18
commit
c59090a64a
5 changed files with 30 additions and 11 deletions
|
|
@ -8,6 +8,11 @@
|
||||||
border-left: 4px solid #667eea;
|
border-left: 4px solid #667eea;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.project-item.is-disabled {
|
||||||
|
cursor: not-allowed;
|
||||||
|
opacity: 0.7;
|
||||||
|
}
|
||||||
|
|
||||||
.project-item:hover {
|
.project-item:hover {
|
||||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
||||||
transform: translateY(-2px);
|
transform: translateY(-2px);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,8 @@
|
||||||
<div class="project-item" (click)="onProjectClick()">
|
<div
|
||||||
|
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>
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,33 @@
|
||||||
import { Component, Input, Output, EventEmitter } from '@angular/core';
|
import { Component, Input } from '@angular/core';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { RouterLink } from '@angular/router';
|
||||||
import { Project } from '../../models/projects.models';
|
import { Project } from '../../models/projects.models';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-project-item',
|
selector: 'app-project-item',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [CommonModule],
|
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;
|
||||||
@Output() projectClick = new EventEmitter<Project>();
|
|
||||||
|
|
||||||
onProjectClick() {
|
get projectRoute(): Array<string | number> | null {
|
||||||
this.projectClick.emit(this.project);
|
const id = this.getProjectId();
|
||||||
|
return id == null ? null : ['/projects', id];
|
||||||
|
}
|
||||||
|
|
||||||
|
get projectState(): { project: Project } | null {
|
||||||
|
return this.projectRoute ? { project: this.project } : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private getProjectId(): string | number | null {
|
||||||
|
const projectAsAny = this.project as Project & {
|
||||||
|
_id?: string | number;
|
||||||
|
projectId?: string | number;
|
||||||
|
};
|
||||||
|
|
||||||
|
return projectAsAny.id ?? projectAsAny.projectId ?? projectAsAny._id ?? null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
<div class="projects-grid">
|
<div class="projects-grid">
|
||||||
@if (projectList.length > 0) {
|
@if (projectList.length > 0) {
|
||||||
@for (project of projectList; track project.id) {
|
@for (project of projectList; track project.id) {
|
||||||
<app-project-item [project]="project" (projectClick)="onProjectClick($event)" />
|
<app-project-item [project]="project" />
|
||||||
}
|
}
|
||||||
} @else {
|
} @else {
|
||||||
<div class="no-projects">
|
<div class="no-projects">
|
||||||
|
|
|
||||||
|
|
@ -20,10 +20,6 @@ export class HomeComponent {
|
||||||
return this.authService.currentUser()?.projects ?? [];
|
return this.authService.currentUser()?.projects ?? [];
|
||||||
}
|
}
|
||||||
|
|
||||||
onProjectClick(project: Project) {
|
|
||||||
this.router.navigate(['/projects', project.id]);
|
|
||||||
}
|
|
||||||
|
|
||||||
onCreateProject() {
|
onCreateProject() {
|
||||||
this.router.navigate(['/projects/new']);
|
this.router.navigate(['/projects/new']);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue