@@ -21,10 +21,12 @@ import {
2121 switchMap ,
2222} from 'rxjs/operators' ;
2323
24+ import { ConfigurationDataService } from '../../../core/data/configuration-data.service' ;
2425import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service' ;
2526import { FeatureID } from '../../../core/data/feature-authorization/feature-id' ;
2627import { ScriptDataService } from '../../../core/data/processes/script-data.service' ;
2728import { RemoteData } from '../../../core/data/remote-data' ;
29+ import { ConfigurationProperty } from '../../../core/shared/configuration-property.model' ;
2830import { getFirstCompletedRemoteData } from '../../../core/shared/operators' ;
2931import { getProcessDetailRoute } from '../../../process-page/process-page-routing.paths' ;
3032import { Process } from '../../../process-page/processes/process.model' ;
@@ -53,6 +55,11 @@ export class SearchExportCsvComponent implements OnInit {
5355 */
5456 @Input ( ) searchConfig : PaginatedSearchOptions ;
5557
58+ /**
59+ * The total number of items in the search results which can be exported
60+ */
61+ @Input ( ) total : number ;
62+
5663 /**
5764 * Observable used to determine whether the button should be shown
5865 */
@@ -63,12 +70,18 @@ export class SearchExportCsvComponent implements OnInit {
6370 */
6471 tooltipMsg = 'metadata-export-search.tooltip' ;
6572
73+ exportLimitExceededKey = 'metadata-export-search.submit.error.limit-exceeded' ;
74+
75+ exportLimitExceededMsg = '' ;
76+
77+ shouldShowWarning$ : Observable < boolean > ;
78+
6679 constructor ( private scriptDataService : ScriptDataService ,
6780 private authorizationDataService : AuthorizationDataService ,
6881 private notificationsService : NotificationsService ,
6982 private translateService : TranslateService ,
7083 private router : Router ,
71- ) {
84+ private configurationService : ConfigurationDataService ) {
7285 }
7386
7487 ngOnInit ( ) : void {
@@ -78,6 +91,25 @@ export class SearchExportCsvComponent implements OnInit {
7891 map ( ( canExecute : boolean ) => canExecute ) ,
7992 startWith ( false ) ,
8093 ) ;
94+ this . shouldShowWarning$ = this . itemExceeds ( ) ;
95+ }
96+
97+ /**
98+ * Checks if the export limit has been exceeded and updates the tooltip accordingly
99+ */
100+ private itemExceeds ( ) : Observable < boolean > {
101+ return this . configurationService . findByPropertyName ( 'metadataexport.max.items' ) . pipe (
102+ getFirstCompletedRemoteData ( ) ,
103+ map ( ( response : RemoteData < ConfigurationProperty > ) => {
104+ const limit = Number ( response . payload ?. values ?. [ 0 ] ) ;
105+ if ( response . hasSucceeded && limit < this . total ) {
106+ this . exportLimitExceededMsg = this . translateService . instant ( this . exportLimitExceededKey , { limit : response . payload ?. values ?. [ 0 ] } ) ;
107+ return true ;
108+ } else {
109+ return false ;
110+ }
111+ } ) ,
112+ ) ;
81113 }
82114
83115 /**
0 commit comments