Skip to content

Commit

Permalink
handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
jomarko committed Jan 9, 2025
1 parent 148c40b commit de467be
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 5 deletions.
2 changes: 2 additions & 0 deletions packages/boxed-expression-component/src/@types/react-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ declare module "react-table" {
export interface ColumnInterface<D extends object> {
/** Used by react-table to hold the original id chosen for the column, independently of applied operations */
originalId?: string;
decisionId?: string;
headerCellClickCallback?: () => void;
/** Column identifier */
accessor: string;
/** Column group type */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,8 @@ export function BeeTableHeader<R extends object>({
// title={`Open ${dmnFormResult.decisionName} expression`}
icon={<ArrowUpIcon />}
// data-navigate-to-expression-id={dmnFormResult.decisionId}
// onClick={() => props.openBoxedExpressionEditor?.(dmnFormResult.decisionId)}
onClick={() => column.headerCellClickCallback?.()}
title={column.decisionId}
/>
{/* )} */}
</Flex>
Expand Down
10 changes: 10 additions & 0 deletions packages/online-editor/src/dmnRunner/DmnRunnerTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,14 @@ import setObjectValueByPath from "lodash/set";
import cloneDeep from "lodash/cloneDeep";
import { DmnRunnerProviderActionType } from "./DmnRunnerTypes";
import { DmnRunnerExtendedServicesError } from "./DmnRunnerContextProvider";
import { useEditorRef } from "@kie-tools-core/editor/dist/embedded";
import { MessageBusClientApi } from "@kie-tools-core/envelope-bus/dist/api";
import { NewDmnEditorEnvelopeApi } from "@kie-tools/dmn-editor-envelope/dist/NewDmnEditorEnvelopeApi";

export function DmnRunnerTable() {
// STATEs
const [dmnRunnerTableError, setDmnRunnerTableError] = useState<boolean>(false);
const { editor } = useEditorRef();

// REFs
const [inputsContainerRef, setInputsContainerRef] = useState<HTMLDivElement | null>(null);
Expand Down Expand Up @@ -137,6 +141,12 @@ export function DmnRunnerTable() {
i18n={i18n.dmnRunner.table}
jsonSchemaBridge={jsonSchemaBridge}
results={results}
dmnSpecialCallback={(nodeId: string) => {
const newDmnEditorEnvelopeApi = editor?.getEnvelopeServer()
.envelopeApi as unknown as MessageBusClientApi<NewDmnEditorEnvelopeApi>;

newDmnEditorEnvelopeApi.notifications.dmnEditor_openBoxedExpressionEditor.send(nodeId);
}}
/>
</div>
</DrawerPanelContent>
Expand Down
29 changes: 25 additions & 4 deletions packages/unitables-dmn/src/DmnRunnerOutputsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,16 @@ interface Props {
results: Array<DecisionResult[] | undefined> | undefined;
jsonSchemaBridge: DmnUnitablesJsonSchemaBridge;
scrollableParentRef: React.RefObject<HTMLElement>;
dmnSpecialCallback?: (nodeId: string) => void;
}

export function DmnRunnerOutputsTable({ i18n, jsonSchemaBridge, results, scrollableParentRef }: Props) {
export function DmnRunnerOutputsTable({
i18n,
jsonSchemaBridge,
results,
scrollableParentRef,
dmnSpecialCallback,
}: Props) {
const outputUid = useMemo(() => nextId(), []);
const outputErrorBoundaryRef = useRef<ErrorBoundary>(null);
const [outputError, setOutputError] = useState<boolean>(false);
Expand Down Expand Up @@ -80,6 +87,7 @@ export function DmnRunnerOutputsTable({ i18n, jsonSchemaBridge, results, scrolla
outputsPropertiesMap={outputsPropertiesMap}
results={results}
id={outputUid}
dmnSpecialCallback={dmnSpecialCallback}
/>
</ErrorBoundary>
) : (
Expand Down Expand Up @@ -129,9 +137,17 @@ interface OutputsTableProps {
results: (DecisionResult[] | undefined)[] | undefined;
outputsPropertiesMap: Map<string, OutputField>;
scrollableParentRef: React.RefObject<HTMLElement>;
dmnSpecialCallback?: (nodeId: string) => void;
}

function OutputsBeeTable({ id, i18n, outputsPropertiesMap, results, scrollableParentRef }: OutputsTableProps) {
function OutputsBeeTable({
id,
i18n,
outputsPropertiesMap,
results,
scrollableParentRef,
dmnSpecialCallback,
}: OutputsTableProps) {
const beeTableOperationConfig = useMemo<BeeTableOperationConfig>(
() => [
{
Expand Down Expand Up @@ -229,7 +245,7 @@ function OutputsBeeTable({ id, i18n, outputsPropertiesMap, results, scrollablePa
);

const beeTableColumns = useMemo<ReactTable.Column<ROWTYPE>[]>(() => {
return (results?.[0] ?? []).flatMap(({ result, decisionName }) => {
return (results?.[0] ?? []).flatMap(({ result, decisionName, decisionId }) => {
const outputProperties = outputsPropertiesMap.get(decisionName);
if (!outputProperties) {
return [];
Expand Down Expand Up @@ -286,6 +302,7 @@ function OutputsBeeTable({ id, i18n, outputsPropertiesMap, results, scrollablePa
if (typeof result === "string" || typeof result === "number" || typeof result === "boolean" || result === null) {
return [
{
decisionId: decisionId,
originalId: `parent-${outputProperties?.name}-` + generateUuid(),
label: "",
accessor: (`output-parent-${outputProperties?.name}-` + generateUuid()) as any,
Expand All @@ -295,7 +312,11 @@ function OutputsBeeTable({ id, i18n, outputsPropertiesMap, results, scrollablePa
minWidth: DMN_RUNNER_OUTPUT_COLUMN_MIN_WIDTH,
columns: [
{
originalId: `${outputProperties?.name}-` + generateUuid(),
decisionId: decisionId,
headerCellClickCallback: () => {
dmnSpecialCallback?.(decisionId);
},
originalId: `${outputProperties?.name}-` + generateUuid() + `${outputProperties?.properties?.id}`,
label: outputProperties?.name ?? "",
accessor: (`output-${outputProperties?.name}-` + generateUuid()) as any,
dataType: outputProperties?.dataType ?? DmnBuiltInDataType.Undefined,
Expand Down

0 comments on commit de467be

Please sign in to comment.