Skip to content

Commit f779bbe

Browse files
author
Jens Vannerum
committed
122064: fix issues after cherry-picking changes to latest main
1 parent 5b0e7c1 commit f779bbe

7 files changed

Lines changed: 37 additions & 34 deletions

File tree

src/app/browse-by/browse-by-date/browse-by-date.component.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,17 @@ import {
1010
} from '@angular/core';
1111
import {
1212
ActivatedRoute,
13-
Params,
1413
Router,
1514
} from '@angular/router';
1615
import { TranslateModule } from '@ngx-translate/core';
1716
import {
1817
combineLatest as observableCombineLatest,
1918
Observable,
2019
} from 'rxjs';
21-
import { map } from 'rxjs/operators';
20+
import {
21+
map,
22+
switchMap,
23+
} from 'rxjs/operators';
2224
import { ThemedBrowseByComponent } from 'src/app/shared/browse-by/themed-browse-by.component';
2325

2426
import {
@@ -47,13 +49,11 @@ import {
4749
isNotEmpty,
4850
} from '../../shared/empty.util';
4951
import { ThemedLoadingComponent } from '../../shared/loading/themed-loading.component';
50-
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
5152
import { StartsWithType } from '../../shared/starts-with/starts-with-type';
5253
import { VarDirective } from '../../shared/utils/var.directive';
5354
import {
5455
BrowseByMetadataComponent,
5556
browseParamsToOptions,
56-
getBrowseSearchOptions,
5757
} from '../browse-by-metadata/browse-by-metadata.component';
5858

5959
@Component({
@@ -111,19 +111,18 @@ export class BrowseByDateComponent extends BrowseByMetadataComponent implements
111111
switchMap((sortConfig) => {
112112
this.currentPagination$ = this.paginationService.getCurrentPagination(this.paginationConfig.id, this.paginationConfig);
113113
this.currentSort$ = this.paginationService.getCurrentSort(this.paginationConfig.id, sortConfig, false);
114-
return observableCombineLatest([this.route.params, this.route.queryParams, this.route.data, this.currentPagination$, this.currentSort$]).pipe(
115-
map(([routeParams, queryParams, data, currentPage, currentSort]) => ({
116-
params: Object.assign({}, routeParams, queryParams, data), currentPage, currentSort
114+
return observableCombineLatest([this.route.params, this.route.queryParams, this.scope$, this.route.data, this.currentPagination$, this.currentSort$]).pipe(
115+
map(([routeParams, queryParams, scope, data, currentPage, currentSort]) => ({
116+
params: Object.assign({}, routeParams, queryParams, data), scope, currentPage, currentSort,
117117
})));
118-
})).subscribe(({ params, currentPage, currentSort }) => {
118+
})).subscribe(({ params, scope, currentPage, currentSort }) => {
119119
const metadataKeys = params.browseDefinition ? params.browseDefinition.metadataKeys : this.defaultMetadataKeys;
120120
this.startsWith = +params.startsWith || params.startsWith;
121121
this.browseId = params.id || this.defaultBrowseId;
122-
const searchOptions = browseParamsToOptions(params, currentPage, currentSort, this.browseId, this.fetchThumbnails);
122+
const searchOptions = browseParamsToOptions(params, scope, currentPage, currentSort, this.browseId, this.fetchThumbnails);
123123
this.updatePageWithItems(searchOptions, this.value, undefined);
124124
this.updateStartsWithOptions(this.browseId, metadataKeys, params.scope);
125-
})
126-
);
125+
}));
127126
}
128127

