Compare commits

...

2 Commits

5 changed files with 12 additions and 21 deletions

View File

@ -5,10 +5,7 @@ import { DescriptionStatus } from '../common/enum/description-status';
import { DmpLookup } from './dmp.lookup'; import { DmpLookup } from './dmp.lookup';
import { DmpUserRole } from '../common/enum/dmp-user-role'; import { DmpUserRole } from '../common/enum/dmp-user-role';
import { DescriptionTag } from '../model/description/description'; import { DescriptionTag } from '../model/description/description';
import { UntypedFormBuilder, UntypedFormControl, UntypedFormGroup } from '@angular/forms';
import { ReferenceType } from '../model/reference-type/reference-type'; import { ReferenceType } from '../model/reference-type/reference-type';
import { Reference } from '../model/reference/reference';
import { ReferenceTypeLookup } from './reference-type.lookup';
import { DescriptionReferenceLookup, ReferenceLookup } from './reference.lookup'; import { DescriptionReferenceLookup, ReferenceLookup } from './reference.lookup';
export class DescriptionLookup extends Lookup implements DescriptionFilter { export class DescriptionLookup extends Lookup implements DescriptionFilter {
@ -56,7 +53,7 @@ export interface DescriptionFilter {
export class ReferencesWithType { export class ReferencesWithType {
referenceType: ReferenceType; referenceType: ReferenceType;
references: Reference[]; references: Guid[];
constructor() { constructor() {
} }

View File

@ -150,18 +150,6 @@ export class ReferenceService {
}; };
} }
public getInternalMultipleAutoCompleteConfiguration(typeId: Guid, dependencyReferences: Reference[]): MultipleAutoCompleteConfiguration {
return {
initialItems: (excludedItems: any[], data?: any) => this.searchWithDefinition(this.buildAutocompleteSearchLookup(typeId, dependencyReferences, null)).pipe(map(x => x.filter(r => r.sourceType == ReferenceSourceType.Internal))).pipe(map(x => x)),
filterFn: (searchQuery: string, excludedItems: any[]) => this.searchWithDefinition(this.buildAutocompleteSearchLookup(typeId, dependencyReferences, searchQuery)).pipe(map(x => x.filter(r => r.sourceType == ReferenceSourceType.Internal))).pipe(map(x => x)),
displayFn: (item: Reference) => item.label,
titleFn: (item: Reference) => item.label,
subtitleFn: (item: Reference) => item?.sourceType === ReferenceSourceType.External ? this.language.instant('REFERENCE-FIELD-COMPONENT.EXTERNAL-SOURCE') + ': ' + item.source : this.language.instant('REFERENCE-FIELD-COMPONENT.INTERNAL-SOURCE'),
valueAssign: (item: Reference) => item,
uniqueAssign: (item: Reference) => item.source + '_' + item.reference,
};
}
private buildAutocompleteSearchLookup(typeId: Guid, dependencyReferences: Reference[], like?: string): ReferenceSearchLookup { private buildAutocompleteSearchLookup(typeId: Guid, dependencyReferences: Reference[], like?: string): ReferenceSearchLookup {
const lookup: ReferenceSearchLookup = new ReferenceSearchLookup(); const lookup: ReferenceSearchLookup = new ReferenceSearchLookup();
lookup.page = { size: 100, offset: 0 }; lookup.page = { size: 100, offset: 0 };

View File

@ -29,7 +29,8 @@
</button> </button>
</div> </div>
</div> </div>
<div *ngIf="listingItems && listingItems.length > 0 || this.lookup.like" class="filter-btn" [style.right]="dialog.getDialogById('filters') ? '446px' : '0px'" [style.width]="listingItems.length > 2 ? '57px' : '37px'" (click)="openFiltersDialog()"> <div *ngIf="listingItems && listingItems.length > 0 || this.lookup.like || this.lookup.descriptionTemplateIds || this.lookup.associatedDmpIds || this.lookup.roleInDmp || this.lookup.tags || this.lookup.descriptionReferenceSubQuery"
class="filter-btn" [style.right]="dialog.getDialogById('filters') ? '446px' : '0px'" [style.width]="listingItems.length > 2 ? '57px' : '37px'" (click)="openFiltersDialog()">
<button mat-raised-button class="p-0"> <button mat-raised-button class="p-0">
<mat-icon class="mr-4 filter-icon">filter_alt</mat-icon> <mat-icon class="mr-4 filter-icon">filter_alt</mat-icon>
</button> </button>

View File

@ -382,10 +382,15 @@ export class DescriptionListingComponent extends BaseListingComponent<BaseDescri
lookup.tags = formGroup.get("tags")?.value ?? null; lookup.tags = formGroup.get("tags")?.value ?? null;
lookup.associatedDmpIds = formGroup.get("associatedDmpIds")?.value ?? null; lookup.associatedDmpIds = formGroup.get("associatedDmpIds")?.value ?? null;
lookup.descriptionTemplateIds = formGroup.get("descriptionTemplates")?.value ?? null; lookup.descriptionTemplateIds = formGroup.get("descriptionTemplates")?.value ?? null;
lookup.descriptionReferenceSubQuery = this.initializeReferenceLookup();
lookup.descriptionReferenceSubQuery.referenceIds = formGroup.get("references")?.value let references: Guid[] = formGroup.get("references")?.value
?.filter((reference: ReferencesWithType) => reference.referenceType != null && reference.references?.length > 0) ?.filter((reference: ReferencesWithType) => reference.referenceType != null && reference.references?.length > 0)
?.flatMap((referencesWithType: ReferencesWithType) => referencesWithType.references?.map(reference => reference.id)) as Guid[]; ?.flatMap((referencesWithType: ReferencesWithType) => referencesWithType.references) as Guid[];
if (references && references?.length > 0) {
lookup.descriptionReferenceSubQuery = this.initializeReferenceLookup();
lookup.descriptionReferenceSubQuery.referenceIds = references;
} else lookup.descriptionReferenceSubQuery = null;
return lookup; return lookup;
} }

View File

@ -167,7 +167,7 @@ export class DescriptionFilterComponent extends BaseCriteriaComponent implements
}; };
getReferenceAutocompleteConfiguration(referenceTypeId: Guid, excludedIds: Reference[]): MultipleAutoCompleteConfiguration { getReferenceAutocompleteConfiguration(referenceTypeId: Guid, excludedIds: Reference[]): MultipleAutoCompleteConfiguration {
let autocomplete = this.referenceService.getInternalMultipleAutoCompleteConfiguration(referenceTypeId, excludedIds); let autocomplete = this.referenceService.getMultipleAutoCompleteQueryConfiguration([referenceTypeId]);
return autocomplete; return autocomplete;
}; };