moved project card into generic component
This commit is contained in:
@@ -14,38 +14,7 @@
|
||||
</div>
|
||||
|
||||
<ng-template #cardTmp let-element>
|
||||
<mat-card
|
||||
class="card"
|
||||
appearance="outlined"
|
||||
[routerLink]="getDetaiLink(element)">
|
||||
<mat-card-header>
|
||||
<mat-card-title>{{ element.title }}</mat-card-title>
|
||||
<mat-card-subtitle>{{ element.type | uppercase }}</mat-card-subtitle>
|
||||
</mat-card-header>
|
||||
|
||||
<mat-card-content class="card-content">
|
||||
<mat-divider />
|
||||
<div class="card-metadata">
|
||||
<span
|
||||
>Von {{ element.start_date | date: 'dd.MM.yyyy' }} bis
|
||||
{{ element.end_date | date: 'dd.MM.yyyy' }}</span
|
||||
>
|
||||
</div>
|
||||
<mat-divider />
|
||||
</mat-card-content>
|
||||
|
||||
<mat-card-footer>
|
||||
<mat-card-actions>
|
||||
<a
|
||||
mat-button
|
||||
[routerLink]="getDetaiLink(element)"
|
||||
(click)="$event.stopPropagation()">
|
||||
<mat-icon>info</mat-icon>
|
||||
Übersicht
|
||||
</a>
|
||||
</mat-card-actions>
|
||||
</mat-card-footer>
|
||||
</mat-card>
|
||||
<app-project-card [project]="element" />
|
||||
</ng-template>
|
||||
|
||||
<ng-template #additionalFiltersTmp>
|
||||
|
||||
@@ -4,57 +4,3 @@
|
||||
gap: 1rem;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.cards {
|
||||
display: grid;
|
||||
gap: 1.5rem;
|
||||
grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
|
||||
padding: 0 1rem;
|
||||
}
|
||||
|
||||
.card {
|
||||
padding: 0.5rem;
|
||||
background-color: var(--sg-background);
|
||||
transition: transform 0.3s ease;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.card:hover {
|
||||
cursor: pointer;
|
||||
transform: scale(1.05);
|
||||
}
|
||||
|
||||
.card-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: flex-end;
|
||||
gap: 0.5rem;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.card-metadata {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.2rem;
|
||||
font-size: 0.9rem;
|
||||
color: var(--sg-text-secondary);
|
||||
}
|
||||
|
||||
mat-card-actions {
|
||||
padding-top: 0.5rem;
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
mat-card-actions a {
|
||||
width: 100%;
|
||||
text-decoration: none;
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: var(--sg-radius-sm);
|
||||
}
|
||||
|
||||
.mat-mdc-standard-chip {
|
||||
border-radius: var(--sg-radius-sm);
|
||||
}
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
import { Component, computed, input, signal } from '@angular/core';
|
||||
import { FundingProject, FundingProjectPage, ProjectType } from '../../api';
|
||||
import { FundingProjectPage, ProjectType } from '../../api';
|
||||
import { MatDividerModule } from '@angular/material/divider';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { ActivatedRoute, Router, RouterModule } from '@angular/router';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { DatePipe, UpperCasePipe } from '@angular/common';
|
||||
import { MatChipListboxChange, MatChipsModule } from '@angular/material/chips';
|
||||
|
||||
import { AppProjectCardComponent } from '../../shared/ui/app-project-card/app-project-card.component';
|
||||
import { SelectorOption } from '../../shared/ui/query-param-selector/query-param-selector.component';
|
||||
import {
|
||||
CardSearchComponent,
|
||||
@@ -24,10 +23,9 @@ import { FilterObserver } from '../../shared/ui/selected-filters/selected-filter
|
||||
MatCardModule,
|
||||
RouterModule,
|
||||
MatButtonModule,
|
||||
UpperCasePipe,
|
||||
DatePipe,
|
||||
MatChipsModule,
|
||||
CardSearchComponent,
|
||||
AppProjectCardComponent,
|
||||
],
|
||||
templateUrl: './projects.component.html',
|
||||
styleUrl: './projects.component.scss',
|
||||
@@ -83,17 +81,4 @@ export class ProjectsComponent {
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
|
||||
getDetaiLink(fundingProject: FundingProject): string | null {
|
||||
if (fundingProject.type === 'bund') {
|
||||
const encodedId = encodeURIComponent(fundingProject.id);
|
||||
return '/projects/bund/' + encodedId;
|
||||
} else if (fundingProject.type === 'dfg') {
|
||||
return '/projects/dfg/' + fundingProject.id;
|
||||
} else if (fundingProject.type === 'eu') {
|
||||
return '/projects/eu/' + fundingProject.id;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<mat-card
|
||||
class="card-content popup"
|
||||
appearance="outlined"
|
||||
[routerLink]="getDetailLink(project())">
|
||||
<mat-card-header>
|
||||
<mat-card-title>{{ project().title }}</mat-card-title>
|
||||
<mat-card-subtitle class="subtitle">
|
||||
{{ project().type | uppercase }}</mat-card-subtitle
|
||||
>
|
||||
</mat-card-header>
|
||||
|
||||
<mat-divider />
|
||||
|
||||
<mat-card-content class="mat-card-content">
|
||||
<div class="metrics">
|
||||
<div class="metric-item">
|
||||
<mat-icon>date_range</mat-icon>
|
||||
<span
|
||||
>Von {{ project().start_date | date: 'dd.MM.yyyy' }} bis
|
||||
{{ project().end_date | date: 'dd.MM.yyyy' }}</span
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</mat-card-content>
|
||||
|
||||
<mat-divider />
|
||||
|
||||
<mat-card-footer>
|
||||
<mat-card-actions class="card-actions">
|
||||
<a
|
||||
class="card-action"
|
||||
[routerLink]="getDetailLink(project())"
|
||||
matButton="outlined"
|
||||
(click)="$event.stopPropagation()">
|
||||
<mat-icon>open_in_new</mat-icon>
|
||||
Öffnen
|
||||
</a>
|
||||
</mat-card-actions>
|
||||
</mat-card-footer>
|
||||
</mat-card>
|
||||
@@ -0,0 +1,43 @@
|
||||
.card-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
color: var(--sg-text-muted);
|
||||
}
|
||||
|
||||
.metrics {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.metric-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
color: var(--sg-text-muted);
|
||||
}
|
||||
|
||||
.card-actions {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.card-action {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.mat-card-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
height: 100%;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
import { Component, input } from '@angular/core';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { FundingProject } from '../../../api';
|
||||
import { DatePipe, UpperCasePipe } from '@angular/common';
|
||||
import { RouterLink } from '@angular/router';
|
||||
import { MatDividerModule } from '@angular/material/divider';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
@Component({
|
||||
selector: 'app-project-card',
|
||||
imports: [
|
||||
MatCardModule,
|
||||
DatePipe,
|
||||
UpperCasePipe,
|
||||
RouterLink,
|
||||
MatDividerModule,
|
||||
MatIconModule,
|
||||
MatButtonModule,
|
||||
],
|
||||
templateUrl: './app-project-card.component.html',
|
||||
styleUrl: './app-project-card.component.scss',
|
||||
})
|
||||
export class AppProjectCardComponent {
|
||||
project = input.required<FundingProject>();
|
||||
|
||||
getDetailLink(fundingProject: FundingProject): string | null {
|
||||
if (fundingProject.type === 'bund') {
|
||||
const encodedId = encodeURIComponent(fundingProject.id);
|
||||
return '/projects/bund/' + encodedId;
|
||||
} else if (fundingProject.type === 'dfg') {
|
||||
return '/projects/dfg/' + fundingProject.id;
|
||||
} else if (fundingProject.type === 'eu') {
|
||||
return '/projects/eu/' + fundingProject.id;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user