mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
#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:
@@ -8,6 +8,7 @@
|
|||||||
<ds-viewable-collection
|
<ds-viewable-collection
|
||||||
[config]="config"
|
[config]="config"
|
||||||
[sortConfig]="sortConfig"
|
[sortConfig]="sortConfig"
|
||||||
|
[showRSS]="rssSortConfig"
|
||||||
[objects]="communitiesRD$ | async"
|
[objects]="communitiesRD$ | async"
|
||||||
[hideGear]="true">
|
[hideGear]="true">
|
||||||
</ds-viewable-collection>
|
</ds-viewable-collection>
|
||||||
|
@@ -65,9 +65,10 @@ export class TopLevelCommunityListComponent implements OnInit, OnDestroy {
|
|||||||
pageId = 'tl';
|
pageId = 'tl';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The sorting configuration
|
* The sorting configuration for the community list itself, and the optional RSS feed button
|
||||||
*/
|
*/
|
||||||
sortConfig: SortOptions;
|
sortConfig: SortOptions;
|
||||||
|
rssSortConfig: SortOptions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The subscription to the observable for the current page.
|
* 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.pageSize = appConfig.homePage.topLevelCommunityList.pageSize;
|
||||||
this.config.currentPage = 1;
|
this.config.currentPage = 1;
|
||||||
this.sortConfig = new SortOptions('dc.title', SortDirection.ASC);
|
this.sortConfig = new SortOptions('dc.title', SortDirection.ASC);
|
||||||
|
this.rssSortConfig = new SortOptions('dc.date.accessioned', SortDirection.DESC);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
@@ -85,7 +85,7 @@ export class ObjectCollectionComponent implements OnInit {
|
|||||||
/**
|
/**
|
||||||
* Whether to show an RSS syndication button for the current search options
|
* 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.
|
* Emit custom event for listable object custom actions.
|
||||||
|
@@ -85,7 +85,10 @@ export class ObjectDetailComponent {
|
|||||||
*/
|
*/
|
||||||
@Input() showThumbnails;
|
@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.
|
* Emit when one of the listed object has changed.
|
||||||
|
@@ -73,7 +73,7 @@ export class ObjectListComponent {
|
|||||||
/**
|
/**
|
||||||
* Whether to show an RSS syndication button for the current search options
|
* 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
|
* The link type of the listable elements
|
||||||
|
@@ -59,7 +59,7 @@ export class ThemedObjectListComponent extends ThemedComponent<ObjectListCompone
|
|||||||
|
|
||||||
@Input() selectionConfig: { repeatable: boolean, listId: string };
|
@Input() selectionConfig: { repeatable: boolean, listId: string };
|
||||||
|
|
||||||
@Input() showRSS = false;
|
@Input() showRSS: SortOptions | boolean = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The link type of the listable elements
|
* The link type of the listable elements
|
||||||
|
@@ -44,7 +44,7 @@
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
@if (showRSS) {
|
@if (showRSS) {
|
||||||
<ds-rss [sortConfig]="this.sortOptions"></ds-rss>
|
<ds-rss [sortConfig]="rssSortOptions"></ds-rss>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -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
|
* or other lists where an RSS feed doesn't make sense, but uses the same components as recent items or search result
|
||||||
* lists.
|
* lists.
|
||||||
*/
|
*/
|
||||||
@Input() public showRSS = false;
|
@Input() public showRSS: SortOptions | boolean = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Current page.
|
* 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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user