From 6e115df804f86c8fcdc992c015e103cec3450121 Mon Sep 17 00:00:00 2001 From: Michael Shanks Date: Mon, 10 Aug 2020 16:08:46 +0100 Subject: [PATCH] Moved events back into Settings & removed Events Panel --- .../ComponentPropertiesPanel.svelte | 4 - .../EventsEditor/EventEditorModal.svelte | 75 +++----- .../EventsEditor/EventPropertyControl.svelte | 39 +++++ .../EventsEditor/EventsEditor.svelte | 161 ------------------ .../userInterface/temporaryPanelStructure.js | 2 + 5 files changed, 67 insertions(+), 214 deletions(-) create mode 100644 packages/builder/src/components/userInterface/EventsEditor/EventPropertyControl.svelte delete mode 100644 packages/builder/src/components/userInterface/EventsEditor/EventsEditor.svelte diff --git a/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte b/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte index 3996add741..3b04e1b510 100644 --- a/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte +++ b/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte @@ -13,7 +13,6 @@ } from "components/common/Icons/" import CodeEditor from "./CodeEditor.svelte" import LayoutEditor from "./LayoutEditor.svelte" - import EventsEditor from "./EventsEditor" import panelStructure from "./temporaryPanelStructure.js" import CategoryTab from "./CategoryTab.svelte" import DesignView from "./DesignView.svelte" @@ -25,7 +24,6 @@ let categories = [ { value: "settings", name: "Settings" }, { value: "design", name: "Design" }, - { value: "events", name: "Events" }, ] let selectedCategory = categories[0] @@ -113,8 +111,6 @@ displayNameField={displayName} onChange={onPropChanged} screenOrPageInstance={$store.currentView !== 'component' && $store.currentPreviewItem} /> - {:else if selectedCategory.value === 'events'} - {/if} diff --git a/packages/builder/src/components/userInterface/EventsEditor/EventEditorModal.svelte b/packages/builder/src/components/userInterface/EventsEditor/EventEditorModal.svelte index 8132d502d1..3a16170043 100644 --- a/packages/builder/src/components/userInterface/EventsEditor/EventEditorModal.svelte +++ b/packages/builder/src/components/userInterface/EventsEditor/EventEditorModal.svelte @@ -10,28 +10,25 @@ import Input from "../../common/Input.svelte" import getIcon from "../../common/icon" import { CloseIcon } from "components/common/Icons/" - import { EVENT_TYPE_MEMBER_NAME } from "../../common/eventHandlers" - export let event - export let eventOptions = [] + export let event = [] + export let eventType export let onClose + export let onChange - let eventType = "" let draftEventHandler = { parameters: [] } - $: eventData = event || { handlers: [] } - $: if (!eventOptions.includes(eventType) && eventOptions.length > 0) - eventType = eventOptions[0].name + $: handlers = event || [] const closeModal = () => { onClose() draftEventHandler = { parameters: [] } - eventData = { handlers: [] } + handlers = [] } const updateEventHandler = (updatedHandler, index) => { - eventData.handlers[index] = updatedHandler + handlers[index] = updatedHandler } const updateDraftEventHandler = updatedHandler => { @@ -39,8 +36,7 @@ } const deleteEventHandler = index => { - eventData.handlers.splice(index, 1) - eventData = eventData + handlers.splice(index, 1) } const createNewEventHandler = handler => { @@ -48,17 +44,18 @@ parameters: {}, [EVENT_TYPE_MEMBER_NAME]: "", } - eventData.handlers.push(newHandler) - eventData = eventData + handlers.push(newHandler) + handlers = handlers } const deleteEvent = () => { - store.setComponentProp(eventType, []) + handlers = [] + onChange([]) closeModal() } const saveEventData = () => { - store.setComponentProp(eventType, eventData.handlers) + onChange(handlers) closeModal() } @@ -66,19 +63,7 @@
-

- {eventData.name ? `${eventData.name} Event` : 'Create a New Component Event'} -

-
-
-
-

Event Type

- -
+

{eventType} Event

@@ -92,31 +77,23 @@ }} handler={draftEventHandler} />
- {#if eventData} - {#each eventData.handlers as handler, index} - deleteEventHandler(index)} - {handler} /> - {/each} - {/if} + {#each handlers as handler, index} + deleteEventHandler(index)} + {handler} /> + {/each}