wip: work on routing in automation tab

This commit is contained in:
Keviin Åberg Kultalahti 2021-03-15 12:53:44 +01:00
parent de56953d70
commit 4e85caa7b0
3 changed files with 31 additions and 3 deletions

View File

@ -9,6 +9,9 @@
onMount(() => { onMount(() => {
automationStore.actions.fetch() automationStore.actions.fetch()
}) })
function selectAutomation(automation) {
automationStore.actions.select(automation)
}
</script> </script>
<div class="automations-list"> <div class="automations-list">
@ -18,7 +21,7 @@
icon="ri-stackshare-line" icon="ri-stackshare-line"
text={automation.name} text={automation.name}
selected={automation._id === selectedAutomationId} selected={automation._id === selectedAutomationId}
on:click={() => automationStore.actions.select(automation)}> on:click={() => selectAutomation(automation)}>
<EditAutomationPopover {automation} /> <EditAutomationPopover {automation} />
</NavItem> </NavItem>
{/each} {/each}

View File

@ -1,6 +1,15 @@
<script> <script>
import { store } from "builderStore" import { automationStore } from "builderStore"
import { params } from "@sveltech/routify" import { params } from "@sveltech/routify"
store.actions.layouts.select($params.layout) if ($params.automation) {
const automation = $automationStore.automations.find(
m => m._id === $params.automation
)
if (automation) {
automationStore.actions.select(automation)
}
}
</script> </script>
<slot />

View File

@ -1,5 +1,21 @@
<script> <script>
import { onMount } from 'svelte'
import { automationStore } from "builderStore"
import AutomationBuilder from "components/automation/AutomationBuilder/AutomationBuilder.svelte" import AutomationBuilder from "components/automation/AutomationBuilder/AutomationBuilder.svelte"
onMount(async () => {
console.log('Automation Store: ', $automationStore)
console.log('Automation Store Methods: ', automationStore)
// navigate to first automation in list, if not already selected
// if (
// !$leftover &&
// $backendUiStore.tables.length > 0 &&
// (!$backendUiStore.selectedTable || !$backendUiStore.selectedTable._id)
// ) {
// // this file routes as .../tables/index, so, go up one.
// $goto(`../${$backendUiStore.tables[0]._id}`)
// }
})
</script> </script>
<AutomationBuilder /> <AutomationBuilder />