This commit is contained in:
@@ -190,7 +190,33 @@ export const routes: Routes = [
|
||||
collaborationNetwork: collaborationNetworkResolver,
|
||||
},
|
||||
runGuardsAndResolvers: (from, to) => {
|
||||
// No need to re-run for different table view or search term
|
||||
const network = from.data['collaborationNetwork'] as
|
||||
| {
|
||||
filter_information?: {
|
||||
min_possible_year?: number;
|
||||
max_possible_year?: number;
|
||||
};
|
||||
}
|
||||
| undefined;
|
||||
|
||||
const filterInformation = network?.filter_information;
|
||||
|
||||
const defaultQueryParams: Record<string, string> = {
|
||||
filter_by: 'works',
|
||||
start_year: filterInformation?.min_possible_year
|
||||
? String(filterInformation.min_possible_year)
|
||||
: '',
|
||||
end_year: filterInformation?.max_possible_year
|
||||
? String(filterInformation.max_possible_year)
|
||||
: '',
|
||||
min_contributors: '2',
|
||||
max_contributors: '10',
|
||||
min_collaborations: '1',
|
||||
max_collaborations: '100',
|
||||
institutions: '',
|
||||
topics: '',
|
||||
};
|
||||
|
||||
const keys = [
|
||||
'filter_by',
|
||||
'start_year',
|
||||
@@ -203,9 +229,22 @@ export const routes: Routes = [
|
||||
'topics',
|
||||
];
|
||||
|
||||
return keys.some(
|
||||
(key) => from.queryParamMap.get(key) !== to.queryParamMap.get(key),
|
||||
);
|
||||
return keys.some((key) => {
|
||||
const fromRawValue = from.queryParamMap.get(key);
|
||||
const toRawValue = to.queryParamMap.get(key);
|
||||
|
||||
const fromValue =
|
||||
fromRawValue === null || fromRawValue === ''
|
||||
? defaultQueryParams[key]
|
||||
: fromRawValue;
|
||||
|
||||
const toValue =
|
||||
toRawValue === null || toRawValue === ''
|
||||
? defaultQueryParams[key]
|
||||
: toRawValue;
|
||||
|
||||
return fromValue !== toValue;
|
||||
});
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
+2
-2
@@ -131,8 +131,8 @@ $text-muted: #64718f;
|
||||
right: 12px;
|
||||
z-index: 2;
|
||||
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
width: 51px;
|
||||
height: 51px;
|
||||
padding: 0;
|
||||
|
||||
background: transparent;
|
||||
|
||||
@@ -299,7 +299,7 @@ export class PersonNetworkComponent implements OnInit {
|
||||
console.log('Form value when opening dialog:', this.filterForm.value);
|
||||
const dialogRef = this.dialog.open(PersonNetworkFilterDialogComponent, {
|
||||
data: {
|
||||
collaborationNetwork: this.collaborationNetwork,
|
||||
collaborationNetwork: this.collaborationNetwork(),
|
||||
filterBy: this.filterForm.get('filterBy')?.value || 'works',
|
||||
startYear: this.filterForm.get('startYear')?.value,
|
||||
|
||||
@@ -407,22 +407,34 @@ export class PersonNetworkComponent implements OnInit {
|
||||
];
|
||||
|
||||
this.filterForm.valueChanges.pipe(debounceTime(300)).subscribe((value) => {
|
||||
console.log('Form value changed:', value);
|
||||
const queryParams = {
|
||||
table: value.displayedTable ?? 'collaborators',
|
||||
search_term: value.searchTerm ?? '',
|
||||
filter_by: value.filterBy ?? 'works',
|
||||
start_year: value.startYear ?? '',
|
||||
end_year: value.endYear ?? '',
|
||||
min_contributors: value.minContributors ?? 2,
|
||||
max_contributors: value.maxContributors ?? 10,
|
||||
min_collaborations: value.minCollaborations ?? 1,
|
||||
max_collaborations: value.maxCollaborations ?? 100,
|
||||
institutions: value.institutions?.join(',') ?? '',
|
||||
topics: value.topics?.join(',') ?? '',
|
||||
};
|
||||
|
||||
const currentQueryParams = this.activatedRoute.snapshot.queryParams;
|
||||
|
||||
const hasChanged = Object.entries(queryParams).some(([key, value]) => {
|
||||
return String(currentQueryParams[key] ?? '') !== String(value ?? '');
|
||||
});
|
||||
|
||||
if (!hasChanged) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.router.navigate([], {
|
||||
relativeTo: this.activatedRoute,
|
||||
queryParams: {
|
||||
table: value.displayedTable,
|
||||
search_term: value.searchTerm,
|
||||
filter_by: value.filterBy,
|
||||
start_year: value.startYear,
|
||||
end_year: value.endYear,
|
||||
min_contributors: value.minContributors,
|
||||
max_contributors: value.maxContributors,
|
||||
min_collaborations: value.minCollaborations,
|
||||
max_collaborations: value.maxCollaborations,
|
||||
institutions: value.institutions?.join(','),
|
||||
topics: value.topics?.join(','),
|
||||
},
|
||||
queryParams,
|
||||
replaceUrl: true,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -8,6 +8,11 @@ import {
|
||||
WorksFilterProperties,
|
||||
} from '../api';
|
||||
|
||||
const DEFAULT_MIN_CONTRIBUTORS = 2;
|
||||
const DEFAULT_MAX_CONTRIBUTORS = 10;
|
||||
const DEFAULT_MIN_COLLABORATIONS = 1;
|
||||
const DEFAULT_MAX_COLLABORATIONS = 100;
|
||||
|
||||
export const collaborationNetworkResolver: ResolveFn<CollaborationNetwork> = (
|
||||
route,
|
||||
state,
|
||||
@@ -38,10 +43,10 @@ export const collaborationNetworkResolver: ResolveFn<CollaborationNetwork> = (
|
||||
end_year: endYear ? Number.parseInt(endYear, 10) : undefined,
|
||||
min_contributors: minContributors
|
||||
? Number.parseInt(minContributors, 10)
|
||||
: undefined,
|
||||
: DEFAULT_MIN_CONTRIBUTORS,
|
||||
max_contributors: maxContributors
|
||||
? Number.parseInt(maxContributors, 10)
|
||||
: undefined,
|
||||
: DEFAULT_MAX_CONTRIBUTORS,
|
||||
allowed_topics: topics ? topics.split(',') : undefined,
|
||||
};
|
||||
}
|
||||
@@ -49,10 +54,10 @@ export const collaborationNetworkResolver: ResolveFn<CollaborationNetwork> = (
|
||||
authorsFilterProperties = {
|
||||
min_collaborations: minCollaborations
|
||||
? Number.parseInt(minCollaborations, 10)
|
||||
: undefined,
|
||||
: DEFAULT_MIN_COLLABORATIONS,
|
||||
max_collaborations: maxCollaborations
|
||||
? Number.parseInt(maxCollaborations, 10)
|
||||
: undefined,
|
||||
: DEFAULT_MAX_COLLABORATIONS,
|
||||
allowed_institutions: institutions ? institutions.split(',') : undefined,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ mat-toolbar.main {
|
||||
}
|
||||
|
||||
.drawer--collapsed {
|
||||
width: 76px;
|
||||
width: 64px;
|
||||
}
|
||||
|
||||
.content {
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
[routerLink]="item.disabled ? null : item.route"
|
||||
[queryParams]="item.queryParams || null"
|
||||
routerLinkActive="active"
|
||||
[routerLinkActiveOptions]="navLinkActiveOptions"
|
||||
[class.disabled]="item.disabled"
|
||||
[matTooltip]="item.label"
|
||||
matTooltipPosition="right"
|
||||
@@ -61,6 +62,7 @@
|
||||
[routerLink]="item.disabled ? null : item.route"
|
||||
[queryParams]="item.queryParams || null"
|
||||
routerLinkActive="active"
|
||||
[routerLinkActiveOptions]="navLinkActiveOptions"
|
||||
[class.disabled]="item.disabled">
|
||||
<mat-icon matListItemIcon>{{ item.icon }}</mat-icon>
|
||||
<span matListItemTitle>{{ item.label }}</span>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
.sidebar--collapsed {
|
||||
align-items: center;
|
||||
padding: 18px 10px 20px;
|
||||
padding: 18px 8px 20px;
|
||||
}
|
||||
|
||||
.brand-row {
|
||||
@@ -268,3 +268,12 @@
|
||||
.loading-indicator {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.sidebar--collapsed .nav-list,
|
||||
.sidebar--collapsed .sidebar-actions {
|
||||
justify-items: center;
|
||||
}
|
||||
|
||||
.sidebar--collapsed .account-icon {
|
||||
margin-inline: auto;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
import { Component, computed, inject, input, output } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { Router, RouterLink, RouterLinkActive } from '@angular/router';
|
||||
import {
|
||||
IsActiveMatchOptions,
|
||||
Router,
|
||||
RouterLink,
|
||||
RouterLinkActive,
|
||||
} from '@angular/router';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatListModule } from '@angular/material/list';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
@@ -30,6 +35,12 @@ export class AppMenuComponent {
|
||||
collapsed = input(false);
|
||||
canCollapse = input(false);
|
||||
toggleCollapsed = output<void>();
|
||||
readonly navLinkActiveOptions: IsActiveMatchOptions = {
|
||||
paths: 'subset',
|
||||
queryParams: 'ignored',
|
||||
matrixParams: 'ignored',
|
||||
fragment: 'ignored',
|
||||
};
|
||||
navItems = [
|
||||
{
|
||||
label: 'Dashboard',
|
||||
|
||||
Reference in New Issue
Block a user