Skip to content

Commit

Permalink
some updates to registered component
Browse files Browse the repository at this point in the history
  • Loading branch information
petschki committed Nov 30, 2024
1 parent 10a5ba3 commit df91150
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 42 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@11ty/eleventy-upgrade-help": "2",
"@patternslib/pat-code-editor": "4.0.1",
"@patternslib/patternslib": "9.9.16",
"@plone/registry": "^1.7.0",
"@plone/registry": "^2.1.0",
"backbone": "1.4.1",
"backbone.paginator": "2.0.8",
"bootstrap": "5.3.3",
Expand Down Expand Up @@ -135,5 +135,6 @@
],
"publishConfig": {
"access": "public"
}
},
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}
16 changes: 5 additions & 11 deletions src/pat/contentbrowser/contentbrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,21 @@ import registry from "@patternslib/patternslib/src/core/registry";
import utils from "../../core/utils";
import plone_registry from "@plone/registry";

async function init_component_registry() {
// bug? set the component registry as empty dict the first time
// otherwise you get the error: "this._data.components is undefined"
if (plone_registry["components"] === undefined) {
// see @plone/registry
plone_registry["components"] = {};
}

if (plone_registry.getComponent("SelectedItem").component === undefined) {
async function setup_default_component_registry() {
if (plone_registry.getComponent("pat-contentbrowser.SelectedItem").component === undefined) {
const SelectedItem = (await import("./src/SelectedItem.svelte")).default;
plone_registry.registerComponent({
name: "SelectedItem",
name: "pat-contentbrowser.SelectedItem",
component: SelectedItem,
});
console.log("Loaded default 'SelectedItem' Component");
}
}

// register default components in @plone/registry
// here outside the pattern init() so that addons can override this
// when their bundle depends on the "plone" bundle
init_component_registry()
setup_default_component_registry()

// Contentbrowser pattern

Expand Down
12 changes: 6 additions & 6 deletions src/pat/contentbrowser/src/SelectedItems.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script>
import { getContext, onMount, setContext } from "svelte";
import { get_items_from_uids, resolveIcon } from "./utils.js";
import { get_items_from_uids } from "./utils.js";
import Sortable from "sortablejs";
import _t from "../../../core/i18n-wrapper";
import events from "@patternslib/patternslib/src/core/events";
Expand All @@ -9,10 +9,6 @@
let ref;
let initializing = true;
// get registered SelectedItem component
const SelectedItemComponent = plone_registry.getComponent("SelectedItem");
console.log(SelectedItemComponent);
// get reactive context config
const config = getContext("config");
const fieldId = $config.fieldId;
Expand All @@ -25,6 +21,10 @@
// showContentBrowser reactive state
const showContentBrowser = getContext("showContentBrowser");
// get selectedItem component from registry
const RegisteredSelectedItem = plone_registry.getComponent("pat-contentbrowser.SelectedItem");
console.log(RegisteredSelectedItem);
onMount(async () => {
await initializeSelectedItemsStore();
initializeSorting();
Expand Down Expand Up @@ -113,7 +113,7 @@
on:click={() => $showContentBrowser = $selectedItems.length ? false : true }>
{#if $selectedItems}
{#each $selectedItems as selItem, i (selItem.UID)}
<svelte:component this={SelectedItemComponent.component} idx={i} item={selItem} />
<svelte:component this={RegisteredSelectedItem.component} idx={i} item={selItem} />
{/each}
{/if}
{#if !$selectedItems}
Expand Down
97 changes: 74 additions & 23 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1877,15 +1877,17 @@
resolved "https://registry.yarnpkg.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz#a77ea742fab25775145434eb1d2328cf5013ac33"
integrity sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==

"@plone/registry@^1.7.0":
version "1.8.0"
resolved "https://registry.yarnpkg.com/@plone/registry/-/registry-1.8.0.tgz#076770a4af69503fd260f21c6e063f0f4ff939f9"
integrity sha512-xQH7vhnzQpxPxZLZtObpN/jv4JOIBhYEKsdWUCYmL1e8wlbxb+Xk2C6qNK9+i+kyjmLdAUzDH0v5Xl9Y7igxKw==
"@plone/registry@^2.1.0":
version "2.1.2"
resolved "https://registry.yarnpkg.com/@plone/registry/-/registry-2.1.2.tgz#b00821676c05279fdc54d90c01163eebe4ea6b17"
integrity sha512-axmsDNF+p5q2P/9j3v0is1P967MTSkAF2yl2gaYWbwnpPB8rfNVnTzw3HQa6o09qyt20wR8b4aUVlvlWXpi2Zw==
dependencies:
auto-config-loader "^1.7.7"
crypto-random-string "3.2.0"
debug "4.3.2"
dependency-graph "0.10.0"
glob "7.1.6"
glob "^10.4.5"
tmp "0.2.1"

"@pnpm/config.env-replace@^1.1.0":
version "1.1.0"
Expand Down Expand Up @@ -2606,6 +2608,11 @@ acorn@^8.0.4, acorn@^8.1.0, acorn@^8.10.0, acorn@^8.11.0, acorn@^8.7.1, acorn@^8
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.13.0.tgz#2a30d670818ad16ddd6a35d3842dacec9e5d7ca3"
integrity sha512-8zSiw54Oxrdym50NlZ9sUusyO1Z1ZchgRLWRaK6c86XJFClyCgFKetdowBg5bKxyp/u+CDBJG4Mpp0m3HLZl9w==

acorn@^8.5.0:
version "8.14.0"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.14.0.tgz#063e2c70cac5fb4f6467f0b11152e04c682795b0"
integrity sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA==

add-stream@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/add-stream/-/add-stream-1.0.0.tgz#6a7990437ca736d5e1288db92bd3266d5f5cb2aa"
Expand Down Expand Up @@ -2856,6 +2863,19 @@ atomically@^2.0.3:
stubborn-fs "^1.2.5"
when-exit "^2.1.1"

auto-config-loader@^1.7.7:
version "1.7.8"
resolved "https://registry.yarnpkg.com/auto-config-loader/-/auto-config-loader-1.7.8.tgz#03607f41eb8a4731693289ebb7a3f245ea16557e"
integrity sha512-mK8yQmJJy369cz0x2LJwhKD72tkTObBwhgR+3U8Ts8+wCSspED3ydXlWpsv1ZQ9g2iq4b+7EWli+ap2nTeUQog==
dependencies:
ini "^5.0.0"
jiti "^1.18.2"
jsonc-eslint-parser "^2.3.0"
lodash.merge "^4.6.2"
sucrase "^3.32.0"
toml-eslint-parser "^0.10.0"
yaml-eslint-parser "^1.2.2"

axobject-query@^4.0.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/axobject-query/-/axobject-query-4.1.0.tgz#28768c76d0e3cff21bc62a9e2d0b6ac30042a1ee"
Expand Down Expand Up @@ -4432,7 +4452,7 @@ eslint-visitor-keys@^2.1.0:
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz#f65328259305927392c938ed44eb0a5c9b2bd303"
integrity sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==

eslint-visitor-keys@^3.3.0, eslint-visitor-keys@^3.4.1, eslint-visitor-keys@^3.4.3:
eslint-visitor-keys@^3.0.0, eslint-visitor-keys@^3.3.0, eslint-visitor-keys@^3.4.1, eslint-visitor-keys@^3.4.3:
version "3.4.3"
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz#0cd72fe8550e3c2eae156a96a4dddcd1c8ac5800"
integrity sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==
Expand Down Expand Up @@ -4481,7 +4501,7 @@ eslint@^8.57.0:
strip-ansi "^6.0.1"
text-table "^0.2.0"

espree@^9.6.0, espree@^9.6.1:
espree@^9.0.0, espree@^9.6.0, espree@^9.6.1:
version "9.6.1"
resolved "https://registry.yarnpkg.com/espree/-/espree-9.6.1.tgz#a2a17b8e434690a5432f2f8018ce71d331a48c6f"
integrity sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==
Expand Down Expand Up @@ -4996,19 +5016,7 @@ glob-to-regexp@^0.4.1:
resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz#c75297087c851b9a578bd217dd59a92f59fe546e"
integrity sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==

[email protected]:
version "7.1.6"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6"
integrity sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==
dependencies:
fs.realpath "^1.0.0"
inflight "^1.0.4"
inherits "2"
minimatch "^3.0.4"
once "^1.3.0"
path-is-absolute "^1.0.0"

glob@^10.3.10:
glob@^10.3.10, glob@^10.4.5:
version "10.4.5"
resolved "https://registry.yarnpkg.com/glob/-/glob-10.4.5.tgz#f4d9f0b90ffdbab09c9d77f5f29b4262517b0956"
integrity sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==
Expand Down Expand Up @@ -5465,6 +5473,11 @@ ini@^1.3.4, ini@~1.3.0:
resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.8.tgz#a29da425b48806f34767a4efce397269af28432c"
integrity sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==

ini@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/ini/-/ini-5.0.0.tgz#a7a4615339843d9a8ccc2d85c9d81cf93ffbc638"
integrity sha512-+N0ngpO3e7cRUWOJAS7qw0IZIVc6XPrW4MlFBdD066F2L4k1L6ker3hLqSq7iXxU5tgS4WGkIUElWn5vogAEnw==

[email protected]:
version "9.3.2"
resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-9.3.2.tgz#9bc5ced19f572e848044baa05094a498f1e448c6"
Expand Down Expand Up @@ -6260,7 +6273,7 @@ jest@^29.7.0:
import-local "^3.0.2"
jest-cli "^29.7.0"

jiti@^1.21.6:
jiti@^1.18.2, jiti@^1.21.6:
version "1.21.6"
resolved "https://registry.yarnpkg.com/jiti/-/jiti-1.21.6.tgz#6c7f7398dd4b3142767f9a168af2f317a428d268"
integrity sha512-2yTgeWTWzMWkHu6Jp9NKgePDaYHbntiwvYuuJLbbN9vl7DC9DvXKOB2BC3ZZ92D3cvV/aflH0osDfwpHepQ53w==
Expand Down Expand Up @@ -6421,6 +6434,16 @@ json5@^2.1.2, json5@^2.2.3:
resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283"
integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==

jsonc-eslint-parser@^2.3.0:
version "2.4.0"
resolved "https://registry.yarnpkg.com/jsonc-eslint-parser/-/jsonc-eslint-parser-2.4.0.tgz#74ded53f9d716e8d0671bd167bf5391f452d5461"
integrity sha512-WYDyuc/uFcGp6YtM2H0uKmUwieOuzeE/5YocFJLnLfclZ4inf3mRn8ZVy1s7Hxji7Jxm6Ss8gqpexD/GlKoGgg==
dependencies:
acorn "^8.5.0"
eslint-visitor-keys "^3.0.0"
espree "^9.0.0"
semver "^7.3.5"

jsonfile@^6.0.1:
version "6.1.0"
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-6.1.0.tgz#bc55b2634793c679ec6403094eb13698a6ec0aae"
Expand Down Expand Up @@ -8263,7 +8286,7 @@ rimraf@^2.7.1:
dependencies:
glob "^7.1.3"

rimraf@^3.0.2:
rimraf@^3.0.0, rimraf@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a"
integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==
Expand Down Expand Up @@ -8939,7 +8962,7 @@ style-loader@^4.0.0:
resolved "https://registry.yarnpkg.com/style-loader/-/style-loader-4.0.0.tgz#0ea96e468f43c69600011e0589cb05c44f3b17a5"
integrity sha512-1V4WqhhZZgjVAVJyt7TdDPZoPBPNHbekX4fWnCJL1yQukhCeZhJySUL+gL9y6sNdN95uEOS83Y55SqHcP7MzLA==

sucrase@^3.20.0:
sucrase@^3.20.0, sucrase@^3.32.0:
version "3.35.0"
resolved "https://registry.yarnpkg.com/sucrase/-/sucrase-3.35.0.tgz#57f17a3d7e19b36d8995f06679d121be914ae263"
integrity sha512-8EbVDiu9iN/nESwxeSxDKe0dunta1GOlHufmSSXxMD2z2/tMZpDMpvXQGsc+ajGo8y2uYUmixaSRUc/QPoQ0GA==
Expand Down Expand Up @@ -9149,6 +9172,13 @@ tippy.js@^6.3.7:
dependencies:
"@popperjs/core" "^2.9.0"

[email protected]:
version "0.2.1"
resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.2.1.tgz#8457fc3037dcf4719c251367a1af6500ee1ccf14"
integrity sha512-76SUhtfqR2Ijn+xllcI5P1oyannHNHByD80W1q447gU3mp9G9PSpGdWmjUOHRDPiHYacIk66W7ubDTuPF3BEtQ==
dependencies:
rimraf "^3.0.0"

tmp@^0.0.33:
version "0.0.33"
resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9"
Expand Down Expand Up @@ -9178,6 +9208,13 @@ [email protected]:
resolved "https://registry.yarnpkg.com/token-stream/-/token-stream-1.0.0.tgz#cc200eab2613f4166d27ff9afc7ca56d49df6eb4"
integrity sha512-VSsyNPPW74RpHwR8Fc21uubwHY7wMDeJLys2IX5zJNih+OnAnaifKHo+1LHT7DAdloQ7apeaaWg8l7qnf/TnEg==

toml-eslint-parser@^0.10.0:
version "0.10.0"
resolved "https://registry.yarnpkg.com/toml-eslint-parser/-/toml-eslint-parser-0.10.0.tgz#52000b150a8b298feefeea701c29cca8b4730a38"
integrity sha512-khrZo4buq4qVmsGzS5yQjKe/WsFvV8fGfOjDQN0q4iy9FjRfPWRgTFrU8u1R2iu/SfWLhY9WnCi4Jhdrcbtg+g==
dependencies:
eslint-visitor-keys "^3.0.0"

totalist@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/totalist/-/totalist-3.0.1.tgz#ba3a3d600c915b1a97872348f79c127475f6acf8"
Expand Down Expand Up @@ -9838,6 +9875,20 @@ yallist@^4.0.0:
resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72"
integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==

yaml-eslint-parser@^1.2.2:
version "1.2.3"
resolved "https://registry.yarnpkg.com/yaml-eslint-parser/-/yaml-eslint-parser-1.2.3.tgz#3a8ae839fc8df376ef8497add7f40942b493389c"
integrity sha512-4wZWvE398hCP7O8n3nXKu/vdq1HcH01ixYlCREaJL5NUMwQ0g3MaGFUBNSlmBtKmhbtVG/Cm6lyYmSVTEVil8A==
dependencies:
eslint-visitor-keys "^3.0.0"
lodash "^4.17.21"
yaml "^2.0.0"

yaml@^2.0.0:
version "2.6.1"
resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.6.1.tgz#42f2b1ba89203f374609572d5349fb8686500773"
integrity sha512-7r0XPzioN/Q9kXBro/XPnA6kznR73DHq+GXh5ON7ZozRO6aMjbmiBuKste2wslTFkC5d1dw0GooOCepZXJ2SAg==

[email protected], yargs-parser@^21.1.1:
version "21.1.1"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.1.1.tgz#9096bceebf990d21bb31fa9516e0ede294a77d35"
Expand Down

0 comments on commit df91150

Please sign in to comment.