filters fixes

This commit is contained in:
CITE\spapacharalampous 2024-08-27 17:17:03 +03:00
parent 783cd3e86d
commit c539ea8adf
11 changed files with 120 additions and 54 deletions

View File

@ -54,7 +54,7 @@ export class DescriptionTemplateListingFiltersComponent extends BaseComponent im
...this.filter,
like,
isActive: isActive ? [IsActive.Active] : [IsActive.Inactive],
statuses
statuses: statuses?.length > 0 ? statuses : null,
})
}
@ -84,9 +84,16 @@ export class DescriptionTemplateListingFiltersComponent extends BaseComponent im
private _computeAppliedFilters(filters: DescriptionTemplateListingFilters): number {
let count = 0;
if (filters?.isActive) {
count++
if (!filters?.isActive) {
count++;
}
if (filters?.like) {
count++;
}
if (filters?.statuses?.length) {
count++;
}
return count;
}

View File

@ -53,7 +53,7 @@ export class DescriptionTemplateTypeListingFiltersComponent extends BaseComponen
...this.filter,
like,
isActive: isActive ? [IsActive.Active] : [IsActive.Inactive],
statuses
statuses: statuses?.length > 0 ? statuses : null,
})
}
@ -83,9 +83,16 @@ export class DescriptionTemplateTypeListingFiltersComponent extends BaseComponen
private _computeAppliedFilters(filters: DescriptionTemplateTypeListingFilters): number {
let count = 0;
if (filters?.isActive) {
if (!filters?.isActive) {
count++
}
if (filters?.like) {
count++;
}
if (filters?.statuses?.length) {
count++;
}
return count;
}

View File

@ -56,9 +56,9 @@ export class LockListingFiltersComponent extends BaseComponent implements OnInit
const { targetTypes, like, userIds } = this.internalFilters ?? {}
this.filterChange.emit({
...this.filter,
targetTypes,
targetTypes: targetTypes?.length > 0 ? targetTypes : null,
like,
userIds
userIds: userIds?.length > 0 ? userIds : null,
})
}
@ -89,6 +89,17 @@ export class LockListingFiltersComponent extends BaseComponent implements OnInit
private _computeAppliedFilters(filters: LockListingFilters): number {
let count = 0;
if (filters?.like) {
count++;
}
if (filters?.targetTypes?.length) {
count++;
}
if (filters?.userIds?.length) {
count++;
}
return count;
}

View File

