Files
windmill/frontend/src/lib/components/apps/editor/contextPanel/SubGridOutput.svelte
T
Faton Ramadani c483d06e4d feat(frontend): Decision tree (#2812)
* feat(frontend): wip

* feat(frontend): wip

* feat(frontend): wip

* feat(frontend): wip

* feat(frontend): deicision tree v0

* feat(frontend): deicision tree v0

* feat(frontend): fix build

* feat(frontend): fix events

* feat(frontend): add branch

* feat(frontend): interactions done

* feat(frontend): fix graph display

* feat(frontend): fix rendering

* feat(frontend): add end props

* feat(frontend): working empty branches

* feat(frontend): code cleanup

* feat(frontend): code cleanup

* feat(frontend): fix subgrids sync

* feat(frontend): add missing events

* feat(frontend): clean up comments

* feat(frontend): fix inputValue key

* feat(frontend): clean up comments

* feat(frontend): compute first node

* feat(frontend): fix layout

* feat(frontend): fix actions

* feat(frontend): remove console.log

* feat(frontend): fix styling + add debug mode + use label in output panel

* feat(frontend): fix styling

* feat(frontend): fix styling

* feat(frontend): done

* feat(frontend): done

* feat(frontend): done

* feat(frontend): fix add

* feat(frontend): fix delete

* feat(frontend): minor fix

* feat(frontend): fix preivous buttons

* feat(frontend): Fix the eval preview

* feat(frontend): Remove log

* feat(frontend): fix wording

* feat(frontend): select the tab in the app editor when selecting the node
2023-12-15 15:19:59 +01:00

91 lines
2.2 KiB
Svelte

<script lang="ts">
import { classNames } from '$lib/utils'
import { getContext } from 'svelte'
import type { Output } from '../../rx'
import type { AppViewerContext } from '../../types'
import { connectInput } from '../appUtils'
import ComponentOutput from './ComponentOutput.svelte'
export let name: string | undefined = undefined
export let parentId: string
export let expanded: boolean = false
export let subGrids: string[]
export let nameOverrides: string[] | undefined = undefined
const { app, connectingInput, worldStore } = getContext<AppViewerContext>('AppViewerContext')
let selected = 0
$: outputs = $worldStore?.outputsById[parentId] as {
selectedTabIndex: Output<number>
}
$: subgridItems = subGrids.map((k) => ({
k,
items: $app.subgrids?.[k] ?? []
}))
$: if (outputs?.selectedTabIndex) {
subscribeToOutput()
}
function subscribeToOutput() {
outputs.selectedTabIndex.subscribe(
{
id: 'subgridoutput-' + parentId,
next: (value) => {
selected = value
}
},
selected
)
}
</script>
{#each subgridItems as { k, items }, index (k)}
<div class="ml-2 my-2">
{#if subGrids.length > 1}
<!-- svelte-ignore a11y-click-events-have-key-events -->
<div
class={classNames(
'px-1 py-0.5 flex justify-between items-center font-semibold text-xs border-l border-y w-full cursor-pointer',
selected === index ? 'bg-surface-selected' : 'bg-surface'
)}
on:click={() => {
selected = index
}}
>
<div class="text-xs">
{#if nameOverrides && nameOverrides[index]}
{#key nameOverrides[index]}
{nameOverrides[index]}
{/key}
{:else}
{name ? name : 'Should implement name'}
{index + 1}
{/if}
</div>
</div>
{/if}
{#if selected === index || name !== 'Tabs'}
<div class="border-l">
{#if items.length > 0}
{#each items as subGridItem, index (subGridItem.id)}
<ComponentOutput
gridItem={subGridItem}
first={index === 0}
{expanded}
on:select={({ detail }) => {
$connectingInput = connectInput($connectingInput, subGridItem.id, detail)
}}
/>
{/each}
{:else}
<div class="text-xs text-tertiary border-y border-l p-1">No components</div>
{/if}
</div>
{/if}
</div>
{/each}