[MNT-24388] ADW Search request not sending all facet fields

This commit is contained in:
Jacek Pluta 2024-06-19 10:21:24 +02:00
parent 3deb7e7690
commit 7a343896cc
5 changed files with 80 additions and 6 deletions
lib/content-services/src/lib

@ -17,9 +17,9 @@
import { Injectable } from '@angular/core';
import { from, Observable } from 'rxjs';
import { AlfrescoApiService } from '@alfresco/adf-core';
import {AlfrescoApiService, UserPreferencesService} from '@alfresco/adf-core';
import {
Node,
Node, ResultSetPaging, SearchApi,
SiteBodyCreate,
SiteEntry,
SiteGroupEntry,
@ -38,12 +38,19 @@ import {
})
export class SitesService {
private _sitesApi: SitesApi;
private _searchApi: SearchApi;
get sitesApi(): SitesApi {
this._sitesApi = this._sitesApi ?? new SitesApi(this.apiService.getInstance());
return this._sitesApi;
}
constructor(private apiService: AlfrescoApiService) {}
get searchApi(): SearchApi {
this._searchApi = this._searchApi ?? new SearchApi(this.apiService.getInstance());
return this._searchApi;
}
constructor(private apiService: AlfrescoApiService, private userPreferencesService: UserPreferencesService) {}
/**
* Create a site
@ -216,6 +223,32 @@ export class SitesService {
return from(this.sitesApi.rejectSiteMembershipRequest(siteId, inviteeId, opts));
}
/**
* Searches sites by their name.
*
* @param name Value for name which should be used during searching categories.
* @param skipCount Specify how many first results should be skipped. Default 0.
* @param maxItems Specify max number of returned categories. Default is specified by UserPreferencesService.
* @returns Observable<ResultSetPaging> Found categories which name contains searched name.
*/
searchSite(name: string, skipCount = 0, maxItems?: number): Observable<ResultSetPaging> {
maxItems = maxItems || this.userPreferencesService.paginationSize;
console.log(name)
return from(
this.searchApi.search({
query: {
language: 'afts',
query: `*`
},
paging: {
skipCount,
maxItems
},
include: ['path']
})
);
}
/**
* List group membership for site
*

@ -26,11 +26,13 @@
[attr.aria-label]="placeholder | translate"
(matChipInputTokenEnd)="add($event)"
(blur)="activeAnyOption = false"
(focus)="activeAnyOption = true"
data-automation-id="adf-search-chip-autocomplete-input">
</mat-chip-list>
<mat-autocomplete #auto="matAutocomplete" (optionSelected)="selected($event)" id="adf-search-chip-autocomplete"
(optionActivated)="activeAnyOption = true" (closed)="activeAnyOption = false">
<ng-container *ngIf="optionInput.value.length > 0">
<ng-container *ngIf="optionInput.value.length > 0 || filteredOptions?.length > 0 && activeAnyOption">
<mat-option
[disabled]="option | adfIsIncluded: selectedOptions : compareOption"
*ngFor="let option of filteredOptions" [value]="option" [matTooltipShowDelay]="tooltipShowDelay"
@ -42,5 +44,17 @@
{{ option.fullPath || option.value }}
</mat-option>
</ng-container>
<!-- <ng-container *ngIf="optionInput.value.length > 0">-->
<!-- <mat-option-->
<!-- [disabled]="option | adfIsIncluded: selectedOptions : compareOption"-->
<!-- *ngFor="let option of filteredOptions" [value]="option" [matTooltipShowDelay]="tooltipShowDelay"-->
<!-- [matTooltipDisabled]="!option.fullPath" matTooltipPosition="right"-->
<!-- [attr.data-automation-id]="'option-' + (option.value)"-->
<!-- [matTooltip]="'SEARCH.RESULTS.WILL_CONTAIN' | translate:{searchTerm: option.fullPath || option.value}"-->
<!-- class="adf-search-chip-autocomplete-added-option"-->
<!-- [ngClass]="(option | adfIsIncluded: selectedOptions : compareOption) && 'adf-autocomplete-added-option'">-->
<!-- {{ option.fullPath || option.value }}-->
<!-- </mat-option>-->
<!-- </ng-container>-->
</mat-autocomplete>
</mat-form-field>

@ -88,7 +88,13 @@ export class SearchChipAutocompleteInputComponent implements OnInit, OnDestroy,
this._activeAnyOption = active;
}
get activeAnyOption() {
return this._activeAnyOption;
}
ngOnInit() {
this.filteredOptions = this.autocompleteOptions;
this.formCtrl.valueChanges
.pipe(
startWith(''),

@ -24,6 +24,8 @@ import { SearchFilterList } from '../../models/search-filter-list.model';
import { TagService } from '../../../tag/services/tag.service';
import { CategoryService } from '../../../category/services/category.service';
import { AutocompleteField, AutocompleteOption } from '../../models/autocomplete-option.interface';
import {SitesService} from "../../../common";
import {ActivatedRoute} from "@angular/router";
@Component({
selector: 'adf-search-filter-autocomplete-chips',
@ -45,7 +47,7 @@ export class SearchFilterAutocompleteChipsComponent implements SearchWidget, OnI
private autocompleteOptionsSubject$ = new BehaviorSubject<AutocompleteOption[]>([]);
autocompleteOptions$: Observable<AutocompleteOption[]> = this.autocompleteOptionsSubject$.asObservable();
constructor(private tagService: TagService, private categoryService: CategoryService) {
constructor(private tagService: TagService, private categoryService: CategoryService, private sitesService: SitesService, private route: ActivatedRoute) {
this.options = new SearchFilterList<AutocompleteOption[]>();
}
@ -57,6 +59,11 @@ export class SearchFilterAutocompleteChipsComponent implements SearchWidget, OnI
}
this.enableChangeUpdate = this.settings.allowUpdateOnChange ?? true;
}
if (this.settings.field === AutocompleteField.SITE) {
console.log(this.route.snapshot.params)
this.searchForExistingLocations('*');
}
}
reset() {
@ -129,6 +136,9 @@ export class SearchFilterAutocompleteChipsComponent implements SearchWidget, OnI
case AutocompleteField.CATEGORIES:
this.autocompleteOptionsSubject$.next([]);
break;
case AutocompleteField.SITE:
this.autocompleteOptionsSubject$.next(this.settings.autocompleteOptions);
break;
default:
this.autocompleteOptionsSubject$.next(this.settings.autocompleteOptions);
}
@ -143,4 +153,14 @@ export class SearchFilterAutocompleteChipsComponent implements SearchWidget, OnI
}));
});
}
private searchForExistingLocations(searchTerm: string) {
this.sitesService.searchSite(searchTerm, 0, 15).subscribe((existingSiteResult) => {
console.log(existingSiteResult.list.entries.map((rowEntry) => {
const path = rowEntry.entry.path.name;
const fullPath = path ? `${path}/${rowEntry.entry.name}` : rowEntry.entry.name;
return fullPath;
}))
});
}
}

@ -24,5 +24,6 @@ export interface AutocompleteOption {
export enum AutocompleteField {
TAG = 'TAG',
CATEGORIES = 'cm:categories'
CATEGORIES = 'cm:categories',
SITE = 'SITE',
}