Skip to content

Commit f0dd3ff

Browse files
committed
#4172 Allow SortOptions override to showRSS input
If a valid, complete SortOptions is passed to the pagination component showRSS, it will be used instead of the underlying sortOptions, otherwise the pagination context sortOptions will be used.
1 parent f33d2d3 commit f0dd3ff

8 files changed

Lines changed: 28 additions & 7 deletions

File tree

src/app/home-page/top-level-community-list/top-level-community-list.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ <h2>
88
<ds-viewable-collection
99
[config]="config"
1010
[sortConfig]="sortConfig"
11+
[showRSS]="rssSortConfig"
1112
[objects]="communitiesRD$ | async"
1213
[hideGear]="true">
1314
</ds-viewable-collection>

src/app/home-page/top-level-community-list/top-level-community-list.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,10 @@ export class TopLevelCommunityListComponent implements OnInit, OnDestroy {
6565
pageId = 'tl';
6666

6767
/**
68-
* The sorting configuration
68+
* The sorting configuration for the community list itself, and the optional RSS feed button
6969
*/
7070
sortConfig: SortOptions;
71+
rssSortConfig: SortOptions;
7172

7273
/**
7374
* The subscription to the observable for the current page.
@@ -84,6 +85,7 @@ export class TopLevelCommunityListComponent implements OnInit, OnDestroy {
8485
this.config.pageSize = appConfig.homePage.topLevelCommunityList.pageSize;
8586
this.config.currentPage = 1;
8687
this.sortConfig = new SortOptions('dc.title', SortDirection.ASC);
88+
this.rssSortConfig = new SortOptions('dc.date.accessioned', SortDirection.DESC);
8789
}
8890

8991
ngOnInit() {

src/app/shared/object-collection/object-collection.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export class ObjectCollectionComponent implements OnInit {
8585
/**
8686
* Whether to show an RSS syndication button for the current search options
8787
*/
88-
@Input() showRSS = false;
88+
@Input() showRSS: SortOptions | boolean = false;
8989

9090
/**
9191
* Emit custom event for listable object custom actions.

src/app/shared/object-detail/object-detail.component.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ export class ObjectDetailComponent {
8585
*/
8686
@Input() showThumbnails;
8787

88-
@Input() showRSS = false;
88+
/**
89+
* Whether to show the RSS syndication link. Either false, or valid SortOptions object
90+
*/
91+
@Input() showRSS: SortOptions | boolean = false;
8992

9093
/**
9194
* Emit when one of the listed object has changed.

src/app/shared/object-list/object-list.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export class ObjectListComponent {
7373
/**
7474
* Whether to show an RSS syndication button for the current search options
7575
*/
76-
@Input() showRSS = false;
76+
@Input() showRSS: SortOptions | boolean = false;
7777

7878
/**
7979
* The link type of the listable elements

src/app/shared/object-list/themed-object-list.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export class ThemedObjectListComponent extends ThemedComponent<ObjectListCompone
5959

6060
@Input() selectionConfig: { repeatable: boolean, listId: string };
6161

62-
@Input() showRSS = false;
62+
@Input() showRSS: SortOptions | boolean = false;
6363

6464
/**
6565
* The link type of the listable elements

src/app/shared/pagination/pagination.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
</div>
4545
}
4646
@if (showRSS) {
47-
<ds-rss [sortConfig]="this.sortOptions"></ds-rss>
47+
<ds-rss [sortConfig]="rssSortOptions"></ds-rss>
4848
}
4949
</div>
5050
</div>

src/app/shared/pagination/pagination.component.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ export class PaginationComponent implements OnChanges, OnDestroy, OnInit {
173173
* or other lists where an RSS feed doesn't make sense, but uses the same components as recent items or search result
174174
* lists.
175175
*/
176-
@Input() public showRSS = false;
176+
@Input() public showRSS: SortOptions | boolean = false;
177177

178178
/**
179179
* Current page.
@@ -442,4 +442,19 @@ export class PaginationComponent implements OnChanges, OnDestroy, OnInit {
442442
});
443443
}
444444

445+
/**
446+
* Get the sort options to use for the RSS feed. Defaults to the sort options used for this pagination component
447+
* so it matches the search/browse context, but also allows more flexibility if, for example a top-level community
448+
* list is displayed in "title asc" order, but the RSS feed should default to an item list of "date desc" order.
449+
* If the SortOptions are null, incomplete or invalid, the pagination sortOptions will be used instead.
450+
*/
451+
get rssSortOptions() {
452+
if (this.showRSS !== false && this.showRSS instanceof SortOptions
453+
&& this.showRSS.direction !== null
454+
&& this.showRSS.field !== null) {
455+
return this.showRSS;
456+
}
457+
return this.sortOptions;
458+
}
459+
445460
}

0 commit comments

Comments
 (0)