fix listing filters

This commit is contained in:
amentis 2023-11-30 17:28:05 +02:00
parent 5965acc4aa
commit 63e5cde313
21 changed files with 182 additions and 50 deletions

View File

@ -1,12 +1,14 @@
import { Lookup } from "@common/model/lookup"; import { Lookup } from "@common/model/lookup";
import { Guid } from "@common/types/guid"; import { Guid } from "@common/types/guid";
import { IsActive } from "../common/enum/is-active.enum"; import { IsActive } from "../common/enum/is-active.enum";
import { DescriptionTemplateTypeStatus } from "../common/enum/description-template-type-status";
export class DescriptionTemplateTypeLookup extends Lookup implements DescriptionTemplateTypeFilter { export class DescriptionTemplateTypeLookup extends Lookup implements DescriptionTemplateTypeFilter {
ids: Guid[]; ids: Guid[];
excludedIds: Guid[]; excludedIds: Guid[];
like: string; like: string;
isActive: IsActive[]; isActive: IsActive[];
statuses: DescriptionTemplateTypeStatus[];
constructor() { constructor() {
super(); super();
@ -18,4 +20,5 @@ export interface DescriptionTemplateTypeFilter {
excludedIds: Guid[]; excludedIds: Guid[];
like: string; like: string;
isActive: IsActive[]; isActive: IsActive[];
statuses: DescriptionTemplateTypeStatus[];
} }

View File

@ -10,7 +10,7 @@ export class ReferenceLookup extends Lookup implements ReferenceFilter {
like: string; like: string;
isActive: IsActive[]; isActive: IsActive[];
sourceTypes: ReferenceSourceType[]; sourceTypes: ReferenceSourceType[];
referenceTypes: ReferenceType[]; types: ReferenceType[];
constructor() { constructor() {
super(); super();
@ -23,5 +23,5 @@ export interface ReferenceFilter {
like: string; like: string;
isActive: IsActive[]; isActive: IsActive[];
sourceTypes: ReferenceSourceType[]; sourceTypes: ReferenceSourceType[];
referenceTypes: ReferenceType[]; types: ReferenceType[];
} }

View File

@ -2,7 +2,6 @@ import { Injectable } from '@angular/core';
import { IsActive } from '@app/core/common/enum/is-active.enum'; import { IsActive } from '@app/core/common/enum/is-active.enum';
import { DescriptionTemplateType, DescriptionTemplateTypePersist } from '@app/core/model/description-template-type/description-template-type'; import { DescriptionTemplateType, DescriptionTemplateTypePersist } from '@app/core/model/description-template-type/description-template-type';
import { DescriptionTemplateTypeLookup } from '@app/core/query/description-template-type.lookup'; import { DescriptionTemplateTypeLookup } from '@app/core/query/description-template-type.lookup';
import { DmpBlueprintLookup } from '@app/core/query/dmp-blueprint.lookup';
import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration'; import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration';
import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration'; import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration';
import { QueryResult } from '@common/model/query-result'; import { QueryResult } from '@common/model/query-result';
@ -80,8 +79,8 @@ export class DescriptionTemplateTypeService {
valueAssign: (item: DescriptionTemplateType) => item.id, valueAssign: (item: DescriptionTemplateType) => item.id,
}; };
private buildAutocompleteLookup(like?: string, excludedIds?: Guid[], ids?: Guid[]): DmpBlueprintLookup { private buildAutocompleteLookup(like?: string, excludedIds?: Guid[], ids?: Guid[]): DescriptionTemplateTypeLookup {
const lookup: DmpBlueprintLookup = new DmpBlueprintLookup(); const lookup: DescriptionTemplateTypeLookup = new DescriptionTemplateTypeLookup();
lookup.page = { size: 100, offset: 0 }; lookup.page = { size: 100, offset: 0 };
if (excludedIds && excludedIds.length > 0) { lookup.excludedIds = excludedIds; } if (excludedIds && excludedIds.length > 0) { lookup.excludedIds = excludedIds; }
if (ids && ids.length > 0) { lookup.ids = ids; } if (ids && ids.length > 0) { lookup.ids = ids; }

View File

@ -71,29 +71,29 @@ export class ReferenceService {
// //
// Autocomplete Commons // Autocomplete Commons
// //
public getSingleAutocompleteConfiguration(referenceTypes?: ReferenceType[], sourceTypes?: ReferenceSourceType[]): SingleAutoCompleteConfiguration { public getSingleAutocompleteConfiguration(types?: ReferenceType[], sourceTypes?: ReferenceSourceType[]): SingleAutoCompleteConfiguration {
return { return {
initialItems: (data?: any) => this.query(this.buildAutocompleteLookup(referenceTypes, sourceTypes)).pipe(map(x => x.items)), initialItems: (data?: any) => this.query(this.buildAutocompleteLookup(types, sourceTypes)).pipe(map(x => x.items)),
filterFn: (searchQuery: string, data?: any) => this.query(this.buildAutocompleteLookup(referenceTypes, sourceTypes, searchQuery)).pipe(map(x => x.items)), filterFn: (searchQuery: string, data?: any) => this.query(this.buildAutocompleteLookup(types, sourceTypes, searchQuery)).pipe(map(x => x.items)),
getSelectedItem: (selectedItem: any) => this.query(this.buildAutocompleteLookup(referenceTypes, sourceTypes, null, null, [selectedItem])).pipe(map(x => x.items[0])), getSelectedItem: (selectedItem: any) => this.query(this.buildAutocompleteLookup(types, sourceTypes, null, null, [selectedItem])).pipe(map(x => x.items[0])),
displayFn: (item: Reference) => item.label, displayFn: (item: Reference) => item.label,
titleFn: (item: Reference) => item.label, titleFn: (item: Reference) => item.label,
valueAssign: (item: Reference) => item.id, valueAssign: (item: Reference) => item.id,
}; };
}; };
public getMultipleAutoCompleteConfiguration(referenceTypes?: ReferenceType[], sourceTypes?: ReferenceSourceType[]): MultipleAutoCompleteConfiguration { public getMultipleAutoCompleteConfiguration(types?: ReferenceType[], sourceTypes?: ReferenceSourceType[]): MultipleAutoCompleteConfiguration {
return { return {
initialItems: (excludedItems: any[], data?: any) => this.query(this.buildAutocompleteLookup(referenceTypes, sourceTypes, null, excludedItems ? excludedItems : null)).pipe(map(x => x.items)), initialItems: (excludedItems: any[], data?: any) => this.query(this.buildAutocompleteLookup(types, sourceTypes, null, excludedItems ? excludedItems : null)).pipe(map(x => x.items)),
filterFn: (searchQuery: string, excludedItems: any[]) => this.query(this.buildAutocompleteLookup(referenceTypes, sourceTypes, searchQuery, excludedItems)).pipe(map(x => x.items)), filterFn: (searchQuery: string, excludedItems: any[]) => this.query(this.buildAutocompleteLookup(types, sourceTypes, searchQuery, excludedItems)).pipe(map(x => x.items)),
getSelectedItems: (selectedItems: any[]) => this.query(this.buildAutocompleteLookup(referenceTypes, sourceTypes, null, null, selectedItems)).pipe(map(x => x.items)), getSelectedItems: (selectedItems: any[]) => this.query(this.buildAutocompleteLookup(types, sourceTypes, null, null, selectedItems)).pipe(map(x => x.items)),
displayFn: (item: Reference) => item.label, displayFn: (item: Reference) => item.label,
titleFn: (item: Reference) => item.label, titleFn: (item: Reference) => item.label,
valueAssign: (item: Reference) => item.id, valueAssign: (item: Reference) => item.id,
}; };
} }
private buildAutocompleteLookup(referenceTypes?: ReferenceType[], sourceTypes?: ReferenceSourceType[], like?: string, excludedIds?: Guid[], ids?: Guid[]): ReferenceLookup { private buildAutocompleteLookup(types?: ReferenceType[], sourceTypes?: ReferenceSourceType[], like?: string, excludedIds?: Guid[], ids?: Guid[]): ReferenceLookup {
const lookup: ReferenceLookup = new ReferenceLookup(); const lookup: ReferenceLookup = new ReferenceLookup();
lookup.page = { size: 100, offset: 0 }; lookup.page = { size: 100, offset: 0 };
if (excludedIds && excludedIds.length > 0) { lookup.excludedIds = excludedIds; } if (excludedIds && excludedIds.length > 0) { lookup.excludedIds = excludedIds; }
@ -105,7 +105,7 @@ export class ReferenceService {
nameof<Reference>(x => x.label) nameof<Reference>(x => x.label)
] ]
}; };
if (referenceTypes && referenceTypes.length > 0) { lookup.referenceTypes = referenceTypes; } if (types && types.length > 0) { lookup.types = types; }
if (sourceTypes && sourceTypes.length > 0) { lookup.sourceTypes = sourceTypes; } if (sourceTypes && sourceTypes.length > 0) { lookup.sourceTypes = sourceTypes; }
lookup.order = { items: [nameof<Reference>(x => x.label)] }; lookup.order = { items: [nameof<Reference>(x => x.label)] };
if (like) { lookup.like = this.filterService.transformLike(like); } if (like) { lookup.like = this.filterService.transformLike(like); }

View File

@ -27,6 +27,7 @@ import { ImportDescriptionTemplateDialogComponent } from './import-description-t
import { DescriptionTemplateService } from '@app/core/services/description-template/description-template.service'; import { DescriptionTemplateService } from '@app/core/services/description-template/description-template.service';
import { DescriptionTemplateStatus } from '@app/core/common/enum/description-template-status'; import { DescriptionTemplateStatus } from '@app/core/common/enum/description-template-status';
import { DescriptionTemplateLookup } from '@app/core/query/description-template.lookup'; import { DescriptionTemplateLookup } from '@app/core/query/description-template.lookup';
import { IsActiveTypePipe } from '@common/formatting/pipes/is-active-type.pipe';
@Component({ @Component({
@ -127,6 +128,12 @@ export class DescriptionTemplateListingComponent extends BaseListingComponent<De
languageName: 'DESCRIPTION-TEMPLATE-LISTING.FIELDS.UPDATED-AT', languageName: 'DESCRIPTION-TEMPLATE-LISTING.FIELDS.UPDATED-AT',
pipe: this.pipeService.getPipe<DataTableDateTimeFormatPipe>(DataTableDateTimeFormatPipe).withFormat('short') pipe: this.pipeService.getPipe<DataTableDateTimeFormatPipe>(DataTableDateTimeFormatPipe).withFormat('short')
}, },
{
prop: nameof<DescriptionTemplate>(x => x.isActive),
sortable: true,
languageName: 'DESCRIPTION-TEMPLATE-LISTING.FIELDS.IS-ACTIVE',
pipe: this.pipeService.getPipe<IsActiveTypePipe>(IsActiveTypePipe)
},
{ {
alwaysShown: true, alwaysShown: true,
cellTemplate: this.actions, cellTemplate: this.actions,

View File

@ -20,6 +20,14 @@
{{'DESCRIPTION-TEMPLATE-LISTING.FILTER.IS-ACTIVE' | translate}} {{'DESCRIPTION-TEMPLATE-LISTING.FILTER.IS-ACTIVE' | translate}}
</mat-slide-toggle> </mat-slide-toggle>
<div>
<mat-label>{{'DESCRIPTION-TEMPLATE-LISTING.FILTER.STATUS' | translate}}
<mat-select multiple [(ngModel)]="internalFilters.statuses">
<mat-option *ngFor="let descriptionTemplateStatus of descriptionTemplateStatusEnumValues" [value]="descriptionTemplateStatus">{{enumUtils.toDescriptionTemplateTypeStatusString(descriptionTemplateStatus)}}</mat-option>
</mat-select>
</mat-label>
</div>
<div class="d-flex justify-content-end align-items-center mt-4 gap-1-rem"> <div class="d-flex justify-content-end align-items-center mt-4 gap-1-rem">
<button mat-stroked-button color="primary" (click)="filterMenuTrigger?.closeMenu()"> <button mat-stroked-button color="primary" (click)="filterMenuTrigger?.closeMenu()">
{{'DESCRIPTION-TEMPLATE-LISTING.FILTER.CANCEL' | translate}} {{'DESCRIPTION-TEMPLATE-LISTING.FILTER.CANCEL' | translate}}

View File

@ -1,4 +1,5 @@
import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core'; import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core';
import { DescriptionTemplateStatus } from '@app/core/common/enum/description-template-status';
import { IsActive } from '@app/core/common/enum/is-active.enum'; import { IsActive } from '@app/core/common/enum/is-active.enum';
import { DescriptionTemplateFilter } from '@app/core/query/description-template.lookup'; import { DescriptionTemplateFilter } from '@app/core/query/description-template.lookup';
import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
@ -16,6 +17,8 @@ export class DescriptionTemplateListingFiltersComponent extends BaseComponent im
@Input() readonly filter: DescriptionTemplateFilter; @Input() readonly filter: DescriptionTemplateFilter;
@Output() filterChange = new EventEmitter<DescriptionTemplateFilter>(); @Output() filterChange = new EventEmitter<DescriptionTemplateFilter>();
descriptionTemplateStatusEnumValues = this.enumUtils.getEnumValues<DescriptionTemplateStatus>(DescriptionTemplateStatus);
// * State // * State
internalFilters: DescriptionTemplateListingFilters = this._getEmptyFilters(); internalFilters: DescriptionTemplateListingFilters = this._getEmptyFilters();
@ -46,12 +49,12 @@ export class DescriptionTemplateListingFiltersComponent extends BaseComponent im
} }
protected applyFilters(): void { protected applyFilters(): void {
const { isActive, like, typeIds } = this.internalFilters ?? {} const { isActive, like, statuses } = this.internalFilters ?? {}
this.filterChange.emit({ this.filterChange.emit({
...this.filter, ...this.filter,
like, like,
isActive: isActive ? [IsActive.Active] : [IsActive.Inactive], isActive: isActive ? [IsActive.Active] : [IsActive.Inactive],
typeIds statuses
}) })
} }
@ -61,12 +64,12 @@ export class DescriptionTemplateListingFiltersComponent extends BaseComponent im
return this._getEmptyFilters(); return this._getEmptyFilters();
} }
let { excludedIds, ids, isActive, like, typeIds } = inputFilter; let { excludedIds, ids, isActive, like, statuses } = inputFilter;
return { return {
isActive: (isActive ?? [])?.includes(IsActive.Active) || !isActive?.length, isActive: (isActive ?? [])?.includes(IsActive.Active) || !isActive?.length,
like: like, like: like,
typeIds: typeIds statuses: statuses
} }
} }
@ -75,7 +78,7 @@ export class DescriptionTemplateListingFiltersComponent extends BaseComponent im
return { return {
isActive: true, isActive: true,
like: null, like: null,
typeIds: null, statuses: null,
} }
} }
@ -95,5 +98,5 @@ export class DescriptionTemplateListingFiltersComponent extends BaseComponent im
interface DescriptionTemplateListingFilters { interface DescriptionTemplateListingFilters {
isActive: boolean; isActive: boolean;
like: string; like: string;
typeIds: Guid[]; statuses: DescriptionTemplateStatus[];
} }

View File

@ -13,6 +13,7 @@ import { QueryParamsService } from '@app/core/services/utilities/query-params.se
import { BaseListingComponent } from '@common/base/base-listing-component'; import { BaseListingComponent } from '@common/base/base-listing-component';
import { PipeService } from '@common/formatting/pipe.service'; import { PipeService } from '@common/formatting/pipe.service';
import { DataTableDateTimeFormatPipe } from '@common/formatting/pipes/date-time-format.pipe'; import { DataTableDateTimeFormatPipe } from '@common/formatting/pipes/date-time-format.pipe';
import { IsActiveTypePipe } from '@common/formatting/pipes/is-active-type.pipe';
import { QueryResult } from '@common/model/query-result'; import { QueryResult } from '@common/model/query-result';
import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component'; import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component';
import { HttpErrorHandlingService } from '@common/modules/errors/error-handling/http-error-handling.service'; import { HttpErrorHandlingService } from '@common/modules/errors/error-handling/http-error-handling.service';
@ -110,6 +111,12 @@ export class DescriptionTemplateTypeListingComponent extends BaseListingComponen
languageName: 'DESCRIPTION-TEMPLATE-TYPE-LISTING.FIELDS.UPDATED-AT', languageName: 'DESCRIPTION-TEMPLATE-TYPE-LISTING.FIELDS.UPDATED-AT',
pipe: this.pipeService.getPipe<DataTableDateTimeFormatPipe>(DataTableDateTimeFormatPipe).withFormat('short') pipe: this.pipeService.getPipe<DataTableDateTimeFormatPipe>(DataTableDateTimeFormatPipe).withFormat('short')
}, },
{
prop: nameof<DescriptionTemplateType>(x => x.isActive),
sortable: true,
languageName: 'DESCRIPTION-TEMPLATE-TYPE-LISTING.FIELDS.IS-ACTIVE',
pipe: this.pipeService.getPipe<IsActiveTypePipe>(IsActiveTypePipe)
},
{ {
alwaysShown: true, alwaysShown: true,
cellTemplate: this.actions, cellTemplate: this.actions,

View File

@ -20,6 +20,14 @@
{{'DESCRIPTION-TEMPLATE-TYPE-LISTING.FILTER.IS-ACTIVE' | translate}} {{'DESCRIPTION-TEMPLATE-TYPE-LISTING.FILTER.IS-ACTIVE' | translate}}
</mat-slide-toggle> </mat-slide-toggle>
<div>
<mat-label>{{'DESCRIPTION-TEMPLATE-TYPE-LISTING.FILTER.STATUS' | translate}}
<mat-select multiple [(ngModel)]="internalFilters.statuses">
<mat-option *ngFor="let descriptionTemplateTypeStatus of descriptionTemplateTypeStatusEnumValues" [value]="descriptionTemplateTypeStatus">{{enumUtils.toDescriptionTemplateTypeStatusString(descriptionTemplateTypeStatus)}}</mat-option>
</mat-select>
</mat-label>
</div>
<div class="d-flex justify-content-end align-items-center mt-4 gap-1-rem"> <div class="d-flex justify-content-end align-items-center mt-4 gap-1-rem">
<button mat-stroked-button color="primary" (click)="filterMenuTrigger?.closeMenu()"> <button mat-stroked-button color="primary" (click)="filterMenuTrigger?.closeMenu()">
{{'DESCRIPTION-TEMPLATE-TYPE-LISTING.FILTER.CANCEL' | translate}} {{'DESCRIPTION-TEMPLATE-TYPE-LISTING.FILTER.CANCEL' | translate}}

View File

@ -1,4 +1,5 @@
import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core'; import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core';
import { DescriptionTemplateTypeStatus } from '@app/core/common/enum/description-template-type-status';
import { IsActive } from '@app/core/common/enum/is-active.enum'; import { IsActive } from '@app/core/common/enum/is-active.enum';
import { DescriptionTemplateTypeFilter } from '@app/core/query/description-template-type.lookup'; import { DescriptionTemplateTypeFilter } from '@app/core/query/description-template-type.lookup';
import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
@ -15,6 +16,8 @@ export class DescriptionTemplateTypeListingFiltersComponent extends BaseComponen
@Input() readonly filter: DescriptionTemplateTypeFilter; @Input() readonly filter: DescriptionTemplateTypeFilter;
@Output() filterChange = new EventEmitter<DescriptionTemplateTypeFilter>(); @Output() filterChange = new EventEmitter<DescriptionTemplateTypeFilter>();
descriptionTemplateTypeStatusEnumValues = this.enumUtils.getEnumValues<DescriptionTemplateTypeStatus>(DescriptionTemplateTypeStatus);
// * State // * State
internalFilters: DescriptionTemplateTypeListingFilters = this._getEmptyFilters(); internalFilters: DescriptionTemplateTypeListingFilters = this._getEmptyFilters();
@ -45,11 +48,12 @@ export class DescriptionTemplateTypeListingFiltersComponent extends BaseComponen
} }
protected applyFilters(): void { protected applyFilters(): void {
const { isActive, like } = this.internalFilters ?? {} const { isActive, like, statuses } = this.internalFilters ?? {}
this.filterChange.emit({ this.filterChange.emit({
...this.filter, ...this.filter,
like, like,
isActive: isActive ? [IsActive.Active] : [IsActive.Inactive] isActive: isActive ? [IsActive.Active] : [IsActive.Inactive],
statuses
}) })
} }
@ -59,11 +63,12 @@ export class DescriptionTemplateTypeListingFiltersComponent extends BaseComponen
return this._getEmptyFilters(); return this._getEmptyFilters();
} }
let { excludedIds, ids, isActive, like } = inputFilter; let { excludedIds, ids, isActive, like, statuses } = inputFilter;
return { return {
isActive: (isActive ?? [])?.includes(IsActive.Active) || !isActive?.length, isActive: (isActive ?? [])?.includes(IsActive.Active) || !isActive?.length,
like: like like: like,
statuses: statuses
} }
} }
@ -72,6 +77,7 @@ export class DescriptionTemplateTypeListingFiltersComponent extends BaseComponen
return { return {
isActive: true, isActive: true,
like: null, like: null,
statuses: null,
} }
} }
@ -91,4 +97,5 @@ export class DescriptionTemplateTypeListingFiltersComponent extends BaseComponen
interface DescriptionTemplateTypeListingFilters { interface DescriptionTemplateTypeListingFilters {
isActive: boolean; isActive: boolean;
like: string; like: string;
statuses: DescriptionTemplateTypeStatus[];
} }

