119612: UI warning that only first part of configured items will be exported

(cherry picked from commit b69b21af6c)
This commit is contained in:
Jens Vannerum
2025-01-20 16:45:36 +01:00
parent aabc0a199e
commit 93200d6b3c
4 changed files with 52 additions and 4 deletions

View File

@@ -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>

View File

@@ -21,10 +21,12 @@ import {
switchMap,
} from 'rxjs/operators';
import { ConfigurationDataService } from '../../../core/data/configuration-data.service';
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
import { FeatureID } from '../../../core/data/feature-authorization/feature-id';
import { ScriptDataService } from '../../../core/data/processes/script-data.service';
import { RemoteData } from '../../../core/data/remote-data';
import { ConfigurationProperty } from '../../../core/shared/configuration-property.model';
import { getFirstCompletedRemoteData } from '../../../core/shared/operators';
import { getProcessDetailRoute } from '../../../process-page/process-page-routing.paths';
import { Process } from '../../../process-page/processes/process.model';
@@ -53,6 +55,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
*/
@@ -63,12 +70,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 configurationService: ConfigurationDataService) {
}
ngOnInit(): void {
@@ -78,6 +91,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;
}
}),
);
}
/**

View File

@@ -12,7 +12,8 @@
<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

View File

@@ -6874,4 +6874,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",
}