Skip to content

Commit

Permalink
feat: Include initial values on ove
Browse files Browse the repository at this point in the history
  • Loading branch information
mfanselmo committed Sep 4, 2024
1 parent 6c5d28d commit d27390d
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 36 deletions.
16 changes: 10 additions & 6 deletions packages/ove/demo/src/EditorDemo/AddEditFeatureOverrideExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,11 @@ export class AddOrEditFeatureDialog extends React.Component {
sequenceData = { sequence: "" },
handleSubmit,
locations,
upsertFeature
upsertFeature,
start,
end,
forward,
type
} = this.props;
const sequenceLength = sequenceData.sequence.length;
return (
Expand Down Expand Up @@ -158,12 +162,12 @@ export class AddOrEditFeatureDialog extends React.Component {
// format={value => (value ? "true" : "false")}
name="forward"
label="Strand:"
defaultValue={true}
defaultValue={forward ?? true}
/>
<ReactSelectField
inlineLabel
tooltipError
defaultValue="misc_feature"
defaultValue={type ?? "misc_feature"}
options={getFeatureTypes().map(type => {
return {
label: (
Expand Down Expand Up @@ -198,7 +202,7 @@ export class AddOrEditFeatureDialog extends React.Component {
<NumericInputField
inlineLabel
tooltipError
defaultValue={1}
defaultValue={start ?? 1}
min={1}
max={sequenceLength || 1}
name="start"
Expand All @@ -207,7 +211,7 @@ export class AddOrEditFeatureDialog extends React.Component {
<NumericInputField
inlineLabel
tooltipError
defaultValue={1}
defaultValue={end ?? 1}
min={1}
max={sequenceLength || 1}
name="end"
Expand Down Expand Up @@ -372,5 +376,5 @@ export default compose(
return errors;
}
}),
tgFormValues("start", "end", "locations")
tgFormValues("start", "end", "locations", "forward", "type")
)(AddOrEditFeatureDialog);
10 changes: 8 additions & 2 deletions packages/ove/src/PCRTool/PCRTool.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,10 @@ function PCRTool(props) {
inlineLabel
tooltipError
options={forwardPrimers}
defaultValue={forwardPrimers[0] ? forwardPrimers[0].value : undefined}
defaultValue={
forwardPrimer ??
(forwardPrimers[0] ? forwardPrimers[0].value : undefined)
}
name="forwardPrimer"
label="Forward Primer:"
/>
Expand All @@ -132,7 +135,10 @@ function PCRTool(props) {
inlineLabel
tooltipError
options={reversePrimers}
defaultValue={reversePrimers[0] ? reversePrimers[0].value : undefined}
defaultValue={
reversePrimer ??
(reversePrimers[0] ? reversePrimers[0].value : undefined)
}
name="reversePrimer"
label="Reverse Primer:"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class AddOrEditAnnotationDialog extends React.Component {
sequenceData = { sequence: "" },
handleSubmit,
beforeAnnotationCreate,
renderTypes,
RenderTypes,
renderTags,
RenderBases,
allowMultipleFeatureDirections,
Expand All @@ -210,6 +210,7 @@ class AddOrEditAnnotationDialog extends React.Component {
overlapsSelf,
start,
end,
type,
readOnly,
getAdditionalEditAnnotationComps,
advancedOptions,
Expand Down Expand Up @@ -370,7 +371,9 @@ class AddOrEditAnnotationDialog extends React.Component {
/>
))}

{renderTypes || null}
{RenderTypes && (
<RenderTypes readOnly={this.props.readOnly} type={type}></RenderTypes>
)}
{renderTags || null}

{/* {allowPrimerBasesToBeEdited && RenderBases ? null : !renderLocations || */}
Expand All @@ -387,7 +390,7 @@ class AddOrEditAnnotationDialog extends React.Component {
format={this.formatStart}
parse={this.parseStart}
tooltipError
defaultValue={1}
defaultValue={start ?? 1}
min={1}
max={sequenceLength || 1}
name="start"
Expand All @@ -401,7 +404,7 @@ class AddOrEditAnnotationDialog extends React.Component {
parse={this.parseEnd}
inlineLabel
tooltipError
defaultValue={sequenceData.isProtein ? 3 : 1}
defaultValue={end ?? (sequenceData.isProtein ? 3 : 1)}
min={1}
max={sequenceLength || 1}
name="end"
Expand Down Expand Up @@ -569,6 +572,7 @@ export default ({ formName, getProps, dialogProps }) => {
tgFormValues(
"start",
"end",
"type",
"overlapsSelf",
"locations",
"bases",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import {
import AddOrEditAnnotationDialog from "../AddOrEditAnnotationDialog";
import { ReactSelectField } from "@teselagen/ui";

const renderTypes = ({ readOnly }) => (
const RenderTypes = ({ readOnly, type }) => (
<ReactSelectField
inlineLabel
tooltipError
disabled={readOnly}
defaultValue="misc_feature"
options={getFeatureTypes().map(type => {
defaultValue={type ?? "misc_feature"}
options={getFeatureTypes().map(featureType => {
return {
label: (
<div
Expand All @@ -25,16 +25,18 @@ const renderTypes = ({ readOnly }) => (
>
<div
style={{
background: getFeatureToColorMap({ includeHidden: true })[type],
background: getFeatureToColorMap({ includeHidden: true })[
featureType
],
height: 15,
width: 15,
marginRight: 5
}}
/>
{type}
{featureType}
</div>
),
value: type
value: featureType
};
})}
name="type"
Expand All @@ -52,7 +54,7 @@ export default AddOrEditAnnotationDialog({
upsertAnnotation: props.upsertFeature,
// renderLocations: true, //tnw enable this eventually for proteins
renderLocations: !props.sequenceData.isProtein,
renderTypes: renderTypes({ readOnly: props.readOnly }),
RenderTypes,
annotationTypePlural: "features"
})
});
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import {
import { getFeatureTypes } from "@teselagen/sequence-utils";
import { get } from "lodash-es";

const renderTypes = ({ readOnly }) => (
const RenderTypes = ({ readOnly, type }) => (
<ReactSelectField
inlineLabel
tooltipError
disabled={readOnly}
defaultValue="misc_feature"
defaultValue={type ?? "misc_feature"}
options={getFeatureTypes().map(type => {
return {
label: type,
Expand Down Expand Up @@ -88,7 +88,7 @@ export default AddOrEditAnnotationDialog({
advancedOptions: props.allowPartsToOverlapSelf
? renderAdvancedOptions({ readOnly: props.readOnly })
: undefined,
renderTypes: renderTypes({ readOnly: props.readOnly }),
RenderTypes,
renderTags:
props.allPartTags &&
getRenderTags({
Expand Down
10 changes: 3 additions & 7 deletions packages/ove/src/helperComponents/AddOrEditPrimerDialog/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ const CustomContentEditable = generateField(function CustomContentEditable({
start,
end,
primerBindsOn,
bases,
forward
}) {
const bases = input.value;
const [hasTempError, setTempError] = useState(false);
const inputRef = useRef(null);
const [caretPosition, setCaretPosition] = useState({ start: 0, end: 0 });
Expand Down Expand Up @@ -194,7 +194,7 @@ const RenderBases = props => {
label="Linked Oligo?"
tooltipInfo={`Check this box to link this primer to an oligo in your Oligo Library. If the primer bases match exactly the bases of an existing oligo, it will be linked to that existing oligo. If the bases don't match, a new oligo will be created in the library.`}
noMarginBottom
defaultValue={true}
defaultValue={useLinkedOligo ?? true}
disabled={readOnly}
></CheckboxField>
{useLinkedOligo && (
Expand All @@ -221,11 +221,7 @@ const RenderBases = props => {
sequenceLength={sequenceLength}
disabled={readOnly}
{...props}
{...(defaultValue
? {
defaultValue
}
: {})}
defaultValue={bases ?? defaultValue}
name="bases"
label={
<div className="tg-bases-label">
Expand Down
9 changes: 2 additions & 7 deletions packages/ui/src/DataTable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,12 +274,7 @@ const DataTable = ({

tmp.searchTerm = reduxFormSearchInput;
return tmp;
}, [
history.location,
reduxFormQueryParams,
reduxFormSearchInput,
urlConnected
]);
}, [history, reduxFormQueryParams, reduxFormSearchInput, urlConnected]);

const tableParams = useMemo(() => {
if (!isTableParamsConnected) {
Expand Down Expand Up @@ -324,7 +319,7 @@ const DataTable = ({
_tableParams,
change,
currentParams,
history.replace,
history,
isTableParamsConnected,
props,
selectedEntities,
Expand Down

0 comments on commit d27390d

Please sign in to comment.