#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.
This commit is contained in:
Kim Shepherd
2025-04-24 15:09:19 +02:00
parent b89a626ffc
commit 3a347d83b5
8 changed files with 28 additions and 7 deletions

View File

@@ -8,6 +8,7 @@
<ds-viewable-collection
[config]="config"
[sortConfig]="sortConfig"
[showRSS]="rssSortConfig"
[objects]="communitiesRD$ | async"
[hideGear]="true">
</ds-viewable-collection>

View File

@@ -65,9 +65,10 @@ export class TopLevelCommunityListComponent implements OnInit, OnDestroy {
pageId = 'tl';
/**
* The sorting configuration
* The sorting configuration for the community list itself, and the optional RSS feed button
*/
sortConfig: SortOptions;
rssSortConfig: SortOptions;
/**
* The subscription to the observable for the current page.
@@ -84,6 +85,7 @@ export class TopLevelCommunityListComponent implements OnInit, OnDestroy {
this.config.pageSize = appConfig.homePage.topLevelCommunityList.pageSize;
this.config.currentPage = 1;
this.sortConfig = new SortOptions('dc.title', SortDirection.ASC);
this.rssSortConfig = new SortOptions('dc.date.accessioned', SortDirection.DESC);
}
ngOnInit() {

View File

@@ -85,7 +85,7 @@ export class ObjectCollectionComponent implements OnInit {
/**
* Whether to show an RSS syndication button for the current search options
*/
@Input() showRSS = false;
@Input() showRSS: SortOptions | boolean = false;
/**
* Emit custom event for listable object custom actions.

View File

@@ -85,7 +85,10 @@ export class ObjectDetailComponent {
*/
@Input() showThumbnails;
@Input() showRSS = false;
/**
* Whether to show the RSS syndication link. Either false, or valid SortOptions object
*/
@Input() showRSS: SortOptions | boolean = false;
/**
* Emit when one of the listed object has changed.

View File

@@ -73,7 +73,7 @@ export class ObjectListComponent {
/**
* Whether to show an RSS syndication button for the current search options
*/
@Input() showRSS = false;
@Input() showRSS: SortOptions | boolean = false;
/**
* The link type of the listable elements

View File

@@ -59,7 +59,7 @@ export class ThemedObjectListComponent extends ThemedComponent<ObjectListCompone
@Input() selectionConfig: { repeatable: boolean, listId: string };
@Input() showRSS = false;
@Input() showRSS: SortOptions | boolean = false;
/**
* The link type of the listable elements

View File

@@ -44,7 +44,7 @@
</div>
}
@if (showRSS) {
<ds-rss [sortConfig]="this.sortOptions"></ds-rss>
<ds-rss [sortConfig]="rssSortOptions"></ds-rss>
}
</div>
</div>

View File

@@ -173,7 +173,7 @@ export class PaginationComponent implements OnChanges, OnDestroy, OnInit {
* or other lists where an RSS feed doesn't make sense, but uses the same components as recent items or search result
* lists.
*/
@Input() public showRSS = false;
@Input() public showRSS: SortOptions | boolean = false;
/**
* Current page.
@@ -442,4 +442,19 @@ export class PaginationComponent implements OnChanges, OnDestroy, OnInit {
});
}
/**
* Get the sort options to use for the RSS feed. Defaults to the sort options used for this pagination component
* so it matches the search/browse context, but also allows more flexibility if, for example a top-level community
* list is displayed in "title asc" order, but the RSS feed should default to an item list of "date desc" order.
* If the SortOptions are null, incomplete or invalid, the pagination sortOptions will be used instead.
*/
get rssSortOptions() {
if (this.showRSS !== false && this.showRSS instanceof SortOptions
&& this.showRSS.direction !== null
&& this.showRSS.field !== null) {
return this.showRSS;
}
return this.sortOptions;
}
}