Compare commits
2 Commits
ba3938ee03
...
bff183753b
Author | SHA1 | Date |
---|---|---|
Sofia Papacharalampous | bff183753b | |
Sofia Papacharalampous | 725daced7c |
|
@ -5,10 +5,7 @@ import { DescriptionStatus } from '../common/enum/description-status';
|
|||
import { DmpLookup } from './dmp.lookup';
|
||||
import { DmpUserRole } from '../common/enum/dmp-user-role';
|
||||
import { DescriptionTag } from '../model/description/description';
|
||||
import { UntypedFormBuilder, UntypedFormControl, UntypedFormGroup } from '@angular/forms';
|
||||
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';
|
||||
|
||||
export class DescriptionLookup extends Lookup implements DescriptionFilter {
|
||||
|
@ -56,7 +53,7 @@ export interface DescriptionFilter {
|
|||
|
||||
export class ReferencesWithType {
|
||||
referenceType: ReferenceType;
|
||||
references: Reference[];
|
||||
references: Guid[];
|
||||
|
||||
constructor() {
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
const lookup: ReferenceSearchLookup = new ReferenceSearchLookup();
|
||||
lookup.page = { size: 100, offset: 0 };
|
||||
|
|
|
@ -29,7 +29,8 @@
|
|||
</button>
|
||||
</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">
|
||||
<mat-icon class="mr-4 filter-icon">filter_alt</mat-icon>
|
||||
</button>
|
||||
|
|
|
@ -382,10 +382,15 @@ export class DescriptionListingComponent extends BaseListingComponent<BaseDescri
|
|||
lookup.tags = formGroup.get("tags")?.value ?? null;
|
||||
lookup.associatedDmpIds = formGroup.get("associatedDmpIds")?.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)
|
||||
?.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;
|
||||
}
|
||||
|
|
|
@ -167,7 +167,7 @@ export class DescriptionFilterComponent extends BaseCriteriaComponent implements
|
|||
};
|
||||
|
||||
getReferenceAutocompleteConfiguration(referenceTypeId: Guid, excludedIds: Reference[]): MultipleAutoCompleteConfiguration {
|
||||
let autocomplete = this.referenceService.getInternalMultipleAutoCompleteConfiguration(referenceTypeId, excludedIds);
|
||||
let autocomplete = this.referenceService.getMultipleAutoCompleteQueryConfiguration([referenceTypeId]);
|
||||
return autocomplete;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue