mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +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,6 +1,19 @@
|
|||||||
|
<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"
|
<button *ngIf="shouldShowButton$ | async"
|
||||||
class="export-button btn btn-dark btn-sm"
|
class="export-button btn btn-dark btn-sm"
|
||||||
[ngbTooltip]="tooltipMsg | translate"
|
[ngbTooltip]="(shouldShowWarning$ | async) ? tipContentWarning : tipContent"
|
||||||
(click)="export()"
|
(click)="export()"
|
||||||
[title]="tooltipMsg |translate" [attr.aria-label]="tooltipMsg |translate">
|
[title]="tooltipMsg |translate" [attr.aria-label]="tooltipMsg |translate">
|
||||||
<i class="fas fa-file-export fa-fw"></i>
|
<i class="fas fa-file-export fa-fw"></i>
|
||||||
|
@@ -21,10 +21,12 @@ import {
|
|||||||
switchMap,
|
switchMap,
|
||||||
} from 'rxjs/operators';
|
} from 'rxjs/operators';
|
||||||
|
|
||||||
|
import { ConfigurationDataService } from '../../../core/data/configuration-data.service';
|
||||||
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
|
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
|
||||||
import { FeatureID } from '../../../core/data/feature-authorization/feature-id';
|
import { FeatureID } from '../../../core/data/feature-authorization/feature-id';
|
||||||
import { ScriptDataService } from '../../../core/data/processes/script-data.service';
|
import { ScriptDataService } from '../../../core/data/processes/script-data.service';
|
||||||
import { RemoteData } from '../../../core/data/remote-data';
|
import { RemoteData } from '../../../core/data/remote-data';
|
||||||
|
import { ConfigurationProperty } from '../../../core/shared/configuration-property.model';
|
||||||
import { getFirstCompletedRemoteData } from '../../../core/shared/operators';
|
import { getFirstCompletedRemoteData } from '../../../core/shared/operators';
|
||||||
import { getProcessDetailRoute } from '../../../process-page/process-page-routing.paths';
|
import { getProcessDetailRoute } from '../../../process-page/process-page-routing.paths';
|
||||||
import { Process } from '../../../process-page/processes/process.model';
|
import { Process } from '../../../process-page/processes/process.model';
|
||||||
@@ -53,6 +55,11 @@ export class SearchExportCsvComponent implements OnInit {
|
|||||||
*/
|
*/
|
||||||
@Input() searchConfig: PaginatedSearchOptions;
|
@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
|
* Observable used to determine whether the button should be shown
|
||||||
*/
|
*/
|
||||||
@@ -63,12 +70,18 @@ export class SearchExportCsvComponent implements OnInit {
|
|||||||
*/
|
*/
|
||||||
tooltipMsg = 'metadata-export-search.tooltip';
|
tooltipMsg = 'metadata-export-search.tooltip';
|
||||||
|
|
||||||
|
exportLimitExceededKey = 'metadata-export-search.submit.error.limit-exceeded';
|
||||||
|
|
||||||
|
exportLimitExceededMsg = '';
|
||||||
|
|
||||||
|
shouldShowWarning$: Observable<boolean>;
|
||||||
|
|
||||||
constructor(private scriptDataService: ScriptDataService,
|
constructor(private scriptDataService: ScriptDataService,
|
||||||
private authorizationDataService: AuthorizationDataService,
|
private authorizationDataService: AuthorizationDataService,
|
||||||
private notificationsService: NotificationsService,
|
private notificationsService: NotificationsService,
|
||||||
private translateService: TranslateService,
|
private translateService: TranslateService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
) {
|
private configurationService: ConfigurationDataService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
@@ -78,6 +91,25 @@ export class SearchExportCsvComponent implements OnInit {
|
|||||||
map((canExecute: boolean) => canExecute),
|
map((canExecute: boolean) => canExecute),
|
||||||
startWith(false),
|
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;
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -12,7 +12,8 @@
|
|||||||
|
|
||||||
<div class="d-flex justify-content-between">
|
<div class="d-flex justify-content-between">
|
||||||
<h1 *ngIf="!disableHeader">{{ (configuration ? configuration + '.search.results.head' : 'search.results.head') | translate }}</h1>
|
<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>
|
||||||
<div *ngIf="searchResults && searchResults?.hasSucceeded && !searchResults?.isLoading && searchResults?.payload?.page.length > 0" @fadeIn>
|
<div *ngIf="searchResults && searchResults?.hasSucceeded && !searchResults?.isLoading && searchResults?.payload?.page.length > 0" @fadeIn>
|
||||||
<ds-viewable-collection
|
<ds-viewable-collection
|
||||||
|
@@ -6874,4 +6874,6 @@
|
|||||||
"live-region.ordering.dropped": "{{ itemName }}, dropped at position {{ index }} of {{ length }}.",
|
"live-region.ordering.dropped": "{{ itemName }}, dropped at position {{ index }} of {{ length }}.",
|
||||||
|
|
||||||
"dynamic-form-array.sortable-list.label": "Sortable list",
|
"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