disabled quick filters when there is no available option
This commit is contained in:
parent
35198bd006
commit
d3f031661a
@ -320,38 +320,41 @@ export class ConfigService {
|
||||
_recentlyModifiedChecker = (file: File) =>
|
||||
moment(file.lastUpdated).add(this._appConfigService.values.RECENT_PERIOD_IN_HOURS, 'hours').isAfter(moment());
|
||||
|
||||
private _quickFilters(entities: File[]): NestedFilter[] {
|
||||
let quickFilters: INestedFilter[] = [];
|
||||
if (entities.filter(this._recentlyModifiedChecker).length > 0) {
|
||||
const recentPeriod = this._appConfigService.values.RECENT_PERIOD_IN_HOURS;
|
||||
quickFilters = [
|
||||
{
|
||||
id: 'recent',
|
||||
label: this._translateService.instant('dossier-overview.quick-filters.recent', {
|
||||
hours: recentPeriod,
|
||||
}),
|
||||
required: true,
|
||||
checker: this._recentlyModifiedChecker,
|
||||
},
|
||||
];
|
||||
}
|
||||
_assignedToMeChecker = (file: File) => file.currentReviewer === this._userService.currentUser.id;
|
||||
|
||||
_unassignedChecker = (file: File) => file.isUnassigned;
|
||||
|
||||
_assignedToOthersChecker = (file: File) => !file.isUnassigned && file.currentReviewer !== this._userService.currentUser.id;
|
||||
|
||||
private _quickFilters(entities: File[]): NestedFilter[] {
|
||||
const recentPeriod = this._appConfigService.values.RECENT_PERIOD_IN_HOURS;
|
||||
return [
|
||||
...quickFilters,
|
||||
{
|
||||
id: 'recent',
|
||||
label: this._translateService.instant('dossier-overview.quick-filters.recent', {
|
||||
hours: recentPeriod,
|
||||
}),
|
||||
required: true,
|
||||
checker: this._recentlyModifiedChecker,
|
||||
disabled: entities.filter(this._recentlyModifiedChecker).length === 0,
|
||||
},
|
||||
{
|
||||
id: 'assigned-to-me',
|
||||
label: this._translateService.instant('dossier-overview.quick-filters.assigned-to-me'),
|
||||
checker: (file: File) => file.currentReviewer === this._userService.currentUser.id,
|
||||
checker: this._recentlyModifiedChecker,
|
||||
disabled: entities.filter(this._assignedToMeChecker).length === 0,
|
||||
},
|
||||
{
|
||||
id: 'unassigned',
|
||||
label: this._translateService.instant('dossier-overview.quick-filters.unassigned'),
|
||||
checker: (file: File) => file.isUnassigned,
|
||||
checker: this._unassignedChecker,
|
||||
disabled: entities.filter(this._unassignedChecker).length === 0,
|
||||
},
|
||||
{
|
||||
id: 'assigned-to-others',
|
||||
label: this._translateService.instant('dossier-overview.quick-filters.assigned-to-others'),
|
||||
checker: (file: File) => !file.isUnassigned && file.currentReviewer !== this._userService.currentUser.id,
|
||||
checker: this._assignedToOthersChecker,
|
||||
disabled: entities.filter(this._assignedToOthersChecker).length === 0,
|
||||
},
|
||||
].map(filter => new NestedFilter(filter));
|
||||
}
|
||||
|
||||
@ -36,28 +36,40 @@ export class ConfigService {
|
||||
return this._userService.currentUser;
|
||||
}
|
||||
|
||||
private get _quickFilters(): NestedFilter[] {
|
||||
_myDossiersChecker = (dw: Dossier) => dw.ownerId === this._currentUser.id;
|
||||
|
||||
_toApproveChecker = (dw: Dossier) => dw.approverIds.includes(this._currentUser.id);
|
||||
|
||||
_toReviewChecker = (dw: Dossier) => dw.memberIds.includes(this._currentUser.id);
|
||||
|
||||
_otherChecker = (dw: Dossier) => !dw.memberIds.includes(this._currentUser.id);
|
||||
|
||||
private _quickFilters(entities: Dossier[]): NestedFilter[] {
|
||||
const myDossiersLabel = this._translateService.instant('dossier-listing.quick-filters.my-dossiers');
|
||||
const filters = [
|
||||
{
|
||||
id: 'my-dossiers',
|
||||
label: myDossiersLabel,
|
||||
checker: (dw: Dossier) => dw.ownerId === this._currentUser.id,
|
||||
checker: this._myDossiersChecker,
|
||||
disabled: entities.filter(this._myDossiersChecker).length === 0,
|
||||
},
|
||||
{
|
||||
id: 'to-approve',
|
||||
label: this._translateService.instant('dossier-listing.quick-filters.to-approve'),
|
||||
checker: (dw: Dossier) => dw.approverIds.includes(this._currentUser.id),
|
||||
checker: this._toApproveChecker,
|
||||
disabled: entities.filter(this._toApproveChecker).length === 0,
|
||||
},
|
||||
{
|
||||
id: 'to-review',
|
||||
label: this._translateService.instant('dossier-listing.quick-filters.to-review'),
|
||||
checker: (dw: Dossier) => dw.memberIds.includes(this._currentUser.id),
|
||||
checker: this._toReviewChecker,
|
||||
disabled: entities.filter(this._toReviewChecker).length === 0,
|
||||
},
|
||||
{
|
||||
id: 'other',
|
||||
label: this._translateService.instant('dossier-listing.quick-filters.other'),
|
||||
checker: (dw: Dossier) => !dw.memberIds.includes(this._currentUser.id),
|
||||
checker: this._otherChecker,
|
||||
disabled: entities.filter(this._otherChecker).length === 0,
|
||||
},
|
||||
].map(filter => new NestedFilter(filter));
|
||||
|
||||
@ -177,10 +189,9 @@ export class ConfigService {
|
||||
checker: dossierTemplateChecker,
|
||||
});
|
||||
|
||||
const quickFilters = this._quickFilters;
|
||||
filterGroups.push({
|
||||
slug: 'quickFilters',
|
||||
filters: quickFilters,
|
||||
filters: this._quickFilters(entities),
|
||||
checker: (dw: Dossier, filter: NestedFilter) => filter.checked && filter.checker(dw),
|
||||
});
|
||||
|
||||
|
||||
@ -1 +1 @@
|
||||
Subproject commit aebdfd0f2eaaf6b4551c5c822ca9533a7f37fda2
|
||||
Subproject commit d67d556b684927bf9afe6bcd1eb6c231a6566d8d
|
||||
Loading…
x
Reference in New Issue
Block a user