add only active dossiers filter

This commit is contained in:
Dan Percic 2022-03-04 17:43:09 +02:00
parent 7a39ba96ca
commit 346baaf7ec
8 changed files with 27 additions and 38 deletions

View File

@ -5,6 +5,7 @@ import {
CircleButtonTypes,
ConfirmationDialogInput,
DefaultListingServices,
getLeftDateTime,
IListable,
IRouterPath,
ListingComponent,
@ -16,7 +17,6 @@ import {
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import * as moment from 'moment';
import { ConfigService } from '@services/config.service';
import { getLeftDateTime } from '@utils/functions';
import { firstValueFrom, Observable, of } from 'rxjs';
import { distinctUntilChanged, map } from 'rxjs/operators';
import { DossiersDialogService } from '../../../services/dossiers-dialog.service';

View File

@ -89,6 +89,8 @@ export class SearchScreenComponent extends ListingComponent<ISearchListItem> imp
checker: keyChecker('dossierId'),
};
this.filterService.addFilterGroups([dossierNameFilter]);
const onlyActiveLabel = this._translateService.instant('search-screen.filters.only-active');
this.filterService.addSingleFilter({ id: 'onlyActiveDossiers', label: onlyActiveLabel, checked: this._routeOnlyActive });
}
private get _routeDossierIds(): string[] {
@ -112,11 +114,12 @@ export class SearchScreenComponent extends ListingComponent<ISearchListItem> imp
}
private get _filtersChanged$(): Observable<[string[], boolean]> {
return this.filterService.filterGroups$.pipe(
map(groups => {
const onlyActiveDossiers$ = this.filterService.getSingleFilter('onlyActiveDossiers').pipe(map(f => !!f.checked));
const filterGroups$ = this.filterService.filterGroups$;
return combineLatest([filterGroups$, onlyActiveDossiers$]).pipe(
map(([groups, onlyActive]) => {
const dossierIds: string[] = groups[0].filters.filter(v => v.checked).map(v => v.id);
// TODO: Only active filter
return [dossierIds, this._routeOnlyActive];
return [dossierIds, onlyActive];
}),
startWith<[string[], boolean]>([this._routeDossierIds, this._routeOnlyActive]),
);

View File

@ -3,9 +3,9 @@ import * as moment from 'moment';
import { TranslateService } from '@ngx-translate/core';
import { DatePipe as BaseDatePipe } from '@angular/common';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { getLeftDateTime } from '@utils/functions';
import { getLeftDateTime } from '@iqser/common-ui';
const MONTH_NAMES = {
const MONTH_NAMES: Record<number, string> = {
0: _('months.jan'),
1: _('months.feb'),
2: _('months.mar'),
@ -29,16 +29,18 @@ export class DatePipe extends BaseDatePipe implements PipeTransform {
}
transform(value: null | undefined, format?: string, timezone?: string, locale?: string): null;
transform(value: Date | string | number | null | undefined, format?: string, timezone?: string, locale?: string): string | null;
transform(value: any, format?: string, timezone?: string, locale?: string): string {
if (format === 'timeFromNow') {
return this._getTimeFromNow(value);
}
if (format === 'sophisticatedDate') {
return this._getSophisticatedDate(value);
}
if (format === 'exactDate') {
return this._getExactDate(value);
transform(value: Date | string | number, format?: string, timezone?: string, locale?: string): string;
transform(value: Date | string | number | null | undefined, format?: string, timezone?: string, locale?: string): string | null {
if (typeof value === 'string') {
if (format === 'timeFromNow') {
return this._getTimeFromNow(value);
}
if (format === 'sophisticatedDate') {
return this._getSophisticatedDate(value);
}
if (format === 'exactDate') {
return this._getExactDate(value);
}
}
return super.transform(value, format, timezone, locale);
}

View File

@ -1,4 +1,3 @@
import * as moment from 'moment';
import { List } from '@iqser/common-ui';
import { filter } from 'rxjs/operators';
import { ActivationEnd } from '@angular/router';
@ -76,22 +75,6 @@ export function toNumber(str: string) {
}
}
const HOURS_IN_A_DAY = 24;
const MINUTES_IN_AN_HOUR = 60;
export function getLeftDateTime(ISOString: string) {
const date = moment(ISOString);
const now = new Date(Date.now());
const daysLeft = date.diff(now, 'days');
const hoursFromNow = date.diff(now, 'hours');
const hoursLeft = hoursFromNow - HOURS_IN_A_DAY * daysLeft;
const minutesFromNow = date.diff(now, 'minutes');
const minutesLeft = minutesFromNow - HOURS_IN_A_DAY * MINUTES_IN_AN_HOUR * daysLeft;
return { daysLeft, hoursLeft, minutesLeft };
}
export function removeBraces(str: any): string {
return str.replace(/[{}]/g, '');
}

View File

@ -1719,6 +1719,7 @@
},
"filters": {
"by-dossier": "Nach Dossier filtern",
"only-active": "",
"search-placeholder": "Dossiername..."
},
"missing": "Fehlt",

View File

@ -1754,6 +1754,7 @@
},
"filters": {
"by-dossier": "Filter by Dossier",
"only-active": "Active dossiers only",
"search-placeholder": "Dossier name..."
},
"missing": "Missing",

@ -1 +1 @@
Subproject commit 0157507f661ab216413ec0cf6f4a03128ecb5fce
Subproject commit c11f73ba9e202ae86e60a6e6eb1639a3a59d04a8

View File

@ -1,7 +1,6 @@
import { List } from '@iqser/common-ui';
import { getLeftDateTime, List } from '@iqser/common-ui';
import { DownloadFileType } from '../shared';
import { DossierStatus, IDossier } from '@red/domain';
import { getLeftDateTime } from '@utils/functions';
import { DossierStatus, IDossier } from '../dossiers';
export class TrashDossier implements IDossier {
readonly dossierId: string;