mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-19 17:14:57 +00:00
[MNT-24388] ADW Search request not sending all facet fields
This commit is contained in:
parent
3deb7e7690
commit
7a343896cc
@ -17,9 +17,9 @@
|
|||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { from, Observable } from 'rxjs';
|
import { from, Observable } from 'rxjs';
|
||||||
import { AlfrescoApiService } from '@alfresco/adf-core';
|
import {AlfrescoApiService, UserPreferencesService} from '@alfresco/adf-core';
|
||||||
import {
|
import {
|
||||||
Node,
|
Node, ResultSetPaging, SearchApi,
|
||||||
SiteBodyCreate,
|
SiteBodyCreate,
|
||||||
SiteEntry,
|
SiteEntry,
|
||||||
SiteGroupEntry,
|
SiteGroupEntry,
|
||||||
@ -38,12 +38,19 @@ import {
|
|||||||
})
|
})
|
||||||
export class SitesService {
|
export class SitesService {
|
||||||
private _sitesApi: SitesApi;
|
private _sitesApi: SitesApi;
|
||||||
|
private _searchApi: SearchApi;
|
||||||
|
|
||||||
get sitesApi(): SitesApi {
|
get sitesApi(): SitesApi {
|
||||||
this._sitesApi = this._sitesApi ?? new SitesApi(this.apiService.getInstance());
|
this._sitesApi = this._sitesApi ?? new SitesApi(this.apiService.getInstance());
|
||||||
return this._sitesApi;
|
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
|
* Create a site
|
||||||
@ -216,6 +223,32 @@ export class SitesService {
|
|||||||
return from(this.sitesApi.rejectSiteMembershipRequest(siteId, inviteeId, opts));
|
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
|
* List group membership for site
|
||||||
*
|
*
|
||||||
|
@ -26,11 +26,13 @@
|
|||||||
[attr.aria-label]="placeholder | translate"
|
[attr.aria-label]="placeholder | translate"
|
||||||
(matChipInputTokenEnd)="add($event)"
|
(matChipInputTokenEnd)="add($event)"
|
||||||
(blur)="activeAnyOption = false"
|
(blur)="activeAnyOption = false"
|
||||||
|
(focus)="activeAnyOption = true"
|
||||||
data-automation-id="adf-search-chip-autocomplete-input">
|
data-automation-id="adf-search-chip-autocomplete-input">
|
||||||
</mat-chip-list>
|
</mat-chip-list>
|
||||||
<mat-autocomplete #auto="matAutocomplete" (optionSelected)="selected($event)" id="adf-search-chip-autocomplete"
|
<mat-autocomplete #auto="matAutocomplete" (optionSelected)="selected($event)" id="adf-search-chip-autocomplete"
|
||||||
(optionActivated)="activeAnyOption = true" (closed)="activeAnyOption = false">
|
(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
|
<mat-option
|
||||||
[disabled]="option | adfIsIncluded: selectedOptions : compareOption"
|
[disabled]="option | adfIsIncluded: selectedOptions : compareOption"
|
||||||
*ngFor="let option of filteredOptions" [value]="option" [matTooltipShowDelay]="tooltipShowDelay"
|
*ngFor="let option of filteredOptions" [value]="option" [matTooltipShowDelay]="tooltipShowDelay"
|
||||||
@ -42,5 +44,17 @@
|
|||||||
{{ option.fullPath || option.value }}
|
{{ option.fullPath || option.value }}
|
||||||
</mat-option>
|
</mat-option>
|
||||||
</ng-container>
|
</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-autocomplete>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
@ -88,7 +88,13 @@ export class SearchChipAutocompleteInputComponent implements OnInit, OnDestroy,
|
|||||||
this._activeAnyOption = active;
|
this._activeAnyOption = active;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get activeAnyOption() {
|
||||||
|
return this._activeAnyOption;
|
||||||
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
this.filteredOptions = this.autocompleteOptions;
|
||||||
|
|
||||||
this.formCtrl.valueChanges
|
this.formCtrl.valueChanges
|
||||||
.pipe(
|
.pipe(
|
||||||
startWith(''),
|
startWith(''),
|
||||||
|
@ -24,6 +24,8 @@ import { SearchFilterList } from '../../models/search-filter-list.model';
|
|||||||
import { TagService } from '../../../tag/services/tag.service';
|
import { TagService } from '../../../tag/services/tag.service';
|
||||||
import { CategoryService } from '../../../category/services/category.service';
|
import { CategoryService } from '../../../category/services/category.service';
|
||||||
import { AutocompleteField, AutocompleteOption } from '../../models/autocomplete-option.interface';
|
import { AutocompleteField, AutocompleteOption } from '../../models/autocomplete-option.interface';
|
||||||
|
import {SitesService} from "../../../common";
|
||||||
|
import {ActivatedRoute} from "@angular/router";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'adf-search-filter-autocomplete-chips',
|
selector: 'adf-search-filter-autocomplete-chips',
|
||||||
@ -45,7 +47,7 @@ export class SearchFilterAutocompleteChipsComponent implements SearchWidget, OnI
|
|||||||
private autocompleteOptionsSubject$ = new BehaviorSubject<AutocompleteOption[]>([]);
|
private autocompleteOptionsSubject$ = new BehaviorSubject<AutocompleteOption[]>([]);
|
||||||
autocompleteOptions$: Observable<AutocompleteOption[]> = this.autocompleteOptionsSubject$.asObservable();
|
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[]>();
|
this.options = new SearchFilterList<AutocompleteOption[]>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,6 +59,11 @@ export class SearchFilterAutocompleteChipsComponent implements SearchWidget, OnI
|
|||||||
}
|
}
|
||||||
this.enableChangeUpdate = this.settings.allowUpdateOnChange ?? true;
|
this.enableChangeUpdate = this.settings.allowUpdateOnChange ?? true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.settings.field === AutocompleteField.SITE) {
|
||||||
|
console.log(this.route.snapshot.params)
|
||||||
|
this.searchForExistingLocations('*');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
reset() {
|
reset() {
|
||||||
@ -129,6 +136,9 @@ export class SearchFilterAutocompleteChipsComponent implements SearchWidget, OnI
|
|||||||
case AutocompleteField.CATEGORIES:
|
case AutocompleteField.CATEGORIES:
|
||||||
this.autocompleteOptionsSubject$.next([]);
|
this.autocompleteOptionsSubject$.next([]);
|
||||||
break;
|
break;
|
||||||
|
case AutocompleteField.SITE:
|
||||||
|
this.autocompleteOptionsSubject$.next(this.settings.autocompleteOptions);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
this.autocompleteOptionsSubject$.next(this.settings.autocompleteOptions);
|
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 {
|
export enum AutocompleteField {
|
||||||
TAG = 'TAG',
|
TAG = 'TAG',
|
||||||
CATEGORIES = 'cm:categories'
|
CATEGORIES = 'cm:categories',
|
||||||
|
SITE = 'SITE',
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user