@ -4,7 +4,6 @@ import { IsActive } from '@app/core/common/enum/is-active.enum';
import { PlanBlueprintFilter } from '@app/core/query/plan-blueprint.lookup';
import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
import { BaseComponent } from '@common/base/base.component';
import { Guid } from '@common/types/guid';
import { nameof } from 'ts-simple-nameof';
@Component({
@ -54,7 +53,7 @@ export class PlanBlueprintListingFiltersComponent extends BaseComponent implemen
...this.filter,
like,
isActive: isActive ? [IsActive.Active] : [IsActive.Inactive],
statuses
statuses: statuses?.length > 0 ? statuses : null,
})
}
@ -84,9 +83,15 @@ export class PlanBlueprintListingFiltersComponent extends BaseComponent implemen
private _computeAppliedFilters(filters: PlanBlueprintListingFilters): number {
let count = 0;
if (filters?.isActive) {
if (!filters?.isActive) {
count++
}
if (filters?.like) {
count++;
}
if (filters?.statuses?.length) {
count++;
}
return count;
}

View File

@ -6,27 +6,27 @@ import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
import { BaseComponent } from '@common/base/base.component';
@Component({
selector: 'app-plan-status-listing-filters',
templateUrl: './plan-status-listing-filters.component.html',
styleUrl: './plan-status-listing-filters.component.scss'
selector: 'app-plan-status-listing-filters',
templateUrl: './plan-status-listing-filters.component.html',
styleUrl: './plan-status-listing-filters.component.scss'
})
export class PlanStatusListingFiltersComponent extends BaseComponent{
readonly filter = input<PlanStatusFilter>();
export class PlanStatusListingFiltersComponent extends BaseComponent {
readonly filter = input<PlanStatusFilter>();
@Output() filterChange = new EventEmitter<PlanStatusFilter>();
internalFilters: PlanStatusListingFilters = this._getEmptyFilters();
appliedFilterCount: number = 0;
internalStatusEnum = this.enumUtils.getEnumValues<PlanStatusEnum>(PlanStatusEnum);
internalFilters: PlanStatusListingFilters = this._getEmptyFilters();
appliedFilterCount: number = 0;
internalStatusEnum = this.enumUtils.getEnumValues<PlanStatusEnum>(PlanStatusEnum);
constructor(protected enumUtils: EnumUtils){
super();
effect(() => {
const newFilters = this.filter();
if(newFilters){
this.updateFilters();
}
})
}
constructor(protected enumUtils: EnumUtils) {
super();
effect(() => {
const newFilters = this.filter();
if (newFilters) {
this.updateFilters();
}
})
}
private _parseToInternalFilters(inputFilter: PlanStatusFilter): PlanStatusListingFilters {
@ -39,7 +39,7 @@ export class PlanStatusListingFiltersComponent extends BaseComponent{
return {
isActive: (isActive ?? [])?.includes(IsActive.Active) || !isActive?.length,
like,
internalStatuses: internalStatuses?.length ? internalStatuses : null
internalStatuses: internalStatuses?.length ? internalStatuses : null
}
}
@ -49,44 +49,44 @@ export class PlanStatusListingFiltersComponent extends BaseComponent{
if (!filters?.isActive) {
count++
}
if(filters?.like){
count++;
}
if(filters?.internalStatuses?.length) {
count++;
}
if (filters?.like) {
count++;
}
if (filters?.internalStatuses?.length) {
count++;
}
return count;
}
private _getEmptyFilters(): PlanStatusListingFilters {
private _getEmptyFilters(): PlanStatusListingFilters {
return {
isActive: true,
like: null,
internalStatuses: null
internalStatuses: null
}
}
protected updateFilters(): void {
protected updateFilters(): void {
this.internalFilters = this._parseToInternalFilters(this.filter());
this.appliedFilterCount = this._computeAppliedFilters(this.internalFilters);
}
protected applyFilters(): void {
protected applyFilters(): void {
const { isActive, like, internalStatuses } = this.internalFilters ?? {}
this.filterChange.emit({
...this.filter(),
like,
isActive: isActive ? [IsActive.Active] : [IsActive.Inactive],
internalStatuses: internalStatuses?.length ? internalStatuses : null
internalStatuses: internalStatuses?.length ? internalStatuses : null
})
}
protected onSearchTermChange(searchTerm: string): void {
protected onSearchTermChange(searchTerm: string): void {
this.applyFilters();
}
protected clearFilters() {
protected clearFilters() {
this.internalFilters = this._getEmptyFilters();
}
}
@ -94,5 +94,5 @@ export class PlanStatusListingFiltersComponent extends BaseComponent{
interface PlanStatusListingFilters {
isActive: boolean;
like: string;
internalStatuses: PlanStatusEnum[];
internalStatuses: PlanStatusEnum[];
}

View File

@ -77,9 +77,13 @@ export class PrefillingSourceListingFiltersComponent extends BaseComponent imple
private _computeAppliedFilters(filters: PrefillingSourceListingFilters): number {
let count = 0;
if (filters?.isActive) {
count++
if (!filters?.isActive) {
count++;
}
if (filters?.like) {
count++;
}
return count;
}

View File

@ -77,9 +77,13 @@ export class ReferenceTypeListingFiltersComponent extends BaseComponent implemen
private _computeAppliedFilters(filters: ReferenceTypeListingFilters): number {
let count = 0;
if (filters?.isActive) {
if (!filters?.isActive) {
count++
}
if (filters?.like) {
count++;
}
return count;
}

View File

@ -56,8 +56,8 @@ export class ReferenceListingFiltersComponent extends BaseComponent implements O
...this.filter,
like,
isActive: isActive ? [IsActive.Active] : [IsActive.Inactive],
typeIds,
sourceTypes
typeIds: typeIds?.length > 0 ? typeIds : null,
sourceTypes: sourceTypes?.length > 0 ? sourceTypes : null,
})
}
@ -89,9 +89,19 @@ export class ReferenceListingFiltersComponent extends BaseComponent implements O
private _computeAppliedFilters(filters: ReferenceListingFilters): number {
let count = 0;
if (filters?.isActive) {
if (!filters?.isActive) {
count++
}
if (filters?.like) {
count++;
}
if (filters?.sourceTypes?.length) {
count++;
}
if (filters?.typeIds?.length) {
count++;
}
return count;
}

View File

@ -77,9 +77,13 @@ export class TenantListingFiltersComponent extends BaseComponent implements OnIn
private _computeAppliedFilters(filters: TenantListingFilters): number {
let count = 0;
if (filters?.isActive) {
count++
if (!filters?.isActive) {
count++;
}
if (filters?.like) {
count++;
}
return count;
}

View File

@ -53,7 +53,7 @@ export class UsageLimitListingFiltersComponent extends BaseComponent implements
...this.filter,
like,
isActive: isActive ? [IsActive.Active] : [IsActive.Inactive],
usageLimitTargetMetrics
usageLimitTargetMetrics: usageLimitTargetMetrics?.length > 0 ? usageLimitTargetMetrics : null,
})
}
@ -83,9 +83,16 @@ export class UsageLimitListingFiltersComponent extends BaseComponent implements
private _computeAppliedFilters(filters: UsageLimitListingFilters): number {
let count = 0;
if (filters?.isActive) {
if (!filters?.isActive) {
count++
}
if (filters?.like) {
count++;
}
if (filters?.usageLimitTargetMetrics?.length) {
count++;
}
return count;
}

View File

@ -58,7 +58,7 @@ export class UserListingFiltersComponent extends BaseComponent implements OnInit
like,
isActive: isActive ? [IsActive.Active] : [IsActive.Inactive],
}
if (userRoleSubQuery && userRoleSubQuery.roles != null && userRoleSubQuery.roles.length > 0) {
if (userRoleSubQuery && userRoleSubQuery?.roles != null && userRoleSubQuery?.roles?.length > 0) {
filter = {
...filter,
userRoleSubQuery
@ -93,9 +93,16 @@ export class UserListingFiltersComponent extends BaseComponent implements OnInit
private _computeAppliedFilters(filters: UserListingFilters): number {
let count = 0;
if (filters?.isActive) {
if (!filters?.isActive) {
count++
}
if (filters?.like) {
count++;
}
if (filters?.userRoleSubQuery?.roles?.length) {
count++;
}
return count;
}