Bugfix: Scoped Content Picker Search (#17481)
* add searchFrom to request args type * add search from to picker search manager config * pass startNode to config * get default setting from config * pass to server * remove unused import
This commit is contained in:
@@ -184,7 +184,12 @@ export class UmbPickerSearchManager<
|
||||
return;
|
||||
}
|
||||
|
||||
const { data } = await this.#searchProvider.search(query);
|
||||
const args = {
|
||||
searchFrom: this.#config?.searchFrom,
|
||||
...query,
|
||||
};
|
||||
|
||||
const { data } = await this.#searchProvider.search(args);
|
||||
const items = (data?.items as ResultItemType[]) ?? [];
|
||||
this.#resultItems.setValue(items);
|
||||
this.#resultTotalItems.setValue(data?.total ?? 0);
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import type { UmbEntityModel } from '@umbraco-cms/backoffice/entity';
|
||||
|
||||
export interface UmbPickerSearchManagerConfig {
|
||||
providerAlias: string;
|
||||
searchFrom?: UmbEntityModel;
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ export class UmbTreePickerModalElement<TreeItemType extends UmbTreeItemModelBase
|
||||
|
||||
if (_changedProperties.has('data')) {
|
||||
if (this.data?.search) {
|
||||
this.#pickerContext.search.updateConfig({ ...this.data?.search });
|
||||
this.#pickerContext.search.updateConfig({ ...this.data?.search, searchFrom: this.data?.startNode });
|
||||
}
|
||||
|
||||
const multiple = this.data?.multiple ?? false;
|
||||
|
||||
@@ -33,6 +33,7 @@ export class UmbDocumentSearchServerDataSource implements UmbSearchDataSource<Um
|
||||
this.#host,
|
||||
DocumentService.getItemDocumentSearch({
|
||||
query: args.query,
|
||||
parentId: args.searchFrom?.unique ?? undefined,
|
||||
}),
|
||||
);
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { UmbEntityModel } from '@umbraco-cms/backoffice/entity';
|
||||
import type { UmbApi } from '@umbraco-cms/backoffice/extension-api';
|
||||
import type { UmbPagedModel, UmbRepositoryResponse } from '@umbraco-cms/backoffice/repository';
|
||||
|
||||
@@ -12,6 +13,7 @@ export type UmbSearchResultItemModel = {
|
||||
|
||||
export type UmbSearchRequestArgs = {
|
||||
query: string;
|
||||
searchFrom?: UmbEntityModel;
|
||||
};
|
||||
|
||||
export interface UmbSearchProvider<
|
||||
|
||||
Reference in New Issue
Block a user