diff --git a/svelte-kit/package-lock.json b/svelte-kit/package-lock.json index 974b50f3a..3f3622f33 100644 --- a/svelte-kit/package-lock.json +++ b/svelte-kit/package-lock.json @@ -13,7 +13,7 @@ "mongodb": "^4.12.1", "sass": "^1.56.1", "svelte": "^3.44.0", - "svelte-helpers": "^0.2.10" + "svelte-helpers": "^0.2.12" }, "devDependencies": { "@sveltejs/adapter-auto": "next", @@ -2678,9 +2678,9 @@ } }, "node_modules/svelte-helpers": { - "version": "0.2.10", - "resolved": "https://registry.npmjs.org/svelte-helpers/-/svelte-helpers-0.2.10.tgz", - "integrity": "sha512-jzlXCE561kuoehhapLVimFh8Px0Y0Ml7gwg+EuSheyHstuoGTr8RYA9Ar6SD+11M1Td8BSJpkKdjTdw7QN/OsQ==", + "version": "0.2.12", + "resolved": "https://registry.npmjs.org/svelte-helpers/-/svelte-helpers-0.2.12.tgz", + "integrity": "sha512-SyPU9XdCZYWpqrYBzTul+GYAIWIFw+1MgOblajpfib9s2e9ojAjI1t2D5gdJToeFsAb3iT3/yeXcBbY0AmUI/A==", "dependencies": { "@sveltejs/vite-plugin-svelte": "^1.0.0-next.30", "@xstate/fsm": "^1.6.0", @@ -5254,9 +5254,9 @@ } }, "svelte-helpers": { - "version": "0.2.10", - "resolved": "https://registry.npmjs.org/svelte-helpers/-/svelte-helpers-0.2.10.tgz", - "integrity": "sha512-jzlXCE561kuoehhapLVimFh8Px0Y0Ml7gwg+EuSheyHstuoGTr8RYA9Ar6SD+11M1Td8BSJpkKdjTdw7QN/OsQ==", + "version": "0.2.12", + "resolved": "https://registry.npmjs.org/svelte-helpers/-/svelte-helpers-0.2.12.tgz", + "integrity": "sha512-SyPU9XdCZYWpqrYBzTul+GYAIWIFw+1MgOblajpfib9s2e9ojAjI1t2D5gdJToeFsAb3iT3/yeXcBbY0AmUI/A==", "requires": { "@sveltejs/vite-plugin-svelte": "^1.0.0-next.30", "@xstate/fsm": "^1.6.0", diff --git a/svelte-kit/package.json b/svelte-kit/package.json index e23f683fb..b1e9227c1 100644 --- a/svelte-kit/package.json +++ b/svelte-kit/package.json @@ -28,6 +28,6 @@ "classnames": "^2.3.2", "mongodb": "^4.12.1", "sass": "^1.56.1", - "svelte-helpers": "^0.2.10" + "svelte-helpers": "^0.2.12" } } diff --git a/svelte-kit/src/lib/components/subjectsAndTags/GenericLabelSelect.svelte b/svelte-kit/src/lib/components/subjectsAndTags/GenericLabelSelect.svelte index 7d1c9cc23..a7e78117f 100644 --- a/svelte-kit/src/lib/components/subjectsAndTags/GenericLabelSelect.svelte +++ b/svelte-kit/src/lib/components/subjectsAndTags/GenericLabelSelect.svelte @@ -7,12 +7,23 @@ export let inputProps = {}; export let search = ""; export let onItemSelected: (option: any, inputEl: HTMLInputElement) => void; + export let noFiltering = false; let inputStyles = "width: 100px; border-top-width: 0; border-right-width: 0; border-left-width: 0; border-radius: 0;";
- + diff --git a/svelte-kit/src/lib/components/subjectsAndTags/subjects/SelectAvailableSubjects.svelte b/svelte-kit/src/lib/components/subjectsAndTags/subjects/SelectAvailableSubjects.svelte index 5d004d452..72465727f 100644 --- a/svelte-kit/src/lib/components/subjectsAndTags/subjects/SelectAvailableSubjects.svelte +++ b/svelte-kit/src/lib/components/subjectsAndTags/subjects/SelectAvailableSubjects.svelte @@ -1,10 +1,9 @@ - + diff --git a/svelte-kit/src/lib/state/subjectsState.ts b/svelte-kit/src/lib/state/subjectsState.ts index 5e737fb69..3592e127c 100644 --- a/svelte-kit/src/lib/state/subjectsState.ts +++ b/svelte-kit/src/lib/state/subjectsState.ts @@ -51,7 +51,7 @@ export const filterSubjects = (subjects: Subject[], search?: string, lookupMap: let regex = new RegExp(search, "i"); searchFn = s => regex.test(s.name) && !alreadySelected[s._id]; } - const selectedLookup: Set = new Set([]); + const forcedLookup: Set = new Set([]); return subjects.reduce((result, s) => { if (searchFn(s)) { const entry: DisablableSubject = { ...s, disabled: false }; @@ -61,18 +61,17 @@ export const filterSubjects = (subjects: Subject[], search?: string, lookupMap: let parentId; while ((parentId = computeParentId(currentSubject.path))) { - if (!parentId || selectedLookup.has(parentId)) { - break; - } - let parent = lookupMap[parentId]; - if (!parent) { + const parent = lookupMap[parentId]; + + if (!parent || forcedLookup.has(parentId)) { break; } - let parentEntry: DisablableSubject = { ...parent, disabled: false }; + + const parentEntry: DisablableSubject = { ...parent, disabled: false }; if (alreadySelected[parent._id] || !searchFn(parent)) { toAdd.unshift(parentEntry); - selectedLookup.add(parentId); + forcedLookup.add(parentId); if (alreadySelected[parent._id]) { parentEntry.disabled = true;