Skip to content

Commit e1b773c

Browse files
author
Jens Vannerum
committed
119612: Check if a warning should be shown on changes to the total elements of the search, default to 500 if no value for the configuration property was returned
1 parent 2a39bd8 commit e1b773c

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

src/app/shared/search/search-export-csv/search-export-csv.component.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ import {
55
import {
66
Component,
77
Input,
8+
OnChanges,
89
OnInit,
10+
SimpleChanges,
911
} from '@angular/core';
1012
import { Router } from '@angular/router';
1113
import { NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap';
@@ -48,7 +50,7 @@ import { SearchFilter } from '../models/search-filter.model';
4850
/**
4951
* Display a button to export the current search results as csv
5052
*/
51-
export class SearchExportCsvComponent implements OnInit {
53+
export class SearchExportCsvComponent implements OnInit, OnChanges {
5254

5355
/**
5456
* The current configuration of the search
@@ -94,16 +96,22 @@ export class SearchExportCsvComponent implements OnInit {
9496
this.shouldShowWarning$ = this.itemExceeds();
9597
}
9698

99+
ngOnChanges(changes: SimpleChanges): void {
100+
if (changes.total) {
101+
this.shouldShowWarning$ = this.itemExceeds();
102+
}
103+
}
104+
97105
/**
98106
* Checks if the export limit has been exceeded and updates the tooltip accordingly
99107
*/
100108
private itemExceeds(): Observable<boolean> {
101-
return this.configurationService.findByPropertyName('metadataexport.max.items').pipe(
109+
return this.configurationService.findByPropertyName('bulkedit.export.max.items').pipe(
102110
getFirstCompletedRemoteData(),
103111
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] });
112+
const limit = Number(response.payload?.values?.[0]) || 500;
113+
if (limit < this.total) {
114+
this.exportLimitExceededMsg = this.translateService.instant(this.exportLimitExceededKey, { limit: String(limit) });
107115
return true;
108116
} else {
109117
return false;

0 commit comments

Comments
 (0)