fix(frontend): Correctly handle undefined actions

This commit is contained in:
Faton Ramadani
2024-04-12 16:16:43 +02:00
parent 071c3cf04a
commit 40a64a05d5
4 changed files with 9 additions and 6 deletions
@@ -198,7 +198,7 @@
function actionRenderer(params) {
const { rowIndex, data: row } = params
if (rowIndex === -1 || actions == undefined || actions.length == 0) {
if (rowIndex === -1 || actions == undefined || actions?.length == 0) {
return null
}
@@ -90,8 +90,8 @@
}
if (
parent.data.type === 'aggridcomponent' ||
(parent.data.type === 'aggridcomponentee' && Array.isArray(parent.data.actions))
(parent.data.type === 'aggridcomponent' || parent.data.type === 'aggridcomponentee') &&
Array.isArray(parent.data.actions)
) {
parent.data.actions = parent.data.actions.filter(
(x) => x.id !== tableActionSettings?.item.id
@@ -517,7 +517,10 @@ export function getAllGridItems(app: App): GridItem[] {
.map((x) => {
if (x?.data?.type === 'tablecomponent') {
return [x, ...x?.data?.actionButtons?.map((x) => ({ data: x, id: x.id }))]
} else if (x?.data?.type === 'aggridcomponent' || x?.data?.type === 'aggridcomponentee') {
} else if (
(x?.data?.type === 'aggridcomponent' || x?.data?.type === 'aggridcomponentee') &&
Array.isArray(x?.data?.actions)
) {
return [x, ...x?.data?.actions?.map((x) => ({ data: x, id: x.id }))]
} else if (x?.data?.type === 'menucomponent') {
return [x, ...x?.data?.menuItems?.map((x) => ({ data: x, id: x.id }))]
@@ -34,8 +34,8 @@
{/each}
{/if}
{#if gridItem?.data?.type === 'aggridcomponent' || (gridItem?.data?.type === 'aggridcomponentee' && Array.isArray(gridItem.data.actions))}
{#each gridItem.data.actions ?? [] as actionButton, index (index)}
{#if (gridItem?.data?.type === 'aggridcomponent' || gridItem?.data?.type === 'aggridcomponentee') && Array.isArray(gridItem.data.actions)}
{#each gridItem.data.actions as actionButton, index (index)}
{#if actionButton?.id === $selectedComponentInEditor || actionButton?.id + '_transformer' === $selectedComponentInEditor}
<InlineScriptEditorPanel
on:createScriptFromInlineScript