View File

@ -20,9 +20,13 @@
{{'DMP-BLUEPRINT-LISTING.FILTER.IS-ACTIVE' | translate}} {{'DMP-BLUEPRINT-LISTING.FILTER.IS-ACTIVE' | translate}}
</mat-slide-toggle> </mat-slide-toggle>
<mat-select multiple [(ngModel)]="internalFilters.statuses"> <div>
<mat-option *ngFor="let blueprintStatus of dmpBlueprintStatusEnumValues" [value]="blueprintStatus">{{enumUtils.toDmpBlueprintStatusString(blueprintStatus)}}</mat-option> <mat-label>{{'DMP-BLUEPRINT-LISTING.FILTER.STATUS' | translate}}
</mat-select> <mat-select multiple [(ngModel)]="internalFilters.statuses">
<mat-option *ngFor="let blueprintStatus of dmpBlueprintStatusEnumValues" [value]="blueprintStatus">{{enumUtils.toDmpBlueprintStatusString(blueprintStatus)}}</mat-option>
</mat-select>
</mat-label>
</div>
<div class="d-flex justify-content-end align-items-center mt-4 gap-1-rem"> <div class="d-flex justify-content-end align-items-center mt-4 gap-1-rem">
<button mat-stroked-button color="primary" (click)="filterMenuTrigger?.closeMenu()"> <button mat-stroked-button color="primary" (click)="filterMenuTrigger?.closeMenu()">

