From 2892259fab2c16b3d3c718ad78bc6d9b430cb2a3 Mon Sep 17 00:00:00 2001 From: kevmodrome Date: Fri, 17 Apr 2020 11:33:27 +0200 Subject: [PATCH] removes stuff from SelectionList component. --- .../ComponentSelectionList.svelte | 137 ------------------ 1 file changed, 137 deletions(-) diff --git a/packages/builder/src/components/userInterface/ComponentSelectionList.svelte b/packages/builder/src/components/userInterface/ComponentSelectionList.svelte index 714aa66532..d1958d3d3f 100644 --- a/packages/builder/src/components/userInterface/ComponentSelectionList.svelte +++ b/packages/builder/src/components/userInterface/ComponentSelectionList.svelte @@ -3,122 +3,8 @@ import components from "./temporaryPanelStructure.js" import Tab from "./ComponentTab/Tab.svelte" - import { splitName } from "./pagesParsing/splitRootComponentName.js" - import { store } from "builderStore" - import { - find, - sortBy, - groupBy, - values, - filter, - map, - uniqBy, - flatten, - } from "lodash/fp" - import { ImageIcon, InputIcon, LayoutIcon } from "components/common/Icons/" - import Select from "components/common/Select.svelte" - import Button from "components/common/PlusButton.svelte" - import ConfirmDialog from "components/common/ConfirmDialog.svelte" - import { - getRecordNodes, - getIndexNodes, - getIndexSchema, - pipe, - } from "components/common/core" - - export let toggleTab - const categories = components.categories let selectedCategory = categories[0] - - let componentLibraries = [] - let current_view = "text" - let selectedComponent = null - let selectedLib - let selectTemplateDialog - let templateInstances = [] - let selectedTemplateInstance - - $: templatesByComponent = groupBy(t => t.component)($store.templates) - $: hierarchy = $store.hierarchy - $: libraryModules = $store.libraries - $: standaloneTemplates = pipe(templatesByComponent, [ - values, - flatten, - filter(t => !$store.components.some(c => c.name === t.component)), - map(t => ({ name: splitName(t.component).componentName, template: t })), - uniqBy(t => t.name), - ]) - - const addRootComponent = (component, allComponents) => { - const { libName } = splitName(component.name) - let group = find(r => r.libName === libName)(allComponents) - - if (!group) { - group = { - libName, - components: [], - } - - allComponents.push(group) - } - - group.components.push(component) - } - - const onComponentChosen = component => { - if (component.template) { - onTemplateChosen(component.template) - } else { - store.addChildComponent(component.name) - toggleTab() - } - } - - const onTemplateChosen = template => { - selectedComponent = null - const { componentName, libName } = splitName(template.name) - const templateOptions = { - records: getRecordNodes(hierarchy), - indexes: getIndexNodes(hierarchy), - helpers: { - indexSchema: getIndexSchema(hierarchy), - }, - } - templateInstances = libraryModules[libName][componentName](templateOptions) - if (!templateInstances || templateInstances.length === 0) return - selectedTemplateInstance = templateInstances[0].name - selectTemplateDialog.show() - } - - const onTemplateInstanceChosen = () => { - selectedComponent = null - const instance = templateInstances.find( - i => i.name === selectedTemplateInstance - ) - store.addTemplatedComponent(instance.props) - toggleTab() - } - - function generate_components_list(components) { - return ($store.currentFrontEndType === "page" - ? $store.builtins.concat(components) - : components - ).concat(standaloneTemplates) - } - - $: { - const newComponentLibraries = [] - - for (let comp of sortBy(["name"])($store.components)) { - addRootComponent(comp, newComponentLibraries) - } - - componentLibraries = newComponentLibraries - if (!selectedLib) selectedLib = newComponentLibraries[0].libName - } - - $: componentLibrary = componentLibraries.find(l => l.libName === selectedLib)
@@ -136,25 +22,6 @@
- (selectedComponent = null)} - onOk={onTemplateInstanceChosen}> - {#each templateInstances.map(i => i.name) as instance} -
- -
- {/each} -
-