handle query params in context

This commit is contained in:
Mads Rasmussen
2024-08-16 13:07:46 +02:00
parent b70682bc6b
commit 4b37fab3af

View File

@@ -26,12 +26,20 @@ export class UmbPickerContext<
*/
setConfig(config: ConfigType | undefined) {
const searchProviderAlias = config?.search?.providerAlias;
if (searchProviderAlias) {
this.search.updateConfig({ providerAlias: searchProviderAlias });
this.search.setSearchable(true);
} else {
this.search.setSearchable(false);
this.search.updateConfig({ providerAlias: searchProviderAlias });
const queryParams = config?.search?.queryParams;
if (queryParams) {
this.search.updateQuery(queryParams);
}
return;
}
this.search.setSearchable(false);
}
/**
@@ -42,4 +50,14 @@ export class UmbPickerContext<
getConfig(): ConfigType | undefined {
return this.#config.getValue();
}
/**
* Update the config for the picker
* @param {Partial<ConfigType>} config
* @memberof UmbPickerContext
*/
updateConfig(config: Partial<ConfigType>) {
const mergedConfig = { ...this.#config.getValue(), ...config } as ConfigType;
this.#config.setValue(mergedConfig);
}
}