View File

@ -12,6 +12,7 @@ import { QueryParamsService } from '@app/core/services/utilities/query-params.se
import { BaseListingComponent } from '@common/base/base-listing-component'; import { BaseListingComponent } from '@common/base/base-listing-component';
import { PipeService } from '@common/formatting/pipe.service'; import { PipeService } from '@common/formatting/pipe.service';
import { DataTableDateTimeFormatPipe } from '@common/formatting/pipes/date-time-format.pipe'; import { DataTableDateTimeFormatPipe } from '@common/formatting/pipes/date-time-format.pipe';
import { IsActiveTypePipe } from '@common/formatting/pipes/is-active-type.pipe';
import { QueryResult } from '@common/model/query-result'; import { QueryResult } from '@common/model/query-result';
import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component'; import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component';
import { HttpErrorHandlingService } from '@common/modules/errors/error-handling/http-error-handling.service'; import { HttpErrorHandlingService } from '@common/modules/errors/error-handling/http-error-handling.service';
@ -102,6 +103,12 @@ export class LanguageListingComponent extends BaseListingComponent<Language, Lan
languageName: 'LANGUAGE-LISTING.FIELDS.UPDATED-AT', languageName: 'LANGUAGE-LISTING.FIELDS.UPDATED-AT',
pipe: this.pipeService.getPipe<DataTableDateTimeFormatPipe>(DataTableDateTimeFormatPipe).withFormat('short') pipe: this.pipeService.getPipe<DataTableDateTimeFormatPipe>(DataTableDateTimeFormatPipe).withFormat('short')
}, },
{
prop: nameof<Language>(x => x.isActive),
sortable: true,
languageName: 'LANGUAGE-LISTING.FIELDS.IS-ACTIVE',
pipe: this.pipeService.getPipe<IsActiveTypePipe>(IsActiveTypePipe)
},
{ {
alwaysShown: true, alwaysShown: true,
cellTemplate: this.actions, cellTemplate: this.actions,

View File

@ -21,6 +21,7 @@ import { TranslateService } from '@ngx-translate/core';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { takeUntil } from 'rxjs/operators'; import { takeUntil } from 'rxjs/operators';
import { nameof } from 'ts-simple-nameof'; import { nameof } from 'ts-simple-nameof';
import { IsActiveTypePipe } from '@common/formatting/pipes/is-active-type.pipe';
@Component({ @Component({
templateUrl: './reference-type-listing.component.html', templateUrl: './reference-type-listing.component.html',
@ -95,7 +96,6 @@ export class ReferenceTypeListingComponent extends BaseListingComponent<Referenc
prop: nameof<ReferenceType>(x => x.code), prop: nameof<ReferenceType>(x => x.code),
sortable: true, sortable: true,
languageName: 'REFERENCE-TYPE-LISTING.FIELDS.CODE', languageName: 'REFERENCE-TYPE-LISTING.FIELDS.CODE',
//cellTemplate: this.ReferenceTypeStatus
}, },
{ {
prop: nameof<ReferenceType>(x => x.createdAt), prop: nameof<ReferenceType>(x => x.createdAt),
@ -109,6 +109,12 @@ export class ReferenceTypeListingComponent extends BaseListingComponent<Referenc
languageName: 'REFERENCE-TYPE-LISTING.FIELDS.UPDATED-AT', languageName: 'REFERENCE-TYPE-LISTING.FIELDS.UPDATED-AT',
pipe: this.pipeService.getPipe<DataTableDateTimeFormatPipe>(DataTableDateTimeFormatPipe).withFormat('short') pipe: this.pipeService.getPipe<DataTableDateTimeFormatPipe>(DataTableDateTimeFormatPipe).withFormat('short')
}, },
{
prop: nameof<ReferenceType>(x => x.isActive),
sortable: true,
languageName: 'REFERENCE-TYPE-LISTING.FIELDS.IS-ACTIVE',
pipe: this.pipeService.getPipe<IsActiveTypePipe>(IsActiveTypePipe)
},
{ {
alwaysShown: true, alwaysShown: true,
cellTemplate: this.actions, cellTemplate: this.actions,

View File

@ -20,6 +20,14 @@
{{'REFERENCE-LISTING.FILTER.IS-ACTIVE' | translate}} {{'REFERENCE-LISTING.FILTER.IS-ACTIVE' | translate}}
</mat-slide-toggle> </mat-slide-toggle>
<div>
<mat-label>{{'REFERENCE-LISTING.FILTER.TYPE' | translate}}
<mat-select multiple [(ngModel)]="internalFilters.types">
<mat-option *ngFor="let referenceType of referenceTypeEnumValues" [value]="referenceType">{{enumUtils.toReferenceTypeString(referenceType)}}</mat-option>
</mat-select>
</mat-label>
</div>
<div class="d-flex justify-content-end align-items-center mt-4 gap-1-rem"> <div class="d-flex justify-content-end align-items-center mt-4 gap-1-rem">
<button mat-stroked-button color="primary" (click)="filterMenuTrigger?.closeMenu()"> <button mat-stroked-button color="primary" (click)="filterMenuTrigger?.closeMenu()">
{{'REFERENCE-LISTING.FILTER.CANCEL' | translate}} {{'REFERENCE-LISTING.FILTER.CANCEL' | translate}}

View File

@ -1,6 +1,7 @@
import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core'; import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core';
import { IsActive } from '@app/core/common/enum/is-active.enum'; import { IsActive } from '@app/core/common/enum/is-active.enum';
import { TenantFilter } from '@app/core/query/tenant.lookup'; import { ReferenceType } from '@app/core/common/enum/reference-type';
import { ReferenceFilter } from '@app/core/query/reference.lookup';
import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
import { BaseComponent } from '@common/base/base.component'; import { BaseComponent } from '@common/base/base.component';
import { nameof } from 'ts-simple-nameof'; import { nameof } from 'ts-simple-nameof';
@ -12,8 +13,10 @@ import { nameof } from 'ts-simple-nameof';
}) })
export class ReferenceListingFiltersComponent extends BaseComponent implements OnInit, OnChanges { export class ReferenceListingFiltersComponent extends BaseComponent implements OnInit, OnChanges {
@Input() readonly filter: TenantFilter; @Input() readonly filter: ReferenceFilter;
@Output() filterChange = new EventEmitter<TenantFilter>(); @Output() filterChange = new EventEmitter<ReferenceFilter>();
referenceTypeEnumValues = this.enumUtils.getEnumValues<ReferenceType>(ReferenceType);
// * State // * State
internalFilters: ReferenceListingFilters = this._getEmptyFilters(); internalFilters: ReferenceListingFilters = this._getEmptyFilters();
@ -27,7 +30,7 @@ export class ReferenceListingFiltersComponent extends BaseComponent implements O
} }
ngOnChanges(changes: SimpleChanges): void { ngOnChanges(changes: SimpleChanges): void {
const filterChange = changes[nameof<ReferenceListingFiltersComponent>(x => x.filter)]?.currentValue as TenantFilter; const filterChange = changes[nameof<ReferenceListingFiltersComponent>(x => x.filter)]?.currentValue as ReferenceFilter;
if (filterChange) { if (filterChange) {
this.updateFilters() this.updateFilters()
} }
@ -45,25 +48,27 @@ export class ReferenceListingFiltersComponent extends BaseComponent implements O
} }
protected applyFilters(): void { protected applyFilters(): void {
const { isActive, like } = this.internalFilters ?? {} const { isActive, like, types } = this.internalFilters ?? {}
this.filterChange.emit({ this.filterChange.emit({
...this.filter, ...this.filter,
like, like,
isActive: isActive ? [IsActive.Active] : [IsActive.Inactive] isActive: isActive ? [IsActive.Active] : [IsActive.Inactive],
types
}) })
} }
private _parseToInternalFilters(inputFilter: TenantFilter): ReferenceListingFilters { private _parseToInternalFilters(inputFilter: ReferenceFilter): ReferenceListingFilters {
if (!inputFilter) { if (!inputFilter) {
return this._getEmptyFilters(); return this._getEmptyFilters();
} }
let { excludedIds, ids, isActive, like } = inputFilter; let { excludedIds, ids, isActive, like, types } = inputFilter;
return { return {
isActive: (isActive ?? [])?.includes(IsActive.Active) || !isActive?.length, isActive: (isActive ?? [])?.includes(IsActive.Active) || !isActive?.length,
like: like like: like,
types: types
} }
} }
@ -72,6 +77,7 @@ export class ReferenceListingFiltersComponent extends BaseComponent implements O
return { return {
isActive: true, isActive: true,
like: null, like: null,
types: null
} }
} }
@ -91,4 +97,5 @@ export class ReferenceListingFiltersComponent extends BaseComponent implements O
interface ReferenceListingFilters { interface ReferenceListingFilters {
isActive: boolean; isActive: boolean;
like: string; like: string;
types: ReferenceType[];
} }

