Skip to content

Commit b69b21a

Browse files
author
Jens Vannerum
committed
119612: UI warning that only first part of configured items will be exported
1 parent 76ae286 commit b69b21a

4 files changed

Lines changed: 52 additions & 4 deletions

File tree

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
1+
<ng-template #tipContent>
2+
<div class="tooltip-content">
3+
<p class="m-0">{{tooltipMsg | translate}}</p>
4+
</div>
5+
</ng-template>
6+
7+
<ng-template #tipContentWarning>
8+
<div class="tooltip-content">
9+
<p class="m-0">{{tooltipMsg | translate}}</p>
10+
<p class="m-0 text-warning">{{exportLimitExceededMsg}}</p>
11+
</div>
12+
</ng-template>
13+
114
<button *ngIf="shouldShowButton$ | async"
215
class="export-button btn btn-dark btn-sm"
3-
[ngbTooltip]="tooltipMsg | translate"
16+
[ngbTooltip]="(shouldShowWarning$ | async) ? tipContentWarning : tipContent"
417
(click)="export()"
518
[title]="tooltipMsg |translate" [attr.aria-label]="tooltipMsg |translate">
619
<i class="fas fa-file-export fa-fw"></i>
7-
</button>
20+
</button>

src/app/shared/search/search-export-csv/search-export-csv.component.ts

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ import {
2121
switchMap,
2222
} from 'rxjs/operators';
2323

24+
import { ConfigurationDataService } from '../../../core/data/configuration-data.service';
2425
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
2526
import { FeatureID } from '../../../core/data/feature-authorization/feature-id';
2627
import { ScriptDataService } from '../../../core/data/processes/script-data.service';
2728
import { RemoteData } from '../../../core/data/remote-data';
29+
import { ConfigurationProperty } from '../../../core/shared/configuration-property.model';
2830
import { getFirstCompletedRemoteData } from '../../../core/shared/operators';
2931
import { getProcessDetailRoute } from '../../../process-page/process-page-routing.paths';
3032
import { Process } from '../../../process-page/processes/process.model';
@@ -53,6 +55,11 @@ export class SearchExportCsvComponent implements OnInit {
5355
*/
5456
@Input() searchConfig: PaginatedSearchOptions;
5557

58+
/**
59+
* The total number of items in the search results which can be exported
60+
*/
61+
@Input() total: number;
62+
5663
/**
5764
* Observable used to determine whether the button should be shown
5865
*/
@@ -63,12 +70,18 @@ export class SearchExportCsvComponent implements OnInit {
6370
*/
6471
tooltipMsg = 'metadata-export-search.tooltip';
6572

73+
exportLimitExceededKey = 'metadata-export-search.submit.error.limit-exceeded';
74+
75+
exportLimitExceededMsg = '';
76+
77+
shouldShowWarning$: Observable<boolean>;
78+
6679
constructor(private scriptDataService: ScriptDataService,
6780
private authorizationDataService: AuthorizationDataService,
6881
private notificationsService: NotificationsService,
6982
private translateService: TranslateService,
7083
private router: Router,
71-
) {
84+
private configurationService: ConfigurationDataService) {
7285
}
7386

7487
ngOnInit(): void {
@@ -78,6 +91,25 @@ export class SearchExportCsvComponent implements OnInit {
7891
map((canExecute: boolean) => canExecute),
7992
startWith(false),
8093
);
94+
this.shouldShowWarning$ = this.itemExceeds();
95+
}
96+
97+
/**
98+
* Checks if the export limit has been exceeded and updates the tooltip accordingly
99+
*/
100+
private itemExceeds(): Observable<boolean> {
101+
return this.configurationService.findByPropertyName('metadataexport.max.items').pipe(
102+
getFirstCompletedRemoteData(),
103+
map((response: RemoteData<ConfigurationProperty>) => {
104+
const limit = Number(response.payload?.values?.[0]);
105+
if (response.hasSucceeded && limit < this.total) {
106+
this.exportLimitExceededMsg = this.translateService.instant(this.exportLimitExceededKey, { limit: response.payload?.values?.[0] });
107+
return true;
108+
} else {
109+
return false;
110+
}
111+
}),
112+
);
81113
}
82114

83115
/**

src/app/shared/search/search-results/search-results.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<div class="d-flex justify-content-between">
22
<h1 *ngIf="!disableHeader">{{ (configuration ? configuration + '.search.results.head' : 'search.results.head') | translate }}</h1>
3-
<ds-search-export-csv *ngIf="showCsvExport" [searchConfig]="searchConfig"></ds-search-export-csv>
3+
<ds-search-export-csv *ngIf="showCsvExport" [total]="searchResults?.payload?.totalElements"
4+
[searchConfig]="searchConfig"></ds-search-export-csv>
45
</div>
56
<div *ngIf="searchResults && searchResults?.hasSucceeded && !searchResults?.isLoading && searchResults?.payload?.page.length > 0" @fadeIn>
67
<ds-viewable-collection

src/assets/i18n/en.json5

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6763,4 +6763,6 @@
67636763
"register-page.registration.aria.label": "Enter your e-mail address",
67646764

67656765
"forgot-email.form.aria.label": "Enter your e-mail address",
6766+
6767+
"metadata-export-search.submit.error.limit-exceeded": "Only the first {{limit}} items will be exported",
67666768
}

0 commit comments

Comments
 (0)