Skip to content

Commit

Permalink
Merge branch 'develop' into MAT-7937
Browse files Browse the repository at this point in the history
  • Loading branch information
adongare committed Dec 31, 2024
2 parents 078270b + 2d70195 commit d017186
Show file tree
Hide file tree
Showing 14 changed files with 300 additions and 90 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"webpack-merge": "^5.8.0"
},
"dependencies": {
"@madie/cql-antlr-parser": "^1.0.9",
"@madie/cql-antlr-parser": "^1.0.10",
"@madie/madie-design-system": "^1.2.41",
"@material-ui/core": "^4.12.4",
"@mui/icons-material": "^5.5.1",
Expand Down
1 change: 1 addition & 0 deletions src/AceEditor/madie-ace-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export interface EditorPropsType {
handleDeleteLibrary?: (lib: SelectedLibrary) => void;
handleApplyFunction?: (funct: Funct) => void;
handleFunctionDelete?: (funct: any) => void;
handleFunctionEdit?: (funct: any, newFunct: string) => void;
parseDebounceTime?: number;
inboundAnnotations?: Ace.Annotation[];
inboundErrorMarkers?: Ace.MarkerLike[];
Expand Down
2 changes: 2 additions & 0 deletions src/CqlBuilderPanel/CqlBuilderPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export default function CqlBuilderPanel({
handleDefinitionDelete,
handleApplyFunction,
handleFunctionDelete,
handleFunctionEdit,
resetCql,
getCqlDefinitionReturnTypes,
makeExpanded,
Expand Down Expand Up @@ -246,6 +247,7 @@ export default function CqlBuilderPanel({
canEdit={canEdit}
handleApplyFunction={handleApplyFunction}
handleFunctionDelete={handleFunctionDelete}
handleFunctionEdit={handleFunctionEdit}
loading={loading}
cql={measureStoreCql}
isCQLUnchanged={isCQLUnchanged}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export default function ExpressionEditor(props: ExpressionsProps) {
type === "Definitions" ||
type === "Functions"
) {
if (cqlBuilderLookupsTypes[type?.toLowerCase()]) {
if (cqlBuilderLookupsTypes?.[type?.toLowerCase()]) {
setNamesOptions(
cqlBuilderLookupsTypes[type?.toLowerCase()].map((def) =>
getDefinitionNameWithAlias(def, type?.toLowerCase())
Expand Down
8 changes: 3 additions & 5 deletions src/CqlBuilderPanel/functionsSection/EditFunctionDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,9 @@ const EditFunctionDialog = ({

const updatedFunction = {
...funct,
fluentFunction: funct?.isFluent === true ? true : false,
functionsArguments: parseArgumentsFromLogicString(
funct?.logic ? funct?.logic : ""
),
expressionEditorValue: funct?.logic,
fluentFunction: funct?.isFluent === "Yes" ? true : false,
functionsArguments: funct?.arguments,
expressionEditorValue: funct?.expressionEditorValue,
};

return (
Expand Down
36 changes: 30 additions & 6 deletions src/CqlBuilderPanel/functionsSection/FunctionsSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@ import "./Functions.scss";
import FunctionSectionNavTabs from "./FunctionSectionNavTabs";
import Functions from "./functions/Functions";
import FunctionBuilder from "./functionBuilder/FunctionBuilder";
import { CqlBuilderLookup, FunctionLookup } from "../../model/CqlBuilderLookup";
import {
CqlBuilderLookup,
FunctionLookup,
FunctionArgument,
} from "../../model/CqlBuilderLookup";
import * as _ from "lodash";
import { CqlAntlr } from "@madie/cql-antlr-parser/dist/src";

export interface FunctionProps {
canEdit: boolean;
handleApplyFunction?: Function;
handleFunctionDelete?: Function;
handleFunctionEdit?: Function;
loading: boolean;
cqlBuilderLookupsTypes?: CqlBuilderLookup;
cql: string;
Expand All @@ -19,9 +24,24 @@ export interface FunctionProps {
resetCql: Function;
}

const getArgumentNames = (logic: string) => {
const getArgumentNames = (logic: string): FunctionArgument[] => {
const args = logic.substring(logic.indexOf("(") + 1, logic.indexOf(")"));
return args.split(",");
const argstr = args.split(",");
return argstr.map((arg) => {
if (arg[0] === " ") {
arg = arg.substring(1);
}
const splitted = arg.split(" ");
return { argumentName: splitted[0], dataType: splitted[1] };
});
};

const getExpressionEditorValue = (logic: string): string => {
const expressionEditorValue = logic.substring(
logic.indexOf(":") + 1,
logic.length
);
return expressionEditorValue ? expressionEditorValue.trim() : "";
};

export default function FunctionsSection({
Expand All @@ -32,6 +52,7 @@ export default function FunctionsSection({
cqlBuilderLookupsTypes,
resetCql,
handleFunctionDelete,
handleFunctionEdit,
loading,
}: FunctionProps) {
const [activeTab, setActiveTab] = useState<string>("function");
Expand All @@ -52,7 +73,8 @@ export default function FunctionsSection({
...func,
comment: expression?.comment,
isFluent: "-",
argumentNames: getArgumentNames(func.logic),
arguments: getArgumentNames(func.logic),
expressionEditorValue: getExpressionEditorValue(func.logic),
} as FunctionLookup;
}) || [];

Expand All @@ -67,8 +89,9 @@ export default function FunctionsSection({
...func,
comment: expression?.comment,
isFluent: "Yes",
argumentNames: getArgumentNames(func.logic),
};
arguments: getArgumentNames(func.logic),
expressionEditorValue: getExpressionEditorValue(func.logic),
} as FunctionLookup;
}) || []
);
functionLookups = _.sortBy(functionLookups, (o) => o.name?.toLowerCase());
Expand Down Expand Up @@ -99,6 +122,7 @@ export default function FunctionsSection({
resetCql={resetCql}
handleApplyFunction={handleApplyFunction}
handleFunctionDelete={handleFunctionDelete}
handleFunctionEdit={handleFunctionEdit}
/>
)}
</div>
Expand Down
40 changes: 21 additions & 19 deletions src/CqlBuilderPanel/functionsSection/argumentSection/Arguments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,25 +205,27 @@ const Arguments = ({
accessorKey: "action",
cell: (row: any) => {
return (
<Stack direction="row" alignItems="center">
<ToolTippedIcon
tooltipMessage="Delete"
buttonProps={{
"data-testid": `delete-button-${row.row.id}`,
"aria-label": `delete-button-${row.row.id}`,
size: "small",
onClick: () => {
setSelectedArgument({
argumentName: row.row.original.name,
dataType: row.row.original.datatype,
} as FunctionArgument);
setDeleteDialogOpen(true);
},
}}
>
<DeleteOutlineIcon color="error" />
</ToolTippedIcon>
</Stack>
row.row.original.name && (
<Stack direction="row" alignItems="center">
<ToolTippedIcon
tooltipMessage="Delete"
buttonProps={{
"data-testid": `delete-button-${row.row.id}`,
"aria-label": `delete-button-${row.row.id}`,
size: "small",
onClick: () => {
setSelectedArgument({
argumentName: row.row.original.name,
dataType: row.row.original.datatype,
} as FunctionArgument);
setDeleteDialogOpen(true);
},
}}
>
<DeleteOutlineIcon color="error" />
</ToolTippedIcon>
</Stack>
)
);
},
},
Expand Down
Loading

0 comments on commit d017186

Please sign in to comment.