add reference listing filter
This commit is contained in:
parent
63e5cde313
commit
04d97fc2e2
|
@ -28,6 +28,14 @@
|
|||
</mat-label>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<mat-label>{{'REFERENCE-LISTING.FILTER.SOURCE-TYPE' | translate}}
|
||||
<mat-select multiple [(ngModel)]="internalFilters.sourceTypes">
|
||||
<mat-option *ngFor="let referenceSourceType of referenceSourceTypeEnumValues" [value]="referenceSourceType">{{enumUtils.toReferenceSourceTypeString(referenceSourceType)}}</mat-option>
|
||||
</mat-select>
|
||||
</mat-label>
|
||||
</div>
|
||||
|
||||
<div class="d-flex justify-content-end align-items-center mt-4 gap-1-rem">
|
||||
<button mat-stroked-button color="primary" (click)="filterMenuTrigger?.closeMenu()">
|
||||
{{'REFERENCE-LISTING.FILTER.CANCEL' | translate}}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core';
|
||||
import { IsActive } from '@app/core/common/enum/is-active.enum';
|
||||
import { ReferenceSourceType } from '@app/core/common/enum/reference-source-type';
|
||||
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';
|
||||
|
@ -16,6 +17,7 @@ export class ReferenceListingFiltersComponent extends BaseComponent implements O
|
|||
@Input() readonly filter: ReferenceFilter;
|
||||
@Output() filterChange = new EventEmitter<ReferenceFilter>();
|
||||
|
||||
referenceSourceTypeEnumValues = this.enumUtils.getEnumValues<ReferenceSourceType>(ReferenceSourceType)
|
||||
referenceTypeEnumValues = this.enumUtils.getEnumValues<ReferenceType>(ReferenceType);
|
||||
|
||||
// * State
|
||||
|
@ -48,12 +50,13 @@ export class ReferenceListingFiltersComponent extends BaseComponent implements O
|
|||
}
|
||||
|
||||
protected applyFilters(): void {
|
||||
const { isActive, like, types } = this.internalFilters ?? {}
|
||||
const { isActive, like, types, sourceTypes } = this.internalFilters ?? {}
|
||||
this.filterChange.emit({
|
||||
...this.filter,
|
||||
like,
|
||||
isActive: isActive ? [IsActive.Active] : [IsActive.Inactive],
|
||||
types
|
||||
types,
|
||||
sourceTypes
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -63,12 +66,13 @@ export class ReferenceListingFiltersComponent extends BaseComponent implements O
|
|||
return this._getEmptyFilters();
|
||||
}
|
||||
|
||||
let { excludedIds, ids, isActive, like, types } = inputFilter;
|
||||
let { excludedIds, ids, isActive, like, types, sourceTypes } = inputFilter;
|
||||
|
||||
return {
|
||||
isActive: (isActive ?? [])?.includes(IsActive.Active) || !isActive?.length,
|
||||
like: like,
|
||||
types: types
|
||||
types: types,
|
||||
sourceTypes: sourceTypes
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -77,7 +81,8 @@ export class ReferenceListingFiltersComponent extends BaseComponent implements O
|
|||
return {
|
||||
isActive: true,
|
||||
like: null,
|
||||
types: null
|
||||
types: null,
|
||||
sourceTypes: null
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -98,4 +103,5 @@ interface ReferenceListingFilters {
|
|||
isActive: boolean;
|
||||
like: string;
|
||||
types: ReferenceType[];
|
||||
sourceTypes: ReferenceSourceType[];
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import { takeUntil } from 'rxjs/operators';
|
|||
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';
|
||||
import { ReferenceSourceTypePipe } from '@common/formatting/pipes/reference-source-type.pipe';
|
||||
|
||||
@Component({
|
||||
templateUrl: './REFERENCE-LISTING.component.html',
|
||||
|
@ -40,6 +41,7 @@ export class ReferenceListingComponent extends BaseListingComponent<Reference, R
|
|||
nameof<Reference>(x => x.id),
|
||||
nameof<Reference>(x => x.label),
|
||||
nameof<Reference>(x => x.source),
|
||||
nameof<Reference>(x => x.sourceType),
|
||||
nameof<Reference>(x => x.type),
|
||||
nameof<Reference>(x => x.updatedAt),
|
||||
nameof<Reference>(x => x.createdAt),
|
||||
|
@ -98,6 +100,12 @@ export class ReferenceListingComponent extends BaseListingComponent<Reference, R
|
|||
sortable: true,
|
||||
languageName: 'REFERENCE-LISTING.FIELDS.SOURCE',
|
||||
},
|
||||
{
|
||||
prop: nameof<Reference>(x => x.sourceType),
|
||||
sortable: true,
|
||||
languageName: 'REFERENCE-LISTING.FIELDS.SOURCE-TYPE',
|
||||
pipe: this.pipeService.getPipe<ReferenceSourceTypePipe>(ReferenceSourceTypePipe)
|
||||
},
|
||||
{
|
||||
prop: nameof<Reference>(x => x.type),
|
||||
sortable: true,
|
||||
|
|
|
@ -1132,7 +1132,8 @@
|
|||
"FIELDS": {
|
||||
"LABEL": "Label",
|
||||
"SOURCE": "Source",
|
||||
"TYPE": "Type",
|
||||
"SOURCE-TYPE": "Source Type",
|
||||
"TYPE": "Reference Type",
|
||||
"UPDATED-AT": "Updated",
|
||||
"CREATED-AT": "Created",
|
||||
"IS-ACTIVE": "Is Active"
|
||||
|
@ -1141,6 +1142,7 @@
|
|||
"TITLE": "Filters",
|
||||
"IS-ACTIVE": "Is Active",
|
||||
"TYPE": "Type",
|
||||
"SOURCE-TYPE": "Source Type",
|
||||
"CANCEL": "Cancel",
|
||||
"APPLY-FILTERS": "Apply filters"
|
||||
},
|
||||
|
|
|
@ -6,6 +6,7 @@ import { DataTableDateTimeFormatPipe, DateTimeFormatPipe } from '@common/formatt
|
|||
import { LowercaseFirstLetterPipe } from '@common/formatting/pipes/lowercase-first-letter.pipe';
|
||||
import { IsActiveTypePipe } from './pipes/is-active-type.pipe';
|
||||
import { ReferenceTypePipe } from './pipes/reference-type.pipe';
|
||||
import { ReferenceSourceTypePipe } from './pipes/reference-source-type.pipe';
|
||||
|
||||
//
|
||||
//
|
||||
|
@ -23,8 +24,8 @@ import { ReferenceTypePipe } from './pipes/reference-type.pipe';
|
|||
DateOnlyPipe,
|
||||
DataTableDateOnlyFormatPipe,
|
||||
IsActiveTypePipe,
|
||||
ReferenceTypePipe
|
||||
|
||||
ReferenceTypePipe,
|
||||
ReferenceSourceTypePipe
|
||||
],
|
||||
exports: [
|
||||
DateFormatPipe,
|
||||
|
@ -36,7 +37,8 @@ import { ReferenceTypePipe } from './pipes/reference-type.pipe';
|
|||
DateOnlyPipe,
|
||||
DataTableDateOnlyFormatPipe,
|
||||
IsActiveTypePipe,
|
||||
ReferenceTypePipe
|
||||
ReferenceTypePipe,
|
||||
ReferenceSourceTypePipe
|
||||
],
|
||||
providers: [
|
||||
DateFormatPipe,
|
||||
|
@ -48,7 +50,8 @@ import { ReferenceTypePipe } from './pipes/reference-type.pipe';
|
|||
DateOnlyPipe,
|
||||
DataTableDateOnlyFormatPipe,
|
||||
IsActiveTypePipe,
|
||||
ReferenceTypePipe
|
||||
ReferenceTypePipe,
|
||||
ReferenceSourceTypePipe
|
||||
]
|
||||
})
|
||||
export class CommonFormattingModule { }
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
import { Pipe, PipeTransform } from '@angular/core';
|
||||
import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
|
||||
|
||||
@Pipe({ name: 'ReferenceSourceTypeFormat' })
|
||||
export class ReferenceSourceTypePipe implements PipeTransform {
|
||||
constructor(private enumUtils: EnumUtils) { }
|
||||
|
||||
public transform(value): any {
|
||||
return this.enumUtils.toReferenceSourceTypeString(value);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue