From dc8fdb33dc5797e9bd5923ed28133aae51e23bca Mon Sep 17 00:00:00 2001 From: Darin Kelkhoff Date: Fri, 20 Sep 2024 10:42:22 -0500 Subject: [PATCH] CE-1727 - New blocks and styles for (mobile-style) widgets in processes, plus callbacks and contextValues --- src/qqq/components/widgets/WidgetBlock.tsx | 17 ++- .../widgets/blocks/ActionButtonBlock.tsx | 60 ++++++++ .../components/widgets/blocks/AudioBlock.tsx | 40 ++++++ .../components/widgets/blocks/ImageBlock.tsx | 59 ++++++++ .../widgets/blocks/InputFieldBlock.tsx | 128 ++++++++++++++++++ .../components/widgets/blocks/TextBlock.tsx | 49 ++++++- 6 files changed, 350 insertions(+), 3 deletions(-) create mode 100644 src/qqq/components/widgets/blocks/ActionButtonBlock.tsx create mode 100644 src/qqq/components/widgets/blocks/AudioBlock.tsx create mode 100644 src/qqq/components/widgets/blocks/ImageBlock.tsx create mode 100644 src/qqq/components/widgets/blocks/InputFieldBlock.tsx diff --git a/src/qqq/components/widgets/WidgetBlock.tsx b/src/qqq/components/widgets/WidgetBlock.tsx index fab8f6d..1115741 100644 --- a/src/qqq/components/widgets/WidgetBlock.tsx +++ b/src/qqq/components/widgets/WidgetBlock.tsx @@ -22,6 +22,9 @@ import {QWidgetMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QWidgetMetaData"; import {Alert, Skeleton} from "@mui/material"; +import ActionButtonBlock from "qqq/components/widgets/blocks/ActionButtonBlock"; +import AudioBlock from "qqq/components/widgets/blocks/AudioBlock"; +import InputFieldBlock from "qqq/components/widgets/blocks/InputFieldBlock"; import React from "react"; import BigNumberBlock from "qqq/components/widgets/blocks/BigNumberBlock"; import {BlockData} from "qqq/components/widgets/blocks/BlockModels"; @@ -32,19 +35,21 @@ import TableSubRowDetailRowBlock from "qqq/components/widgets/blocks/TableSubRow import TextBlock from "qqq/components/widgets/blocks/TextBlock"; import UpOrDownNumberBlock from "qqq/components/widgets/blocks/UpOrDownNumberBlock"; import CompositeWidget from "qqq/components/widgets/CompositeWidget"; +import ImageBlock from "./blocks/ImageBlock"; interface WidgetBlockProps { widgetMetaData: QWidgetMetaData; block: BlockData; + actionCallback?: (blockData: BlockData) => boolean; } /******************************************************************************* ** Component to render a single Block in the widget framework! *******************************************************************************/ -export default function WidgetBlock({widgetMetaData, block}: WidgetBlockProps): JSX.Element +export default function WidgetBlock({widgetMetaData, block, actionCallback}: WidgetBlockProps): JSX.Element { if(!block) { @@ -64,7 +69,7 @@ export default function WidgetBlock({widgetMetaData, block}: WidgetBlockProps): if(block.blockTypeName == "COMPOSITE") { // @ts-ignore - special case for composite type block... - return (); + return (); } switch(block.blockTypeName) @@ -83,6 +88,14 @@ export default function WidgetBlock({widgetMetaData, block}: WidgetBlockProps): return (); case "BIG_NUMBER": return (); + case "INPUT_FIELD": + return (); + case "ACTION_BUTTON": + return (); + case "AUDIO": + return (); + case "IMAGE": + return (); default: return (Unsupported block type: {block.blockTypeName}) } diff --git a/src/qqq/components/widgets/blocks/ActionButtonBlock.tsx b/src/qqq/components/widgets/blocks/ActionButtonBlock.tsx new file mode 100644 index 0000000..8b0e2ec --- /dev/null +++ b/src/qqq/components/widgets/blocks/ActionButtonBlock.tsx @@ -0,0 +1,60 @@ +/* + * QQQ - Low-code Application Framework for Engineers. + * Copyright (C) 2021-2024. Kingsrook, LLC + * 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States + * contact@kingsrook.com + * https://github.com/Kingsrook/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +import Box from "@mui/material/Box"; +import Icon from "@mui/material/Icon"; +import {standardWidth} from "qqq/components/buttons/DefaultButtons"; +import MDButton from "qqq/components/legacy/MDButton"; +import BlockElementWrapper from "qqq/components/widgets/blocks/BlockElementWrapper"; +import {StandardBlockComponentProps} from "qqq/components/widgets/blocks/BlockModels"; +import React from "react"; + + +/******************************************************************************* + ** Block that renders ... an action button... + ** + *******************************************************************************/ +export default function ActionButtonBlock({widgetMetaData, data, actionCallback}: StandardBlockComponentProps): JSX.Element +{ + const icon = data.values.iconName ? {data.values.iconName} : null; + + function onClick() + { + if(actionCallback) + { + actionCallback(data, {actionCode: data.values?.actionCode}) + } + else + { + console.log("ActionButtonBlock onClick with no actionCallback present, so, noop"); + } + } + + return ( + + + + {data.values.label ?? "Action"} + + + + ); +} diff --git a/src/qqq/components/widgets/blocks/AudioBlock.tsx b/src/qqq/components/widgets/blocks/AudioBlock.tsx new file mode 100644 index 0000000..210eaaf --- /dev/null +++ b/src/qqq/components/widgets/blocks/AudioBlock.tsx @@ -0,0 +1,40 @@ +/* + * QQQ - Low-code Application Framework for Engineers. + * Copyright (C) 2021-2024. Kingsrook, LLC + * 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States + * contact@kingsrook.com + * https://github.com/Kingsrook/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +import Box from "@mui/material/Box"; +import BlockElementWrapper from "qqq/components/widgets/blocks/BlockElementWrapper"; +import {StandardBlockComponentProps} from "qqq/components/widgets/blocks/BlockModels"; +import DumpJsonBox from "qqq/utils/DumpJsonBox"; +import React from "react"; + +/******************************************************************************* + ** Block that renders ... an audio tag + ** + **