Fixed navigation to single dfg project from person projects
LocationBasedServices/smartguide/pipeline/head This commit looks good
LocationBasedServices/smartguide/pipeline/head This commit looks good
This commit is contained in:
@@ -26,10 +26,7 @@
|
||||
[detailTemplate]="dfgProjectDetailRowTmp"
|
||||
[activeSortKey]="urlSortKey()"
|
||||
[sortDirection]="urlSortDirection()"
|
||||
(sortChange)="handleSortChange($event)"
|
||||
[navigatePrefix]="'projects/dfg/'"
|
||||
[navigateField]="'id'"/>
|
||||
|
||||
(sortChange)="handleSortChange($event)" />
|
||||
</mat-tab>
|
||||
</mat-tab-group>
|
||||
<mat-paginator
|
||||
@@ -42,7 +39,11 @@
|
||||
</div>
|
||||
|
||||
<ng-template #dfgProjectActionsTmp let-element>
|
||||
<a href="{{ element.link }}" target="_blank" mat-icon-button color="primary">
|
||||
<a
|
||||
[routerLink]="['/projects/dfg', element.id]"
|
||||
target="_blank"
|
||||
mat-icon-button
|
||||
color="primary">
|
||||
<mat-icon>open_in_new</mat-icon>
|
||||
</a>
|
||||
</ng-template>
|
||||
|
||||
@@ -20,7 +20,7 @@ import { MatTabsModule } from '@angular/material/tabs';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import { DebounceDirective } from '../../directives/debounce.directive';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { ActivatedRoute, Router, RouterModule } from '@angular/router';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
import { MatPaginatorModule, PageEvent } from '@angular/material/paginator';
|
||||
import { Sort, SortDirection } from '@angular/material/sort';
|
||||
@@ -37,6 +37,7 @@ import { Sort, SortDirection } from '@angular/material/sort';
|
||||
MatInputModule,
|
||||
DebounceDirective,
|
||||
MatPaginatorModule,
|
||||
RouterModule,
|
||||
],
|
||||
templateUrl: './person-projects.component.html',
|
||||
styleUrl: './person-projects.component.scss',
|
||||
|
||||
@@ -49,19 +49,12 @@
|
||||
<tr
|
||||
mat-header-row
|
||||
*matHeaderRowDef="displayedColumns(); sticky: stickyHeader()"></tr>
|
||||
@if (navigatePrefix() || navigateField()){
|
||||
<tr
|
||||
mat-row
|
||||
*matRowDef="let row; columns: displayedColumns()"
|
||||
class="element-row"
|
||||
(click)="navigateToDataField(row)"></tr>
|
||||
} @else {
|
||||
<tr
|
||||
mat-row
|
||||
*matRowDef="let row; columns: displayedColumns()"
|
||||
class="element-row"
|
||||
(click)="toggleRow(row)"></tr>
|
||||
}
|
||||
|
||||
<tr
|
||||
mat-row
|
||||
*matRowDef="let row; columns: displayedColumns()"
|
||||
class="element-row"
|
||||
(click)="toggleRow(row)"></tr>
|
||||
|
||||
<tr
|
||||
mat-row
|
||||
|
||||
@@ -17,7 +17,6 @@ import {
|
||||
SortDirection,
|
||||
} from '@angular/material/sort';
|
||||
import { MatTableDataSource, MatTableModule } from '@angular/material/table';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
export interface BaseColumn<T> {
|
||||
id: string;
|
||||
@@ -58,8 +57,6 @@ export class DataTableComponent<T> implements AfterViewInit {
|
||||
|
||||
activeSortKey = input<string>('');
|
||||
sortDirection = input<SortDirection>('');
|
||||
navigatePrefix=input<string>('');
|
||||
navigateField=input<string>('');
|
||||
sortChange = output<Sort>();
|
||||
|
||||
displayedColumns = computed(() => this.columns().map((col) => col.id));
|
||||
@@ -67,7 +64,7 @@ export class DataTableComponent<T> implements AfterViewInit {
|
||||
|
||||
sort = viewChild.required(MatSort);
|
||||
|
||||
constructor(private router:Router) {
|
||||
constructor() {
|
||||
effect(() => {
|
||||
const currentData = this.data();
|
||||
|
||||
@@ -112,16 +109,6 @@ export class DataTableComponent<T> implements AfterViewInit {
|
||||
this.sortChange.emit(sort);
|
||||
}
|
||||
|
||||
navigateToDataField(row: any): void {
|
||||
if (!this.navigatePrefix() || !this.navigateField()) {
|
||||
return;
|
||||
}
|
||||
const value = row[this.navigateField()];
|
||||
if (value != null) {
|
||||
this.router.navigate([this.navigatePrefix(), value]);
|
||||
}
|
||||
}
|
||||
|
||||
toggleRow(row: T): void {
|
||||
if (!this.detailTemplate()) return;
|
||||
this.expandedElement.update((current) => (current === row ? null : row));
|
||||
|
||||
Reference in New Issue
Block a user