Skip to content

Commit

Permalink
implement option to make components overridable with pattern_options
Browse files Browse the repository at this point in the history
  • Loading branch information
petschki committed Dec 4, 2024
1 parent 1594b8b commit bbbf59d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/pat/contentbrowser/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
export let recentlyUsedKey;
export let recentlyUsedMaxItems;
export let bSize = 20;
export let componentRegistryKeys = {};
const log = logger.getLogger("pat-contentbrowser");
Expand Down Expand Up @@ -83,6 +84,7 @@
recentlyUsedKey: recentlyUsedKey,
recentlyUsedMaxItems: recentlyUsedMaxItems,
pageSize: bSize,
componentRegistryKeys: componentRegistryKeys,
};
log.debug(`Initialized App<${fieldId}> with config ${JSON.stringify($config)}`);
Expand Down
8 changes: 6 additions & 2 deletions src/pat/contentbrowser/src/SelectedItems.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@
// showContentBrowser reactive state
const showContentBrowser = getContext("showContentBrowser");
// get selectedItem component from registry
const RegisteredSelectedItem = plone_registry.getComponent("pat-contentbrowser.SelectedItem");
// get selectedItem component from registry.
// the registry key can be customized with pattern_options
// if an addon registers a custom component to a custom key
const RegisteredSelectedItem = plone_registry.getComponent(
$config.componentRegistryKeys?.selectedItem || "pat-contentbrowser.SelectedItem"
);
onMount(async () => {
await initializeSelectedItemsStore();
Expand Down

0 comments on commit bbbf59d

Please sign in to comment.