Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 256 #260

Merged
merged 7 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
getGeneElement,
getGeneNomenclature,
} from "../../../../../services/main";
import ElementInputAccordion from "../StructuralElementInputAccordion";
import StructuralElementInputAccordion from "../StructuralElementInputAccordion";

interface GeneElementInputProps extends StructuralElementInputProps {
element: ClientGeneElement;
Expand All @@ -28,12 +28,14 @@ const GeneElementInput: React.FC<GeneElementInputProps> = ({
const [geneText, setGeneText] = useState<string>("");
const validated = gene !== "" && geneText == "";
const [expanded, setExpanded] = useState<boolean>(!validated);
const [pendingResponse, setPendingResponse] = useState(false);

useEffect(() => {
if (validated) buildGeneElement();
}, [gene, geneText]);

const buildGeneElement = () => {
setPendingResponse(true)
getGeneElement(gene).then((geneElementResponse) => {
if (
geneElementResponse.warnings &&
Expand All @@ -56,6 +58,7 @@ const GeneElementInput: React.FC<GeneElementInputProps> = ({
nomenclature: nomenclatureResponse.nomenclature,
};
handleSave(index, clientGeneElement);
setPendingResponse(false)
}
}
);
Expand All @@ -74,14 +77,15 @@ const GeneElementInput: React.FC<GeneElementInputProps> = ({
/>
);

return ElementInputAccordion({
return StructuralElementInputAccordion({
expanded,
setExpanded,
element,
handleDelete,
inputElements,
validated,
icon,
pendingResponse
});
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { BaseStructuralElementProps } from "../StructuralElementInputProps";
import CompInputAccordion from "../StructuralElementInputAccordion";
import StructuralElementInputAccordion from "../StructuralElementInputAccordion";

const StaticElement: React.FC<BaseStructuralElementProps> = ({
element,
handleDelete,
icon,
}) =>
CompInputAccordion({
StructuralElementInputAccordion({
expanded: false,
element,
handleDelete,
validated: true,
icon,
pendingResponse: false
});

export default StaticElement;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Tooltip, makeStyles } from "@material-ui/core";
import { Tooltip, makeStyles, CircularProgress } from "@material-ui/core";
import { styled } from "@mui/material/styles";
import IconButton, { IconButtonProps } from "@mui/material/IconButton";
import Card from "@mui/material/Card";
Expand Down Expand Up @@ -43,6 +43,7 @@ interface StructuralElementInputAccordionProps
inputElements?: JSX.Element;
validated: boolean;
icon: JSX.Element;
pendingResponse?: boolean;
}

interface ExpandMoreProps extends IconButtonProps {
Expand Down Expand Up @@ -71,6 +72,7 @@ const StructuralElementInputAccordion: React.FC<
inputElements,
validated,
icon,
pendingResponse
}) => {
const classes = useStyles();

Expand All @@ -79,6 +81,8 @@ const StructuralElementInputAccordion: React.FC<
<CardHeader
avatar={icon}
action={
pendingResponse ?
<CircularProgress style={{width: "1.25em", height: "1.25em", padding: "8px"}} /> :
<Tooltip title="Delete element">
<IconButton
style={{ cursor: "pointer" }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export interface BaseStructuralElementProps {
element: ClientElementUnion;
handleDelete?: (id?: string) => void;
icon: JSX.Element;
pendingResponse?: boolean
}

export interface StructuralElementInputProps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ interface TemplatedSequenceElementInputProps
const TemplatedSequenceElementInput: React.FC<
TemplatedSequenceElementInputProps
> = ({ element, index, handleSave, handleDelete, icon }) => {

const [chromosome, setChromosome] = useState<string>(
element.input_chromosome || ""
);
Expand All @@ -39,6 +40,8 @@ const TemplatedSequenceElementInput: React.FC<

const [expanded, setExpanded] = useState<boolean>(!validated);

const [pendingResponse, setPendingResponse] = useState(false);

useEffect(() => {
if (inputComplete) {
buildTemplatedSequenceElement();
Expand All @@ -64,6 +67,7 @@ const TemplatedSequenceElementInput: React.FC<
) {
// TODO visible error handling
setInputError("element validation unsuccessful");
setPendingResponse(false)
return;
} else if (templatedSequenceResponse.element) {
setInputError("");
Expand All @@ -83,6 +87,7 @@ const TemplatedSequenceElementInput: React.FC<
}
});
}
setPendingResponse(false)
});
};

Expand Down Expand Up @@ -162,6 +167,7 @@ const TemplatedSequenceElementInput: React.FC<
inputElements,
validated,
icon,
pendingResponse
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
} from "../../../../../services/main";
import { GeneAutocomplete } from "../../../../main/shared/GeneAutocomplete/GeneAutocomplete";
import { StructuralElementInputProps } from "../StructuralElementInputProps";
import CompInputAccordion from "../StructuralElementInputAccordion";
import StructuralElementInputAccordion from "../StructuralElementInputAccordion";
import { FusionContext } from "../../../../../global/contexts/FusionContext";
import StrandSwitch from "../../../../main/shared/StrandSwitch/StrandSwitch";
import HelpTooltip from "../../../../main/shared/HelpTooltip/HelpTooltip";
Expand Down Expand Up @@ -85,6 +85,8 @@ const TxSegmentCompInput: React.FC<TxSegmentElementInputProps> = ({
);
const [endingExonOffsetText, setEndingExonOffsetText] = useState("");

const [pendingResponse, setPendingResponse] = useState(false);

/*
Depending on this element's location in the structure array, the user
needs to provide some kind of coordinate input for either one or both ends
Expand Down Expand Up @@ -142,7 +144,7 @@ const TxSegmentCompInput: React.FC<TxSegmentElementInputProps> = ({
endingExon,
startingExonOffset,
endingExonOffset,
index,
index
]);

const handleTxElementResponse = (
Expand All @@ -156,7 +158,6 @@ const TxSegmentCompInput: React.FC<TxSegmentElementInputProps> = ({
...responseElement,
...inputParams,
};

if (!hasRequiredEnds) {
finishedElement.nomenclature = "ERROR";
} else {
Expand All @@ -170,6 +171,7 @@ const TxSegmentCompInput: React.FC<TxSegmentElementInputProps> = ({
}
});
}
setPendingResponse(false)
};

/**
Expand Down Expand Up @@ -226,6 +228,7 @@ const TxSegmentCompInput: React.FC<TxSegmentElementInputProps> = ({
* Request construction of tx segment element from server and handle response
*/
const buildTranscriptSegmentElement = () => {
setPendingResponse(true)
// fire constructor request
switch (txInputType) {
case InputType.gcg:
Expand Down Expand Up @@ -665,14 +668,15 @@ const TxSegmentCompInput: React.FC<TxSegmentElementInputProps> = ({
</>
);

return CompInputAccordion({
return StructuralElementInputAccordion({
expanded,
setExpanded,
element,
handleDelete,
inputElements,
validated,
icon,
pendingResponse
});
};

Expand Down