mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
119612: UI warning that only first part of configured items will be exported
(cherry picked from commit b69b21af6c
)
This commit is contained in:
@@ -1,7 +1,20 @@
|
||||
<ng-template #tipContent>
|
||||
<div class="tooltip-content">
|
||||
<p class="m-0">{{tooltipMsg | translate}}</p>
|
||||
</div>
|
||||
</ng-template>
|
||||
|
||||
<ng-template #tipContentWarning>
|
||||
<div class="tooltip-content">
|
||||
<p class="m-0">{{tooltipMsg | translate}}</p>
|
||||
<p class="m-0 text-warning">{{exportLimitExceededMsg}}</p>
|
||||
</div>
|
||||
</ng-template>
|
||||
|
||||
<button *ngIf="shouldShowButton$ | async"
|
||||
class="export-button btn btn-dark btn-sm"
|
||||
[ngbTooltip]="tooltipMsg | translate"
|
||||
[ngbTooltip]="(shouldShowWarning$ | async) ? tipContentWarning : tipContent"
|
||||
(click)="export()"
|
||||
[title]="tooltipMsg |translate" [attr.aria-label]="tooltipMsg |translate">
|
||||
<i class="fas fa-file-export fa-fw"></i>
|
||||
</button>
|
||||
</button>
|
||||
|
@@ -14,6 +14,8 @@ import { TranslateService } from '@ngx-translate/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { PaginatedSearchOptions } from '../models/paginated-search-options.model';
|
||||
import { SearchFilter } from '../models/search-filter.model';
|
||||
import { ConfigurationDataService } from '../../../core/data/configuration-data.service';
|
||||
import { ConfigurationProperty } from '../../../core/shared/configuration-property.model';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-search-export-csv',
|
||||
@@ -30,6 +32,11 @@ export class SearchExportCsvComponent implements OnInit {
|
||||
*/
|
||||
@Input() searchConfig: PaginatedSearchOptions;
|
||||
|
||||
/**
|
||||
* The total number of items in the search results which can be exported
|
||||
*/
|
||||
@Input() total: number;
|
||||
|
||||
/**
|
||||
* Observable used to determine whether the button should be shown
|
||||
*/
|
||||
@@ -40,12 +47,18 @@ export class SearchExportCsvComponent implements OnInit {
|
||||
*/
|
||||
tooltipMsg = 'metadata-export-search.tooltip';
|
||||
|
||||
exportLimitExceededKey = 'metadata-export-search.submit.error.limit-exceeded';
|
||||
|
||||
exportLimitExceededMsg = '';
|
||||
|
||||
shouldShowWarning$: Observable<boolean>;
|
||||
|
||||
constructor(private scriptDataService: ScriptDataService,
|
||||
private authorizationDataService: AuthorizationDataService,
|
||||
private notificationsService: NotificationsService,
|
||||
private translateService: TranslateService,
|
||||
private router: Router
|
||||
) {
|
||||
private router: Router,
|
||||
private configurationService: ConfigurationDataService) {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
@@ -55,6 +68,25 @@ export class SearchExportCsvComponent implements OnInit {
|
||||
map((canExecute: boolean) => canExecute),
|
||||
startWith(false),
|
||||
);
|
||||
this.shouldShowWarning$ = this.itemExceeds();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the export limit has been exceeded and updates the tooltip accordingly
|
||||
*/
|
||||
private itemExceeds(): Observable<boolean> {
|
||||
return this.configurationService.findByPropertyName('metadataexport.max.items').pipe(
|
||||
getFirstCompletedRemoteData(),
|
||||
map((response: RemoteData<ConfigurationProperty>) => {
|
||||
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] });
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,6 +1,7 @@
|
||||
<div class="d-flex justify-content-between">
|
||||
<h1 *ngIf="!disableHeader">{{ (configuration ? configuration + '.search.results.head' : 'search.results.head') | translate }}</h1>
|
||||
<ds-search-export-csv *ngIf="showCsvExport" [searchConfig]="searchConfig"></ds-search-export-csv>
|
||||
<ds-search-export-csv *ngIf="showCsvExport" [total]="searchResults?.payload?.totalElements"
|
||||
[searchConfig]="searchConfig"></ds-search-export-csv>
|
||||
</div>
|
||||
<div *ngIf="searchResults && searchResults?.hasSucceeded && !searchResults?.isLoading && searchResults?.payload?.page.length > 0" @fadeIn>
|
||||
<ds-viewable-collection
|
||||
|
@@ -5496,4 +5496,6 @@
|
||||
"live-region.ordering.dropped": "{{ itemName }}, dropped at position {{ index }} of {{ length }}.",
|
||||
|
||||
"dynamic-form-array.sortable-list.label": "Sortable list",
|
||||
|
||||
"metadata-export-search.submit.error.limit-exceeded": "Only the first {{limit}} items will be exported",
|
||||
}
|
||||
|
Reference in New Issue
Block a user