refactor description listing filters
This commit is contained in:
parent
b894342f45
commit
cc7ed0d59b
|
@ -1,5 +1,5 @@
|
|||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { FormBuilder, UntypedFormBuilder, UntypedFormControl, UntypedFormGroup, Validators } from '@angular/forms';
|
||||
import { FormBuilder, UntypedFormBuilder, Validators } from '@angular/forms';
|
||||
import { MatDialog, MatDialogRef } from '@angular/material/dialog';
|
||||
import { MatPaginator } from '@angular/material/paginator';
|
||||
import { MatSort } from '@angular/material/sort';
|
||||
|
@ -281,16 +281,17 @@ export class DescriptionListingComponent extends BaseListingComponent<BaseDescri
|
|||
});
|
||||
|
||||
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
||||
if (result) {
|
||||
if (!result) return;
|
||||
|
||||
this.updateDataFn(result);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
updateDataFn(filters: DescriptionListingFilters): void {
|
||||
this.referenceFilters = this._patchReferenceFilters(filters);
|
||||
this.lookup = this._patchLookupFromFilters(filters);
|
||||
this._patchLookupFromFilters(filters);
|
||||
this.filtersCount = this._countFilters(this.lookup);
|
||||
this.isLoading = false;
|
||||
this.filterChanged(this.lookup)
|
||||
}
|
||||
|
||||
|
@ -412,12 +413,10 @@ export class DescriptionListingComponent extends BaseListingComponent<BaseDescri
|
|||
}
|
||||
|
||||
_patchLookupFromFilters(filters: DescriptionListingFilters): DescriptionLookup {
|
||||
if (!filters) return;
|
||||
|
||||
this.lookup.statuses = filters.status !== null ? [filters.status] : null;
|
||||
this.lookup.statuses = filters?.status != null ? [filters?.status] : null;
|
||||
|
||||
// Tenants
|
||||
let viewOnlyTenant = filters.viewOnlyTenant ?? false;
|
||||
let viewOnlyTenant = filters?.viewOnlyTenant ?? false;
|
||||
if (viewOnlyTenant) {
|
||||
let tenant = this.tenants?.find(t => t.code && t.code?.toString() == this.authService.selectedTenant());
|
||||
if (tenant && tenant?.code) {
|
||||
|
@ -428,35 +427,33 @@ export class DescriptionListingComponent extends BaseListingComponent<BaseDescri
|
|||
} else this.lookup.tenantSubQuery = null;
|
||||
|
||||
// Description Templates
|
||||
let descriptionTemplates = filters.descriptionTemplates ?? null;
|
||||
let descriptionTemplates = filters?.descriptionTemplates ?? null;
|
||||
if (descriptionTemplates && descriptionTemplates?.length > 0) {
|
||||
this.lookup.descriptionTemplateSubQuery = DescriptionFilterService.initializeDescriptionTemplateLookup();
|
||||
this.lookup.descriptionTemplateSubQuery.ids = descriptionTemplates;
|
||||
} else this.lookup.descriptionTemplateSubQuery = null;
|
||||
|
||||
// Plans
|
||||
let plans = filters.associatedPlanIds ?? null; let addPlans = plans && plans?.length > 0;
|
||||
let roles = filters.role !== null ? [filters.role] : null; let addRoles = roles && roles?.length > 0;
|
||||
if (addPlans || addRoles) {
|
||||
if (filters?.role || filters?.associatedPlanIds?.length) {
|
||||
this.lookup.planSubQuery = DescriptionFilterService.initializePlanLookup();
|
||||
|
||||
if (addPlans) this.lookup.planSubQuery.ids = plans?.length > 0 ? plans : null;
|
||||
if (filters?.associatedPlanIds?.length) this.lookup.planSubQuery.ids = filters?.associatedPlanIds ?? null;
|
||||
|
||||
if (addRoles) {
|
||||
if (filters?.role) {
|
||||
this.lookup.planSubQuery.planUserSubQuery = DescriptionFilterService.initializePlanUserLookup();
|
||||
this.lookup.planSubQuery.planUserSubQuery.userRoles = roles;
|
||||
this.lookup.planSubQuery.planUserSubQuery.userRoles = [filters?.role];
|
||||
}
|
||||
} else this.lookup.planSubQuery = null;
|
||||
|
||||
// Tags
|
||||
let tags = filters.tags ?? null;
|
||||
let tags = filters?.tags ?? null;
|
||||
if (tags && tags?.length > 0) {
|
||||
this.lookup.descriptionTagSubQuery = DescriptionFilterService.initializeTagLookup();
|
||||
this.lookup.descriptionTagSubQuery.tagIds = tags;
|
||||
} else this.lookup.descriptionTagSubQuery = null;
|
||||
|
||||
// References
|
||||
let references: Guid[] = filters.references
|
||||
let references: Guid[] = filters?.references
|
||||
?.filter((reference: ReferencesWithType) => reference.referenceTypeId != null && reference.referenceIds?.length > 0)
|
||||
?.flatMap((referencesWithType: ReferencesWithType) => referencesWithType.referenceIds) as Guid[];
|
||||
|
||||
|
@ -469,7 +466,7 @@ export class DescriptionListingComponent extends BaseListingComponent<BaseDescri
|
|||
}
|
||||
|
||||
_patchReferenceFilters(filters: DescriptionListingFilters): ReferencesWithType[] {
|
||||
return filters.references?.filter(( referencesWithType: ReferencesWithType ) => referencesWithType.referenceTypeId != null && referencesWithType.referenceIds?.length > 0) ?? null;
|
||||
return filters?.references?.filter(( referencesWithType: ReferencesWithType ) => referencesWithType.referenceTypeId != null && referencesWithType.referenceIds?.length > 0) ?? null;
|
||||
}
|
||||
|
||||
private _countFilters(lookup: DescriptionLookup): number {
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
|
||||
<a class="col-auto d-flex pointer" (click)="onClose()"><span class="ml-auto mt-3 material-icons clear-icon">clear</span></a>
|
||||
<app-description-filter-component
|
||||
[filterFormGroup]="formGroup"
|
||||
[referencesWithTypeItems]="data.referencesWithTypeItems"
|
||||
[filters]="filters"
|
||||
[isPublic]="data.isPublic"
|
||||
[hasSelectedTenant]="data.hasSelectedTenant"
|
||||
(filterChanged)="onFilterChanged($event)"
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
import { Component, Inject, OnInit, ViewChild } from '@angular/core';
|
||||
import { FormGroup, UntypedFormBuilder, UntypedFormGroup } from '@angular/forms';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
import { AnalyticsService } from '@app/core/services/matomo/analytics-service';
|
||||
import { DescriptionFilterComponent, DescriptionListingFilterForm, DescriptionListingFilters } from '../description-filter.component';
|
||||
import { DescriptionFilterComponent, DescriptionListingFilters } from '../description-filter.component';
|
||||
import { DescriptionLookup, ReferencesWithType } from '@app/core/query/description.lookup';
|
||||
|
||||
@Component({
|
||||
|
@ -15,7 +14,7 @@ export class DescriptionFilterDialogComponent implements OnInit {
|
|||
|
||||
@ViewChild(DescriptionFilterComponent, { static: true }) filter: DescriptionFilterComponent;
|
||||
|
||||
formGroup: FormGroup<DescriptionListingFilterForm>;
|
||||
filters: DescriptionListingFilters;
|
||||
|
||||
constructor(
|
||||
public dialogRef: MatDialogRef<DescriptionFilterComponent>,
|
||||
|
@ -27,7 +26,7 @@ export class DescriptionFilterDialogComponent implements OnInit {
|
|||
referencesWithTypeItems: ReferencesWithType[],
|
||||
}
|
||||
) {
|
||||
this.formGroup = this._buildFormFromLookup(data?.lookup);
|
||||
this.filters = this._buildDescriptionFilters(data?.lookup, data?.referencesWithTypeItems);
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
@ -42,18 +41,19 @@ export class DescriptionFilterDialogComponent implements OnInit {
|
|||
this.dialogRef.close();
|
||||
}
|
||||
|
||||
onFilterChanged(formGroup: UntypedFormGroup) {
|
||||
this.dialogRef.close(formGroup.value as DescriptionListingFilters);
|
||||
onFilterChanged(filters: DescriptionListingFilters) {
|
||||
this.dialogRef.close(filters);
|
||||
}
|
||||
|
||||
private _buildFormFromLookup(lookup: DescriptionLookup): FormGroup<DescriptionListingFilterForm> {
|
||||
return (new UntypedFormBuilder()).group({
|
||||
status: [lookup.statuses?.length > 0 ? lookup.statuses[0] : null],
|
||||
viewOnlyTenant: [lookup.tenantSubQuery?.codes?.length > 0 ? true : false],
|
||||
role: lookup.planSubQuery?.planUserSubQuery?.userRoles ? lookup.planSubQuery?.planUserSubQuery?.userRoles[0] : [],
|
||||
descriptionTemplates: lookup.descriptionTemplateSubQuery?.ids ? [lookup.descriptionTemplateSubQuery?.ids] : [],
|
||||
associatedPlanIds: lookup.planSubQuery?.ids ? [lookup.planSubQuery?.ids] : [],
|
||||
tags: lookup.descriptionTagSubQuery?.tagIds ? [lookup.descriptionTagSubQuery?.tagIds] : [],
|
||||
});
|
||||
private _buildDescriptionFilters(lookup: DescriptionLookup, references: ReferencesWithType[]): DescriptionListingFilters {
|
||||
return {
|
||||
status: lookup.statuses?.[0] ?? null,
|
||||
viewOnlyTenant: lookup.tenantSubQuery?.codes?.length > 0,
|
||||
role: lookup.planSubQuery?.planUserSubQuery?.userRoles?.[0] ?? null,
|
||||
descriptionTemplates: lookup.descriptionTemplateSubQuery?.ids ?? [],
|
||||
associatedPlanIds: lookup.planSubQuery?.ids ?? [],
|
||||
tags: lookup.descriptionTagSubQuery?.tagIds ?? [],
|
||||
references: references ?? []
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@
|
|||
<!-- Reference Types -->
|
||||
<div class="col-10 mb-1">
|
||||
<h6 class="category-title">{{'DESCRIPTION-LISTING.FILTERS.REFERENCE-TYPES.NAME' | translate }}</h6>
|
||||
<ng-container *ngFor="let referenceForm of filterFormGroup.get('references')?.controls; let i=index">
|
||||
<ng-container *ngFor="let referenceForm of formGroup.get('references')?.controls; let i=index">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<mat-form-field class="w-100" *ngIf="referenceForm.get('referenceTypeId')">
|
||||
|
@ -98,7 +98,7 @@
|
|||
</mat-form-field>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" *ngIf="referenceForm.get('referenceTypeId')?.value">
|
||||
<div class="row" *ngIf="referenceForm.get('referenceTypeId')?.value && selectReferenceAutocompleteConfiguration(referenceForm.get('referenceTypeId').value)">
|
||||
<div class="col-12">
|
||||
<mat-form-field class="w-100 mb-2">
|
||||
<mat-label>{{'DESCRIPTION-LISTING.FILTERS.REFERENCE-TYPES.REFERENCE' | translate}}</mat-label>
|
||||
|
@ -126,7 +126,11 @@
|
|||
</div>
|
||||
<!-- End of Reference Types -->
|
||||
|
||||
<div class="col-auto ml-auto mb-4">
|
||||
<div class="col-10 d-flex justify-content-between mb-4">
|
||||
<button mat-button class="normal-btn-sm rounded-btn secondary" (click)="resetFilters()" style="font-size: 0.87rem;">
|
||||
{{'DESCRIPTION-LISTING.FILTERS.RESET-FILTERS' | translate}}
|
||||
</button>
|
||||
|
||||
<button class="normal-btn-sm" (click)="controlModified()">
|
||||
{{'DESCRIPTION-LISTING.FILTERS.APPLY-FILTERS' | translate}}
|
||||
</button>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core';
|
||||
import { AbstractControl, FormArray, FormBuilder, FormControl, UntypedFormArray, UntypedFormGroup } from '@angular/forms';
|
||||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||
import { FormArray, FormControl, FormGroup, UntypedFormGroup } from '@angular/forms';
|
||||
import { DescriptionStatusEnum } from '@app/core/common/enum/description-status';
|
||||
import { PlanUserRole } from '@app/core/common/enum/plan-user-role';
|
||||
import { ReferenceType } from '@app/core/model/reference-type/reference-type';
|
||||
|
@ -18,10 +18,9 @@ import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/mu
|
|||
import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration';
|
||||
import { BaseCriteriaComponent } from '@app/ui/misc/criteria/base-criteria.component';
|
||||
import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model';
|
||||
import { QueryResult } from '@common/model/query-result';
|
||||
import { Guid } from '@common/types/guid';
|
||||
import { IsActive } from '@notification-service/core/enum/is-active.enum';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
import { map, takeUntil } from 'rxjs/operators';
|
||||
import { nameof } from 'ts-simple-nameof';
|
||||
|
||||
@Component({
|
||||
|
@ -29,13 +28,22 @@ import { nameof } from 'ts-simple-nameof';
|
|||
templateUrl: './description-filter.component.html',
|
||||
styleUrls: ['./description-filter.component.scss']
|
||||
})
|
||||
export class DescriptionFilterComponent extends BaseCriteriaComponent<any> implements OnInit, OnChanges {
|
||||
export class DescriptionFilterComponent extends BaseCriteriaComponent<DescriptionListingFilterForm> implements OnInit {
|
||||
|
||||
@Input() status;
|
||||
@Input() isPublic: boolean;
|
||||
@Input() hasSelectedTenant: boolean;
|
||||
@Input() referencesWithTypeItems: ReferencesWithType[];
|
||||
@Input() filterFormGroup: UntypedFormGroup;
|
||||
|
||||
private _filters: DescriptionListingFilters;
|
||||
@Input() set filters(v: DescriptionListingFilters) {
|
||||
if (v) {
|
||||
this._filters = v;
|
||||
this.buildForm(v);
|
||||
}
|
||||
}
|
||||
get filters(): DescriptionListingFilters {
|
||||
return this._filters;
|
||||
}
|
||||
|
||||
@Output() filterChanged: EventEmitter<any> = new EventEmitter();
|
||||
|
||||
public criteria: any;
|
||||
|
@ -45,11 +53,11 @@ export class DescriptionFilterComponent extends BaseCriteriaComponent<any> imple
|
|||
planRole = PlanUserRole;
|
||||
options: UntypedFormGroup;
|
||||
|
||||
descriptionTemplateAutoCompleteConfiguration: MultipleAutoCompleteConfiguration;
|
||||
planAutoCompleteConfiguration: MultipleAutoCompleteConfiguration;
|
||||
tagAutoCompleteConfiguration: MultipleAutoCompleteConfiguration;
|
||||
referenceTypeAutocompleteConfiguration: SingleAutoCompleteConfiguration;
|
||||
referenceAutocompleteConfiguration: Map<string, MultipleAutoCompleteConfiguration>;
|
||||
descriptionTemplateAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = this.descriptionTemplateService.buildMultipleAutocompleteConfiguration();
|
||||
planAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = this.planService.multipleAutocompleteConfiguration;
|
||||
tagAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = this.tagService.multipleAutocompleteConfiguration;
|
||||
referenceTypeAutocompleteConfiguration: SingleAutoCompleteConfiguration = this.getReferenceTypeAutocompleteConfiguration();
|
||||
referenceAutocompleteConfiguration: Map<Guid, MultipleAutoCompleteConfiguration>;
|
||||
|
||||
constructor(
|
||||
public enumUtils: EnumUtils,
|
||||
|
@ -59,7 +67,6 @@ export class DescriptionFilterComponent extends BaseCriteriaComponent<any> imple
|
|||
private tagService: TagService,
|
||||
private referenceService: ReferenceService,
|
||||
private referenceTypeService: ReferenceTypeService,
|
||||
private formBuilder: FormBuilder,
|
||||
) {
|
||||
super(new ValidationErrorModel());
|
||||
}
|
||||
|
@ -68,78 +75,78 @@ export class DescriptionFilterComponent extends BaseCriteriaComponent<any> imple
|
|||
super.ngOnInit();
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
if (changes['filterFormGroup']) {
|
||||
|
||||
this.descriptionTemplateAutoCompleteConfiguration = this.descriptionTemplateService.buildMultipleAutocompleteConfiguration();
|
||||
this.planAutoCompleteConfiguration = this.planService.multipleAutocompleteConfiguration;
|
||||
this.tagAutoCompleteConfiguration = this.tagService.multipleAutocompleteConfiguration;
|
||||
this.referenceTypeAutocompleteConfiguration = this.getReferenceTypeAutocompleteConfiguration();
|
||||
this.referenceAutocompleteConfiguration = new Map<string, MultipleAutoCompleteConfiguration>();
|
||||
|
||||
this.formGroup = this.filterFormGroup;
|
||||
|
||||
this.referencesWithTypeItems.forEach((referencesWithType: ReferencesWithType) => {
|
||||
|
||||
if (referencesWithType.referenceTypeId) {
|
||||
this.addReferenceType(referencesWithType.referenceTypeId.toString(), referencesWithType.referenceIds.map(x => x.toString()));
|
||||
}
|
||||
else if (referencesWithType.referenceIds && referencesWithType.referenceIds?.length > 0) {
|
||||
this.referenceService.query(this._referenceLookup(referencesWithType.referenceIds)).pipe(takeUntil(this._destroyed))
|
||||
.subscribe((result: QueryResult<Reference>) => {
|
||||
const references: Reference[] = result.items;
|
||||
|
||||
const groupedReferencesByTypeIds = new Map<string, string[]>();
|
||||
references.forEach(reference => {
|
||||
if (!groupedReferencesByTypeIds.has(reference.type.id.toString())) groupedReferencesByTypeIds.set(reference.type.id.toString(), []);
|
||||
|
||||
groupedReferencesByTypeIds.get(reference.type.id.toString()).push(reference.id.toString());
|
||||
buildForm(filters: DescriptionListingFilters) {
|
||||
this.formGroup = new FormGroup<DescriptionListingFilterForm>({
|
||||
status: new FormControl(filters?.status),
|
||||
viewOnlyTenant: new FormControl(filters.viewOnlyTenant),
|
||||
role: new FormControl(filters.role),
|
||||
descriptionTemplates: new FormControl(filters.descriptionTemplates),
|
||||
associatedPlanIds: new FormControl(filters.associatedPlanIds),
|
||||
tags: new FormControl(filters.tags),
|
||||
references: new FormArray([])
|
||||
});
|
||||
|
||||
groupedReferencesByTypeIds.forEach((referenceIds: string[], referenceId: string) => {
|
||||
this.addReferenceType(referenceId, referenceIds);
|
||||
this.referenceAutocompleteConfiguration = new Map<Guid, MultipleAutoCompleteConfiguration>();
|
||||
|
||||
filters?.references?.forEach((item: ReferencesWithType) => {
|
||||
|
||||
if (item.referenceTypeId) {
|
||||
this.addReferenceType(item.referenceTypeId, item.referenceIds);
|
||||
}
|
||||
else if (item.referenceIds && item.referenceIds?.length > 0) {
|
||||
this.referenceService.query(this._referenceLookup(item.referenceIds)).pipe(takeUntil(this._destroyed), map((x) => x.items))
|
||||
.subscribe((references: Reference[]) => {
|
||||
const types = new Set(references.map((x) => x.type.id));
|
||||
|
||||
types.forEach((typeId) => {
|
||||
const referenceIds = references.filter((x) => x.type.id === typeId).map(x => x.id);
|
||||
this.addReferenceType(typeId, referenceIds);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
resetFilters() {
|
||||
this.formGroup.reset();
|
||||
this.formGroup.patchValue({
|
||||
status: null,
|
||||
viewOnlyTenant: null,
|
||||
role: null,
|
||||
descriptionTemplates: null,
|
||||
associatedPlanIds: null,
|
||||
tags: null,
|
||||
references: null
|
||||
});
|
||||
this.referenceAutocompleteConfiguration.clear();
|
||||
}
|
||||
|
||||
addReferenceType(referenceTypeId: string = null, referenceIds: string[] = null): void {
|
||||
if (!this.formGroup.get('references')) this.formGroup.addControl('references', this.formBuilder.array([]));
|
||||
|
||||
const formArray = this.formGroup.get('references') as UntypedFormArray;
|
||||
|
||||
const referenceForm = this.formBuilder.group({
|
||||
referenceTypeId: referenceTypeId,
|
||||
referenceIds: referenceIds ? [referenceIds] : null,
|
||||
addReferenceType(referenceTypeId: Guid = null, referenceIds: Guid[] = null): void {
|
||||
const referenceForm = new FormGroup<DescriptionListingFilterReferencesForm>({
|
||||
referenceTypeId: new FormControl(referenceTypeId),
|
||||
referenceIds: new FormControl(referenceIds ? referenceIds : []),
|
||||
});
|
||||
|
||||
if (referenceTypeId && referenceTypeId != '' && referenceIds && referenceIds.length > 0) {
|
||||
let referenceAutocomplete = this.getReferenceAutocompleteConfiguration(Guid.parse(referenceTypeId));
|
||||
if (referenceTypeId && referenceIds?.length) {
|
||||
let referenceAutocomplete = this.getReferenceAutocompleteConfiguration(referenceTypeId);
|
||||
this.referenceAutocompleteConfiguration.set(referenceTypeId, referenceAutocomplete);
|
||||
}
|
||||
|
||||
this._registerReferenceTypeListener(referenceForm);
|
||||
this._registerReferencesListener(referenceForm);
|
||||
|
||||
formArray.push(referenceForm);
|
||||
this.formGroup.controls.references.push(referenceForm);
|
||||
}
|
||||
|
||||
deleteRow(index: number): void {
|
||||
const formArray = this.formGroup.get('references') as UntypedFormArray;
|
||||
const formArray = this.formGroup.controls.references;
|
||||
|
||||
formArray.removeAt(index);
|
||||
}
|
||||
|
||||
controlModified(): void {
|
||||
this.clearErrorModel();
|
||||
this.filterChanged.emit(this.formGroup);
|
||||
if (this.refreshCallback != null &&
|
||||
(this.formGroup.get('like')?.value == null || this.formGroup.get('like')?.value.length === 0 || this.formGroup.get('like')?.value.length > 2)
|
||||
) {
|
||||
setTimeout(() => this.refreshCallback(true));
|
||||
}
|
||||
this.filterChanged.emit(this.formGroup.value as DescriptionListingFilters);
|
||||
}
|
||||
|
||||
isAuthenticated(): boolean {
|
||||
|
@ -150,7 +157,7 @@ export class DescriptionFilterComponent extends BaseCriteriaComponent<any> imple
|
|||
return this.referenceTypeService.getSingleAutocompleteConfiguration();
|
||||
};
|
||||
|
||||
selectReferenceAutocompleteConfiguration(referenceTypeId: string): MultipleAutoCompleteConfiguration {
|
||||
selectReferenceAutocompleteConfiguration(referenceTypeId: Guid): MultipleAutoCompleteConfiguration {
|
||||
return this.referenceAutocompleteConfiguration.get(referenceTypeId);
|
||||
};
|
||||
|
||||
|
@ -176,26 +183,26 @@ export class DescriptionFilterComponent extends BaseCriteriaComponent<any> imple
|
|||
return lookup;
|
||||
}
|
||||
|
||||
private _registerReferenceTypeListener(control: AbstractControl) {
|
||||
control.get('referenceTypeId')?.valueChanges.pipe(takeUntil(this._destroyed))
|
||||
.subscribe((referenceTypeId: string) => {
|
||||
private _registerReferenceTypeListener(formGroup: FormGroup<DescriptionListingFilterReferencesForm>) {
|
||||
formGroup.controls.referenceTypeId?.valueChanges.pipe(takeUntil(this._destroyed))
|
||||
.subscribe((referenceTypeId: Guid) => {
|
||||
this.referenceTypeAutocompleteConfiguration = this.getReferenceTypeAutocompleteConfiguration();
|
||||
control.get('referenceIds')?.reset();
|
||||
formGroup.controls.referenceIds?.reset();
|
||||
|
||||
if (referenceTypeId && referenceTypeId != '') {
|
||||
let referenceAutocomplete = this.getReferenceAutocompleteConfiguration(Guid.parse(referenceTypeId));
|
||||
if (referenceTypeId) {
|
||||
let referenceAutocomplete = this.getReferenceAutocompleteConfiguration(referenceTypeId);
|
||||
this.referenceAutocompleteConfiguration.set(referenceTypeId, referenceAutocomplete);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private _registerReferencesListener(control: AbstractControl) {
|
||||
control.get('referenceIds')?.valueChanges.pipe(takeUntil(this._destroyed))
|
||||
private _registerReferencesListener(formGroup: FormGroup<DescriptionListingFilterReferencesForm>) {
|
||||
formGroup.controls.referenceIds?.valueChanges.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(references => {
|
||||
let referenceTypeId = control.get('referenceTypeId').value;
|
||||
let referenceTypeId = formGroup.controls.referenceTypeId.value;
|
||||
if (!referenceTypeId) return;
|
||||
|
||||
let referenceAutocomplete = this.getReferenceAutocompleteConfiguration(Guid.parse(referenceTypeId));
|
||||
let referenceAutocomplete = this.getReferenceAutocompleteConfiguration(referenceTypeId);
|
||||
this.referenceAutocompleteConfiguration.set(referenceTypeId, referenceAutocomplete);
|
||||
});
|
||||
}
|
||||
|
@ -211,12 +218,17 @@ export interface DescriptionListingFilters {
|
|||
references: ReferencesWithType[]
|
||||
}
|
||||
|
||||
export interface DescriptionListingFilterForm {
|
||||
interface DescriptionListingFilterForm {
|
||||
status: FormControl<DescriptionStatusEnum>,
|
||||
viewOnlyTenant: FormControl<boolean>,
|
||||
role: FormControl<Guid>,
|
||||
descriptionTemplates: FormControl<Guid[]>,
|
||||
associatedPlanIds: FormControl<Guid[]>,
|
||||
tags: FormControl<Guid[]>,
|
||||
references: FormArray<any>
|
||||
references: FormArray<FormGroup<DescriptionListingFilterReferencesForm>>
|
||||
}
|
||||
|
||||
interface DescriptionListingFilterReferencesForm {
|
||||
referenceTypeId: FormControl<Guid>,
|
||||
referenceIds: FormControl<Guid[]>
|
||||
}
|
||||
|
|
|
@ -316,6 +316,8 @@ export class PlanListingComponent extends BaseListingComponent<BasePlan, PlanLoo
|
|||
});
|
||||
|
||||
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
||||
if (!result) return;
|
||||
|
||||
this.updateDataFn(result);
|
||||
});
|
||||
}
|
||||
|
@ -408,7 +410,7 @@ export class PlanListingComponent extends BaseListingComponent<BasePlan, PlanLoo
|
|||
|
||||
private _patchLookupFromFilters(filters: PlanListingFilters): PlanLookup {
|
||||
|
||||
this.lookup.statuses = filters?.status !== null ? [filters.status] : null;
|
||||
this.lookup.statuses = filters?.status != null ? [filters.status] : null;
|
||||
|
||||
// Tenants
|
||||
let viewOnlyTenant = filters?.viewOnlyTenant ?? false;
|
||||
|
@ -437,7 +439,7 @@ export class PlanListingComponent extends BaseListingComponent<BasePlan, PlanLoo
|
|||
} else this.lookup.planBlueprintSubQuery = null;
|
||||
|
||||
// plans
|
||||
let roles = filters?.role !== null ? [filters.role] : null;
|
||||
let roles = filters?.role != null ? [filters.role] : null;
|
||||
if (roles && roles?.length > 0) {
|
||||
this.lookup.planUserSubQuery = PlanFilterService.initializePlanUserLookup();
|
||||
this.lookup.planUserSubQuery.userRoles = roles;
|
||||
|
|
|
@ -758,6 +758,7 @@
|
|||
"FILTERS": {
|
||||
"NAME": "Filters",
|
||||
"APPLY-FILTERS": "Apply filters",
|
||||
"RESET-FILTERS": "Reset",
|
||||
"NO-ITEMS-FOUND": "Your search didn't match any items.",
|
||||
"STATUS": {
|
||||
"NAME": "Status",
|
||||
|
@ -1045,6 +1046,7 @@
|
|||
"FILTERS": {
|
||||
"NAME": "Filters",
|
||||
"APPLY-FILTERS": "Apply filters",
|
||||
"RESET-FILTERS": "Reset",
|
||||
"STATUS": {
|
||||
"NAME": "Status",
|
||||
"TYPES": {
|
||||
|
|
|
@ -758,6 +758,7 @@
|
|||
"FILTERS": {
|
||||
"NAME": "Filters",
|
||||
"APPLY-FILTERS": "Apply filters",
|
||||
"RESET-FILTERS": "Reset",
|
||||
"NO-ITEMS-FOUND": "Your search didn't match any items.",
|
||||
"STATUS": {
|
||||
"NAME": "Status",
|
||||
|
@ -1045,6 +1046,7 @@
|
|||
"FILTERS": {
|
||||
"NAME": "Filters",
|
||||
"APPLY-FILTERS": "Apply filters",
|
||||
"RESET-FILTERS": "Reset",
|
||||
"STATUS": {
|
||||
"NAME": "Status",
|
||||
"TYPES": {
|
||||
|
|
|
@ -1044,6 +1044,7 @@
|
|||
"FILTERS": {
|
||||
"NAME": "Filters",
|
||||
"APPLY-FILTERS": "Apply filters",
|
||||
"RESET-FILTERS": "Reset",
|
||||
"STATUS": {
|
||||
"NAME": "Status",
|
||||
"TYPES": {
|
||||
|
|
|
@ -1046,6 +1046,7 @@
|
|||
"FILTERS": {
|
||||
"NAME": "Filters",
|
||||
"APPLY-FILTERS": "Apply filters",
|
||||
"RESET-FILTERS": "Reset",
|
||||
"STATUS": {
|
||||
"NAME": "Status",
|
||||
"TYPES": {
|
||||
|
|
|
@ -1046,6 +1046,7 @@
|
|||
"FILTERS": {
|
||||
"NAME": "Filters",
|
||||
"APPLY-FILTERS": "Apply filters",
|
||||
"RESET-FILTERS": "Reset",
|
||||
"STATUS": {
|
||||
"NAME": "Status",
|
||||
"TYPES": {
|
||||
|
|
|
@ -1046,6 +1046,7 @@
|
|||
"FILTERS": {
|
||||
"NAME": "Filters",
|
||||
"APPLY-FILTERS": "Apply filters",
|
||||
"RESET-FILTERS": "Reset",
|
||||
"STATUS": {
|
||||
"NAME": "Status",
|
||||
"TYPES": {
|
||||
|
|
|
@ -1046,6 +1046,7 @@
|
|||
"FILTERS": {
|
||||
"NAME": "Filters",
|
||||
"APPLY-FILTERS": "Apply filters",
|
||||
"RESET-FILTERS": "Reset",
|
||||
"STATUS": {
|
||||
"NAME": "Status",
|
||||
"TYPES": {
|
||||
|
|
|
@ -1046,6 +1046,7 @@
|
|||
"FILTERS": {
|
||||
"NAME": "Filters",
|
||||
"APPLY-FILTERS": "Apply filters",
|
||||
"RESET-FILTERS": "Reset",
|
||||
"STATUS": {
|
||||
"NAME": "Status",
|
||||
"TYPES": {
|
||||
|
|
|
@ -1046,6 +1046,7 @@
|
|||
"FILTERS": {
|
||||
"NAME": "Filters",
|
||||
"APPLY-FILTERS": "Apply filters",
|
||||
"RESET-FILTERS": "Reset",
|
||||
"STATUS": {
|
||||
"NAME": "Status",
|
||||
"TYPES": {
|
||||
|
|
|
@ -1046,6 +1046,7 @@
|
|||
"FILTERS": {
|
||||
"NAME": "Filters",
|
||||
"APPLY-FILTERS": "Apply filters",
|
||||
"RESET-FILTERS": "Reset",
|
||||
"STATUS": {
|
||||
"NAME": "Status",
|
||||
"TYPES": {
|
||||
|
|
|
@ -1046,6 +1046,7 @@
|
|||
"FILTERS": {
|
||||
"NAME": "Filters",
|
||||
"APPLY-FILTERS": "Apply filters",
|
||||
"RESET-FILTERS": "Reset",
|
||||
"STATUS": {
|
||||
"NAME": "Status",
|
||||
"TYPES": {
|
||||
|
|
Loading…
Reference in New Issue