View File

@ -21,6 +21,8 @@ import { TranslateService } from '@ngx-translate/core';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { takeUntil } from 'rxjs/operators'; import { takeUntil } from 'rxjs/operators';
import { nameof } from 'ts-simple-nameof'; import { nameof } from 'ts-simple-nameof';
import { IsActiveTypePipe } from '@common/formatting/pipes/is-active-type.pipe';
import { ReferenceTypePipe } from '@common/formatting/pipes/reference-type.pipe';
@Component({ @Component({
templateUrl: './REFERENCE-LISTING.component.html', templateUrl: './REFERENCE-LISTING.component.html',
@ -100,6 +102,7 @@ export class ReferenceListingComponent extends BaseListingComponent<Reference, R
prop: nameof<Reference>(x => x.type), prop: nameof<Reference>(x => x.type),
sortable: true, sortable: true,
languageName: 'REFERENCE-LISTING.FIELDS.TYPE', languageName: 'REFERENCE-LISTING.FIELDS.TYPE',
pipe: this.pipeService.getPipe<ReferenceTypePipe>(ReferenceTypePipe)
}, },
{ {
prop: nameof<Reference>(x => x.createdAt), prop: nameof<Reference>(x => x.createdAt),
@ -113,6 +116,12 @@ export class ReferenceListingComponent extends BaseListingComponent<Reference, R
languageName: 'REFERENCE-LISTING.FIELDS.UPDATED-AT', languageName: 'REFERENCE-LISTING.FIELDS.UPDATED-AT',
pipe: this.pipeService.getPipe<DataTableDateTimeFormatPipe>(DataTableDateTimeFormatPipe).withFormat('short') pipe: this.pipeService.getPipe<DataTableDateTimeFormatPipe>(DataTableDateTimeFormatPipe).withFormat('short')
}, },
{
prop: nameof<Reference>(x => x.isActive),
sortable: true,
languageName: 'REFERENCE-LISTING.FIELDS.IS-ACTIVE',
pipe: this.pipeService.getPipe<IsActiveTypePipe>(IsActiveTypePipe)
},
{ {
alwaysShown: true, alwaysShown: true,
cellTemplate: this.actions, cellTemplate: this.actions,

View File

@ -21,6 +21,7 @@ import { TranslateService } from '@ngx-translate/core';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { takeUntil } from 'rxjs/operators'; import { takeUntil } from 'rxjs/operators';
import { nameof } from 'ts-simple-nameof'; import { nameof } from 'ts-simple-nameof';
import { IsActiveTypePipe } from '@common/formatting/pipes/is-active-type.pipe';
@Component({ @Component({
templateUrl: './tenant-listing.component.html', templateUrl: './tenant-listing.component.html',
@ -94,7 +95,6 @@ export class TenantListingComponent extends BaseListingComponent<Tenant, TenantL
prop: nameof<Tenant>(x => x.code), prop: nameof<Tenant>(x => x.code),
sortable: true, sortable: true,
languageName: 'TENANT-LISTING.FIELDS.CODE', languageName: 'TENANT-LISTING.FIELDS.CODE',
//cellTemplate: this.TenantStatus
}, },
{ {
prop: nameof<Tenant>(x => x.createdAt), prop: nameof<Tenant>(x => x.createdAt),
@ -108,6 +108,12 @@ export class TenantListingComponent extends BaseListingComponent<Tenant, TenantL
languageName: 'TENANT-LISTING.FIELDS.UPDATED-AT', languageName: 'TENANT-LISTING.FIELDS.UPDATED-AT',
pipe: this.pipeService.getPipe<DataTableDateTimeFormatPipe>(DataTableDateTimeFormatPipe).withFormat('short') pipe: this.pipeService.getPipe<DataTableDateTimeFormatPipe>(DataTableDateTimeFormatPipe).withFormat('short')
}, },
{
prop: nameof<Tenant>(x => x.isActive),
sortable: true,
languageName: 'TENANT-LISTING.FIELDS.IS-ACTIVE',
pipe: this.pipeService.getPipe<IsActiveTypePipe>(IsActiveTypePipe)
},
{ {
alwaysShown: true, alwaysShown: true,
cellTemplate: this.actions, cellTemplate: this.actions,

View File

@ -1006,11 +1006,13 @@
"STATUS": "Status", "STATUS": "Status",
"UPDATED-AT": "Updated", "UPDATED-AT": "Updated",
"CREATED-AT": "Created", "CREATED-AT": "Created",
"PUBLISHED-AT": "Published" "PUBLISHED-AT": "Published",
"IS-ACTIVE":"Is Active"
}, },
"FILTER": { "FILTER": {
"TITLE": "Filters", "TITLE": "Filters",
"IS-ACTIVE": "Is Active", "IS-ACTIVE": "Is Active",
"STATUS": "Status",
"CANCEL": "Cancel", "CANCEL": "Cancel",
"APPLY-FILTERS": "Apply filters" "APPLY-FILTERS": "Apply filters"
}, },
@ -1046,11 +1048,13 @@
"NAME": "Name", "NAME": "Name",
"STATUS": "Status", "STATUS": "Status",
"UPDATED-AT": "Updated", "UPDATED-AT": "Updated",
"CREATED-AT": "Created" "CREATED-AT": "Created",
"IS-ACTIVE": "Is Active"
}, },
"FILTER": { "FILTER": {
"TITLE": "Filters", "TITLE": "Filters",
"IS-ACTIVE": "Is Active", "IS-ACTIVE": "Is Active",
"STATUS": "Status",
"CANCEL": "Cancel", "CANCEL": "Cancel",
"APPLY-FILTERS": "Apply filters" "APPLY-FILTERS": "Apply filters"
}, },
@ -1073,7 +1077,8 @@
"NAME": "Name", "NAME": "Name",
"CODE": "Code", "CODE": "Code",
"UPDATED-AT": "Updated", "UPDATED-AT": "Updated",
"CREATED-AT": "Created" "CREATED-AT": "Created",
"IS-ACTIVE": "Is Active"
}, },
"FILTER": { "FILTER": {
"TITLE": "Filters", "TITLE": "Filters",
@ -1100,7 +1105,8 @@
"NAME": "Name", "NAME": "Name",
"CODE": "Code", "CODE": "Code",
"UPDATED-AT": "Updated", "UPDATED-AT": "Updated",
"CREATED-AT": "Created" "CREATED-AT": "Created",
"IS-ACTIVE": "Is Active"
}, },
"FILTER": { "FILTER": {
"TITLE": "Filters", "TITLE": "Filters",
@ -1128,11 +1134,13 @@
"SOURCE": "Source", "SOURCE": "Source",
"TYPE": "Type", "TYPE": "Type",
"UPDATED-AT": "Updated", "UPDATED-AT": "Updated",
"CREATED-AT": "Created" "CREATED-AT": "Created",
"IS-ACTIVE": "Is Active"
}, },
"FILTER": { "FILTER": {
"TITLE": "Filters", "TITLE": "Filters",
"IS-ACTIVE": "Is Active", "IS-ACTIVE": "Is Active",
"TYPE": "Type",
"CANCEL": "Cancel", "CANCEL": "Cancel",
"APPLY-FILTERS": "Apply filters" "APPLY-FILTERS": "Apply filters"
}, },
@ -1154,7 +1162,8 @@
"FIELDS": { "FIELDS": {
"CODE": "Code", "CODE": "Code",
"UPDATED-AT": "Updated", "UPDATED-AT": "Updated",
"CREATED-AT": "Created" "CREATED-AT": "Created",
"IS-ACTIVE": "Is Active"
}, },
"FILTER": { "FILTER": {
"TITLE": "Filters", "TITLE": "Filters",
@ -1587,11 +1596,13 @@
"STATUS": "Status", "STATUS": "Status",
"UPDATED-AT": "Updated", "UPDATED-AT": "Updated",
"CREATED-AT": "Created", "CREATED-AT": "Created",
"PUBLISHED-AT": "Published" "PUBLISHED-AT": "Published",
"IS-ACTIVE":"Is Active"
}, },
"FILTER": { "FILTER": {
"TITLE": "Filters", "TITLE": "Filters",
"IS-ACTIVE": "Is Active", "IS-ACTIVE": "Is Active",
"STATUS": "Status",
"CANCEL": "Cancel", "CANCEL": "Cancel",
"APPLY-FILTERS": "Apply filters" "APPLY-FILTERS": "Apply filters"
}, },
@ -1797,11 +1808,13 @@
"ROLES": "Roles", "ROLES": "Roles",
"NAME": "Name", "NAME": "Name",
"UPDATED-AT": "Updated", "UPDATED-AT": "Updated",
"CREATED-AT": "Created" "CREATED-AT": "Created",
"IS-ACTIVE": "Is Active"
}, },
"FILTER": { "FILTER": {
"TITLE": "Filters", "TITLE": "Filters",
"IS-ACTIVE": "Is Active", "IS-ACTIVE": "Is Active",
"ROLES": "Roles",
"CANCEL": "Cancel", "CANCEL": "Cancel",
"APPLY-FILTERS": "Apply filters" "APPLY-FILTERS": "Apply filters"
}, },
@ -1818,6 +1831,10 @@
"MANAGER": "Manager", "MANAGER": "Manager",
"DESCRIPTION-TEMPLATE-EDITOR": "Description Template Editor" "DESCRIPTION-TEMPLATE-EDITOR": "Description Template Editor"
}, },
"IS-ACTIVE":{
"ACTIVE":"Active",
"INACTIVE":"Inactive"
},
"DMP-PROFILE-FIELD": { "DMP-PROFILE-FIELD": {
"DATA-TYPE": { "DATA-TYPE": {
"DATE": "Date", "DATE": "Date",

View File

@ -5,6 +5,7 @@ import { DataTableDateOnlyFormatPipe, DateOnlyPipe } from '@common/formatting/pi
import { DataTableDateTimeFormatPipe, DateTimeFormatPipe } from '@common/formatting/pipes/date-time-format.pipe'; import { DataTableDateTimeFormatPipe, DateTimeFormatPipe } from '@common/formatting/pipes/date-time-format.pipe';
import { LowercaseFirstLetterPipe } from '@common/formatting/pipes/lowercase-first-letter.pipe'; import { LowercaseFirstLetterPipe } from '@common/formatting/pipes/lowercase-first-letter.pipe';
import { IsActiveTypePipe } from './pipes/is-active-type.pipe'; import { IsActiveTypePipe } from './pipes/is-active-type.pipe';
import { ReferenceTypePipe } from './pipes/reference-type.pipe';
// //
// //
@ -21,7 +22,8 @@ import { IsActiveTypePipe } from './pipes/is-active-type.pipe';
ArrayToStringPipe, ArrayToStringPipe,
DateOnlyPipe, DateOnlyPipe,
DataTableDateOnlyFormatPipe, DataTableDateOnlyFormatPipe,
IsActiveTypePipe IsActiveTypePipe,
ReferenceTypePipe
], ],
exports: [ exports: [
@ -33,7 +35,8 @@ import { IsActiveTypePipe } from './pipes/is-active-type.pipe';
ArrayToStringPipe, ArrayToStringPipe,
DateOnlyPipe, DateOnlyPipe,
DataTableDateOnlyFormatPipe, DataTableDateOnlyFormatPipe,
IsActiveTypePipe IsActiveTypePipe,
ReferenceTypePipe
], ],
providers: [ providers: [
DateFormatPipe, DateFormatPipe,
@ -44,7 +47,8 @@ import { IsActiveTypePipe } from './pipes/is-active-type.pipe';
ArrayToStringPipe, ArrayToStringPipe,
DateOnlyPipe, DateOnlyPipe,
DataTableDateOnlyFormatPipe, DataTableDateOnlyFormatPipe,
IsActiveTypePipe IsActiveTypePipe,
ReferenceTypePipe
] ]
}) })
export class CommonFormattingModule { } export class CommonFormattingModule { }

View File

@ -0,0 +1,11 @@
import { Pipe, PipeTransform } from '@angular/core';
import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
@Pipe({ name: 'AppRoleTypeFormat' })
export class AppRoleTypePipe implements PipeTransform {
constructor(private enumUtils: EnumUtils) { }
public transform(value): any {
return this.enumUtils.toAppRoleString(value);
}
}

View File

@ -0,0 +1,11 @@
import { Pipe, PipeTransform } from '@angular/core';
import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
@Pipe({ name: 'ReferenceTypeFormat' })
export class ReferenceTypePipe implements PipeTransform {
constructor(private enumUtils: EnumUtils) { }
public transform(value): any {
return this.enumUtils.toReferenceTypeString(value);
}
}