fix table action input fields

This commit is contained in:
Ruben Fiszel
2023-03-20 16:04:50 +01:00
parent 0f64859961
commit be1d987b41
6 changed files with 49 additions and 9 deletions

View File

@@ -26,11 +26,13 @@
export let customCss: ComponentCustomCSS<'buttoncomponent'> | undefined = undefined
export let render: boolean
export let initializing: boolean | undefined = true
export let extraKey: string | undefined = undefined
export let controls: { left: () => boolean; right: () => boolean | string } | undefined =
undefined
const { worldStore, app, componentControl } = getContext<AppViewerContext>('AppViewerContext')
const { worldStore, app, componentControl, selectedComponent } =
getContext<AppViewerContext>('AppViewerContext')
let outputs = initOutput($worldStore, id, {
result: undefined,
@@ -94,6 +96,8 @@
event?.stopPropagation()
event?.preventDefault()
$selectedComponent = id
if (preclickAction) {
await preclickAction()
}
@@ -115,7 +119,12 @@
</script>
{#each configurationKeys['buttoncomponent'] as key (key)}
<InputValue {key} {id} input={configuration[key]} bind:value={resolvedConfig[key]} />
<InputValue
key={key + extraKey}
{id}
input={configuration[key]}
bind:value={resolvedConfig[key]}
/>
{/each}
<RunnableWrapper
@@ -129,6 +138,7 @@
gotoNewTab={resolvedConfig.gotoNewTab}
{render}
{outputs}
{extraKey}
>
<AlignWrapper {noWFull} {horizontalAlignment} {verticalAlignment}>
{#if errorsMessage}

View File

@@ -52,7 +52,7 @@
let table = createSvelteTable(options)
const { app, worldStore, componentControl, selectedComponent } =
const { app, worldStore, componentControl, selectedComponent, hoverStore } =
getContext<AppViewerContext>('AppViewerContext')
let selectedRowIndex = -1
@@ -262,11 +262,22 @@
<div class="center-center h-full w-full flex-wrap gap-1 ">
{#each actionButtons as actionButton, actionIndex (actionIndex)}
<div
class={actionButton.id === $selectedComponent
on:mouseover|stopPropagation={() => {
if (actionButton.id !== $hoverStore) {
$hoverStore = actionButton.id
}
}}
on:mouseout|stopPropagation={() => {
if ($hoverStore !== undefined) {
$hoverStore = undefined
}
}}
class={actionButton.id === $selectedComponent ||
$hoverStore === actionButton.id
? 'outline outline-indigo-500 outline-1 outline-offset-1 relative '
: ''}
>
{#if actionButton.id === $selectedComponent}
{#if actionButton.id === $selectedComponent || $hoverStore === actionButton.id}
<span
title={`Id: ${actionButton.id}`}
class={classNames(
@@ -279,6 +290,7 @@
{/if}
{#if rowIndex == 0}
<AppButton
extraKey={'idx' + rowIndex}
{render}
noWFull
{...actionButton}
@@ -311,6 +323,7 @@
/>
{:else}
<AppButton
extraKey={'idx' + rowIndex}
{render}
noWFull
{...actionButton}

View File

@@ -35,6 +35,7 @@
export let recomputable: boolean = false
export let recomputeIds: string[] = []
export let outputs: { result: Output<any>; loading: Output<boolean> }
export let extraKey = ''
const {
worldStore,
@@ -282,13 +283,18 @@
{#each Object.entries(fields ?? {}) as [key, v] (key)}
{#if v.type != 'static' && v.type != 'user'}
<InputValue {key} {id} input={fields[key]} bind:value={runnableInputValues[key]} />
<InputValue
key={key + extraKey}
{id}
input={fields[key]}
bind:value={runnableInputValues[key]}
/>
{/if}
{/each}
{#if runnable?.type == 'runnableByName' && runnable.inlineScript?.language == 'frontend'}
{#each runnable.inlineScript.refreshOn ?? [] as { id: tid, key } (`${tid}-${key}`)}
{@const fkey = `${tid}-${key}`}
{@const fkey = `${tid}-${key}${extraKey}`}
<InputValue
{id}
key={fkey}

View File

@@ -23,6 +23,7 @@
export let render: boolean
export let recomputeIds: string[] = []
export let outputs: { result: Output<any>; loading: Output<boolean> }
export let extraKey: string | undefined = undefined
const { staticExporter, noBackend } = getContext<AppViewerContext>('AppViewerContext')
@@ -46,6 +47,7 @@
<slot />
{:else if componentInput.type === 'runnable' && isRunnableDefined(componentInput)}
<RunnableComponent
{extraKey}
{recomputeIds}
gotoUrl={goto}
{gotoNewTab}

View File

@@ -54,7 +54,13 @@ export function findGridItemParentGrid(app: App, id: string): string | undefined
export function allsubIds(app: App, parentId: string): string[] {
let item = findGridItem(app, parentId)
if (!item?.data.numberOfSubgrids) {
return [parentId]
let subIds = [parentId]
if (item) {
if (item.data.type === 'tablecomponent') {
subIds.push(...item.data.actionButtons?.map((x) => x.id))
}
}
return subIds
}
return getAllSubgridsAndComponentIds(app, item?.data)[1]
}
@@ -199,6 +205,9 @@ export function getAllSubgridsAndComponentIds(
): [string[], string[]] {
const subgrids: string[] = []
let components: string[] = [component.id]
if (component.type === 'tablecomponent') {
components.push(...component.actionButtons?.map((x) => x.id))
}
if (app.subgrids && component.numberOfSubgrids) {
for (let i = 0; i < component.numberOfSubgrids; i++) {
const key = `${component.id}-${i}`

View File

@@ -30,7 +30,7 @@
</script>
<TriggerBadgesList
inputDependencies={getDependencies(fields)}
inputDependencies={onClick ? [] : getDependencies(fields)}
bind:inlineScript={runnable.inlineScript}
{onLoad}
id={$selectedComponent}