Skip to content

Commit

Permalink
refactor(ui-bc): update BindingConstraints matrices
Browse files Browse the repository at this point in the history
  • Loading branch information
hdinia committed Sep 20, 2024
1 parent 932b333 commit 17e4126
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import { useFormContextPlus } from "../../../../../../common/Form";
import { useMemo, useState } from "react";
import { useTranslation } from "react-i18next";
import { validateString } from "../../../../../../../utils/validationUtils";
import Matrix from "./Matrix";
import { Box, Button } from "@mui/material";
import { Dataset } from "@mui/icons-material";
import ConstraintMatrix from "./Matrix";

interface Props {
study: StudyMetadata;
Expand Down Expand Up @@ -160,7 +160,7 @@ function Fields({ study, constraintId }: Props) {
</Box>

{matrixDialogOpen && (
<Matrix
<ConstraintMatrix
study={study}
constraintId={constraintId}
operator={currentOperator}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { useTranslation } from "react-i18next";
import { MatrixStats, StudyMetadata } from "../../../../../../../common/types";
import MatrixInput from "../../../../../../common/MatrixInput";
import { StudyMetadata } from "../../../../../../../common/types";
import { Operator } from "./utils";
import SplitView from "../../../../../../common/SplitView";
import { Box, Button } from "@mui/material";
import BasicDialog, {
BasicDialogProps,
} from "../../../../../../common/dialogs/BasicDialog";
import Matrix from "../../../../../../common/MatrixGrid/Matrix";

interface Props {
study: StudyMetadata;
Expand All @@ -16,8 +16,13 @@ interface Props {
onClose: () => void;
}

// TODO rename MatrixDialog or ConstraintMatrixDialog
function Matrix({ study, operator, constraintId, open, onClose }: Props) {
function ConstraintMatrix({
study,
operator,
constraintId,
open,
onClose,
}: Props) {
const { t } = useTranslation();
const dialogProps: BasicDialogProps = {
open,
Expand Down Expand Up @@ -45,63 +50,51 @@ function Matrix({ study, operator, constraintId, open, onClose }: Props) {
{Number(study.version) >= 870 ? (
<>
{operator === "less" && (
<MatrixInput
study={study}
<Matrix
title={t("study.modelization.bindingConst.timeSeries.less")}
url={`input/bindingconstraints/${constraintId}_lt`}
computStats={MatrixStats.NOCOL}
/>
)}
{operator === "equal" && (
<MatrixInput
study={study}
<Matrix
title={t("study.modelization.bindingConst.timeSeries.equal")}
url={`input/bindingconstraints/${constraintId}_eq`}
computStats={MatrixStats.NOCOL}
/>
)}
{operator === "greater" && (
<MatrixInput
study={study}
<Matrix
title={t("study.modelization.bindingConst.timeSeries.greater")}
url={`input/bindingconstraints/${constraintId}_gt`}
computStats={MatrixStats.NOCOL}
/>
)}
{operator === "both" && (
<SplitView id="binding-constraints-matrix" sizes={[50, 50]}>
<Box sx={{ px: 2 }}>
<MatrixInput
study={study}
<Matrix
title={t("study.modelization.bindingConst.timeSeries.less")}
url={`input/bindingconstraints/${constraintId}_lt`}
computStats={MatrixStats.NOCOL}
/>
</Box>
<Box sx={{ px: 2 }}>
<MatrixInput
study={study}
<Matrix
title={t(
"study.modelization.bindingConst.timeSeries.greater",
)}
url={`input/bindingconstraints/${constraintId}_gt`}
computStats={MatrixStats.NOCOL}
/>
</Box>
</SplitView>
)}
</>
) : (
<MatrixInput
study={study}
<Matrix
title={t("global.matrix")}
url={`input/bindingconstraints/${constraintId}`}
columnsNames={["<", ">", "="]}
computStats={MatrixStats.NOCOL}
customColumns={["<", ">", "="]}
/>
)}
</BasicDialog>
);
}

export default Matrix;
export default ConstraintMatrix;

0 comments on commit 17e4126

Please sign in to comment.