129128
/**

src/app/browse-by/browse-by-metadata/browse-by-metadata.component.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
} from '@angular/core';
1313
import {
1414
ActivatedRoute,
15-
Params,
1615
Router,
1716
} from '@angular/router';
1817
import { TranslateModule } from '@ngx-translate/core';
@@ -23,7 +22,10 @@ import {
2322
of as observableOf,
2423
Subscription,
2524
} from 'rxjs';
26-
import { map } from 'rxjs/operators';
25+
import {
26+
map,
27+
switchMap,
28+
} from 'rxjs/operators';
2729
import { ThemedBrowseByComponent } from 'src/app/shared/browse-by/themed-browse-by.component';
2830

2931
import {
@@ -219,7 +221,7 @@ export class BrowseByMetadataComponent implements OnInit, OnChanges, OnDestroy {
219221
this.currentPagination$ = this.paginationService.getCurrentPagination(this.paginationConfig.id, this.paginationConfig);
220222
return observableCombineLatest([this.route.params, this.route.queryParams, this.scope$, this.currentPagination$, this.currentSort$]).pipe(
221223
map(([routeParams, queryParams, scope, currentPage, currentSort]) => ({
222-
params: Object.assign({}, routeParams, queryParams), scope, currentPage, currentSort
224+
params: Object.assign({}, routeParams, queryParams), scope, currentPage, currentSort,
223225
})));
224226
})).subscribe(({ params, scope, currentPage, currentSort }) => {
225227
this.authority = params.authority;
@@ -241,7 +243,7 @@ export class BrowseByMetadataComponent implements OnInit, OnChanges, OnDestroy {
241243
if (isNotEmpty(this.value)) {
242244
this.updatePageWithItems(browseParamsToOptions(params, scope, currentPage, currentSort, this.browseId, this.fetchThumbnails), this.value, this.authority);
243245
} else {
244-
is.updatePage(browseParamsToOptions(params, scope, currentPage, currentSort, this.browseId, false));
246+
this.updatePage(browseParamsToOptions(params, scope, currentPage, currentSort, this.browseId, false));
245247
}
246248
this.updateStartsWithTextOptions();
247249
}));

src/app/browse-by/browse-by-title-page/browse-by-title-page.component.ts

Whitespace-only changes.

src/app/browse-by/browse-by-title/browse-by-title.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { of as observableOf } from 'rxjs';
2020
import { APP_CONFIG } from '../../../config/app-config.interface';
2121
import { environment } from '../../../environments/environment';
2222
import { BrowseService } from '../../core/browse/browse.service';
23+
import { SortDirection } from '../../core/cache/models/sort-options.model';
2324
import { DSpaceObjectDataService } from '../../core/data/dspace-object-data.service';
2425
import { ItemDataService } from '../../core/data/item-data.service';
2526
import { PaginationService } from '../../core/pagination/pagination.service';
@@ -41,7 +42,6 @@ import { EnumKeysPipe } from '../../shared/utils/enum-keys-pipe';
4142
import { VarDirective } from '../../shared/utils/var.directive';
4243
import { toRemoteData } from '../browse-by-metadata/browse-by-metadata.component.spec';
4344
import { BrowseByTitleComponent } from './browse-by-title.component';
44-
import { SortDirection } from '../../core/cache/models/sort-options.model';
4545

4646
describe('BrowseByTitleComponent', () => {
4747
let comp: BrowseByTitleComponent;

src/app/browse-by/browse-by-title/browse-by-title.component.ts

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ import {
66
Component,
77
OnInit,
88
} from '@angular/core';
9-
import { Params } from '@angular/router';
109
import { TranslateModule } from '@ngx-translate/core';
1110
import { combineLatest as observableCombineLatest } from 'rxjs';
12-
import { map } from 'rxjs/operators';
11+
import {
12+
map,
13+
switchMap,
14+
} from 'rxjs/operators';
1315

1416
import {
1517
SortDirection,
@@ -23,12 +25,10 @@ import { ComcolPageHeaderComponent } from '../../shared/comcol/comcol-page-heade
2325
import { ComcolPageLogoComponent } from '../../shared/comcol/comcol-page-logo/comcol-page-logo.component';
2426
import { DsoEditMenuComponent } from '../../shared/dso-page/dso-edit-menu/dso-edit-menu.component';
2527
import { ThemedLoadingComponent } from '../../shared/loading/themed-loading.component';
26-
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
2728
import { VarDirective } from '../../shared/utils/var.directive';
2829
import {
2930
BrowseByMetadataComponent,
3031
browseParamsToOptions,
31-
getBrowseSearchOptions,
3232
} from '../browse-by-metadata/browse-by-metadata.component';
3333

3434
@Component({
@@ -57,22 +57,23 @@ import {
5757
export class BrowseByTitleComponent extends BrowseByMetadataComponent implements OnInit {
5858

5959
ngOnInit(): void {
60-
const sortConfig = new SortOptions('dc.title', SortDirection.ASC);
61-
// include the thumbnail configuration in browse search options
62-
this.updatePage(getBrowseSearchOptions(this.defaultBrowseId, this.paginationConfig, sortConfig, this.fetchThumbnails));
63-
this.currentPagination$ = this.paginationService.getCurrentPagination(this.paginationConfig.id, this.paginationConfig);
64-
this.currentSort$ = this.paginationService.getCurrentSort(this.paginationConfig.id, sortConfig);
60+
this.browseId = this.route.snapshot.params.id;
6561
this.subs.push(
66-
observableCombineLatest([this.route.params, this.route.queryParams, this.scope$, this.currentPagination$, this.currentSort$]).pipe(
67-
map(([routeParams, queryParams, scope, currentPage, currentSort]) => {
68-
return [Object.assign({}, routeParams, queryParams), scope, currentPage, currentSort];
69-
}),
70-
).subscribe(([params, scope, currentPage, currentSort]: [Params, string, PaginationComponentOptions, SortOptions]) => {
62+
this.browseService.getConfiguredSortDirection(this.browseId, SortDirection.ASC).pipe(
63+
map((sortDir) => new SortOptions(this.browseId, sortDir)),
64+
switchMap((sortConfig) => {
65+
this.currentSort$ = this.paginationService.getCurrentSort(this.paginationConfig.id, sortConfig, false);
66+
this.currentPagination$ = this.paginationService.getCurrentPagination(this.paginationConfig.id, this.paginationConfig);
67+
return observableCombineLatest([this.route.params, this.route.queryParams, this.scope$, this.currentPagination$, this.currentSort$]).pipe(
68+
map(([routeParams, queryParams, scope, currentPage, currentSort]) => ({
69+
params: Object.assign({}, routeParams, queryParams), scope, currentPage, currentSort,
70+
})),
71+
);
72+
})).subscribe(({ params, scope, currentPage, currentSort }) => {
7173
this.startsWith = +params.startsWith || params.startsWith;
72-
this.browseId = params.id || this.defaultBrowseId;
7374
this.updatePageWithItems(browseParamsToOptions(params, scope, currentPage, currentSort, this.browseId, this.fetchThumbnails), undefined, undefined);
75+
this.updateStartsWithTextOptions();
7476
}));
75-
this.updateStartsWithTextOptions();
7677
}
7778

7879
}

src/app/core/browse/browse.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export class BrowseService {
138138
getRemoteDataPayload(),
139139
getPaginatedListPayload(),
140140
map((browseDefinitions: BrowseDefinition[]) => browseDefinitions
141-
.find((def: BrowseDefinition) => def.id === browseId)
141+
.find((def: BrowseDefinition) => def.id === browseId),
142142
),
143143
map((browseDef: BrowseDefinition) => {
144144
if (browseDef.order === SortDirection.ASC || browseDef.order === SortDirection.DESC) {

src/app/core/shared/browse-definition.model.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { autoserialize } from 'cerialize';
22

33
import { BrowseByDataType } from '../../browse-by/browse-by-switcher/browse-by-data-type';
44
import { CacheableObject } from '../cache/cacheable-object.model';
5+
import { SortDirection } from '../cache/models/sort-options.model';
56

67
/**
78
* Base class for BrowseDefinition models
@@ -12,7 +13,7 @@ export abstract class BrowseDefinition extends CacheableObject {
1213
id: string;
1314

1415
@autoserialize
15-
order: string;
16+
order: SortDirection;
1617

1718
/**
1819
* Get the render type of the BrowseDefinition model

0 commit comments

Comments
 (0)