From c36c8d726e0e1599080bed761f16500acc277812 Mon Sep 17 00:00:00 2001 From: Jens Vannerum Date: Mon, 3 Feb 2025 10:11:28 +0100 Subject: [PATCH] 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 (cherry picked from commit e1b773c097289500de32ced24eeb1e8f2c0d25e9) --- .../search-export-csv.component.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/app/shared/search/search-export-csv/search-export-csv.component.ts b/src/app/shared/search/search-export-csv/search-export-csv.component.ts index 8b6252ada7..2727c6cce7 100644 --- a/src/app/shared/search/search-export-csv/search-export-csv.component.ts +++ b/src/app/shared/search/search-export-csv/search-export-csv.component.ts @@ -5,7 +5,9 @@ import { import { Component, Input, + OnChanges, OnInit, + SimpleChanges, } from '@angular/core'; import { Router } from '@angular/router'; import { NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap'; @@ -48,7 +50,7 @@ import { SearchFilter } from '../models/search-filter.model'; /** * Display a button to export the current search results as csv */ -export class SearchExportCsvComponent implements OnInit { +export class SearchExportCsvComponent implements OnInit, OnChanges { /** * The current configuration of the search @@ -94,16 +96,22 @@ export class SearchExportCsvComponent implements OnInit { this.shouldShowWarning$ = this.itemExceeds(); } + ngOnChanges(changes: SimpleChanges): void { + if (changes.total) { + this.shouldShowWarning$ = this.itemExceeds(); + } + } + /** * Checks if the export limit has been exceeded and updates the tooltip accordingly */ private itemExceeds(): Observable { - return this.configurationService.findByPropertyName('metadataexport.max.items').pipe( + return this.configurationService.findByPropertyName('bulkedit.export.max.items').pipe( getFirstCompletedRemoteData(), map((response: RemoteData) => { - const limit = Number(response.payload?.values?.[0]); - if (response.hasSucceeded && limit < this.total) { - this.exportLimitExceededMsg = this.translateService.instant(this.exportLimitExceededKey, { limit: response.payload?.values?.[0] }); + const limit = Number(response.payload?.values?.[0]) || 500; + if (limit < this.total) { + this.exportLimitExceededMsg = this.translateService.instant(this.exportLimitExceededKey, { limit: String(limit) }); return true; } else { return false;