mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
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 e1b773c097
)
This commit is contained in:
@@ -5,7 +5,9 @@ import {
|
|||||||
import {
|
import {
|
||||||
Component,
|
Component,
|
||||||
Input,
|
Input,
|
||||||
|
OnChanges,
|
||||||
OnInit,
|
OnInit,
|
||||||
|
SimpleChanges,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap';
|
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
|
* 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
|
* The current configuration of the search
|
||||||
@@ -94,16 +96,22 @@ export class SearchExportCsvComponent implements OnInit {
|
|||||||
this.shouldShowWarning$ = this.itemExceeds();
|
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
|
* Checks if the export limit has been exceeded and updates the tooltip accordingly
|
||||||
*/
|
*/
|
||||||
private itemExceeds(): Observable<boolean> {
|
private itemExceeds(): Observable<boolean> {
|
||||||
return this.configurationService.findByPropertyName('metadataexport.max.items').pipe(
|
return this.configurationService.findByPropertyName('bulkedit.export.max.items').pipe(
|
||||||
getFirstCompletedRemoteData(),
|
getFirstCompletedRemoteData(),
|
||||||
map((response: RemoteData<ConfigurationProperty>) => {
|
map((response: RemoteData<ConfigurationProperty>) => {
|
||||||
const limit = Number(response.payload?.values?.[0]);
|
const limit = Number(response.payload?.values?.[0]) || 500;
|
||||||
if (response.hasSucceeded && limit < this.total) {
|
if (limit < this.total) {
|
||||||
this.exportLimitExceededMsg = this.translateService.instant(this.exportLimitExceededKey, { limit: response.payload?.values?.[0] });
|
this.exportLimitExceededMsg = this.translateService.instant(this.exportLimitExceededKey, { limit: String(limit) });
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
Reference in New Issue
Block a user