From ad870e17151cc66c1d04950de135fd41b59baf6f Mon Sep 17 00:00:00 2001 From: Ryan Greer Date: Tue, 10 Sep 2024 09:59:45 -0600 Subject: [PATCH] added dna topology dropdown --- apps/web/src/components/CurationForm.jsx | 5 +- apps/web/src/components/TypeSelection.jsx | 100 ++++++++++++++++++++++ apps/web/src/modules/roles.js | 2 +- apps/web/src/modules/store.js | 5 +- 4 files changed, 108 insertions(+), 4 deletions(-) create mode 100644 apps/web/src/components/TypeSelection.jsx diff --git a/apps/web/src/components/CurationForm.jsx b/apps/web/src/components/CurationForm.jsx index 46b5893..96f84ca 100644 --- a/apps/web/src/components/CurationForm.jsx +++ b/apps/web/src/components/CurationForm.jsx @@ -1,8 +1,9 @@ -import { Container, Title, Tabs, Text, Space, LoadingOverlay, Button, Group, Header, List, ActionIcon, Tooltip, Textarea, Menu, Modal, TextInput, PasswordInput, Loader, Center, Select, SegmentedControl, Checkbox } from '@mantine/core' +import { Container, Title, Tabs, Text, Space, LoadingOverlay, Button, Group, Header, List, ActionIcon, Tooltip, Textarea, Menu, Modal, TextInput, PasswordInput, Loader, Center, Select, SegmentedControl, Checkbox, TypographyStylesProvider } from '@mantine/core' import { useStore, mutateDocument, mutateDocumentForDisplayID } from '../modules/store' import { useCyclicalColors } from "../hooks/misc" import SimilarParts from './SimilarParts' import RoleSelection from "./RoleSelection" +import TypeSelection from "./TypeSelection" import ProteinSelection from './ProteinSelection' import SplitPanel from "./SplitPanel" import TargetOrganismsSelection from './TargetOrganismsSelection' @@ -559,8 +560,8 @@ export default function CurationForm({ }) { - Roles + diff --git a/apps/web/src/components/TypeSelection.jsx b/apps/web/src/components/TypeSelection.jsx new file mode 100644 index 0000000..f55401a --- /dev/null +++ b/apps/web/src/components/TypeSelection.jsx @@ -0,0 +1,100 @@ +import { Group, Select, Text, Space, Button, CloseButton } from '@mantine/core' +import { useDebouncedValue } from '@mantine/hooks' +import { forwardRef, useEffect, useState } from 'react' +import { useSequenceOntology } from '../modules/ontologies/so' +import { mutateDocument, useStore } from '../modules/store' +import shallow from 'zustand/shallow' +import { decodeRoleURI } from '../modules/roles' +import { ScooterElectric } from 'tabler-icons-react' + + +export default function TypeSelection() { + const type = useStore(s => s.types); + const isFileEdited = useStore((s) => s.isFileEdited); + + let selectedTopology = type.filter(item => item.startsWith('http://identifiers.org/so/SO:')); + + const labels = ['Linear', 'Circular', 'Double-stranded', 'Single-stranded', 'Linear double-stranded', 'Linear single-stranded', 'Circular double-stranded', 'Circular single-stranded'] + + const types = [ + // use an array for values, then append to types in document + { value: ['http://identifiers.org/so/SO:0000987'], label: 'Linear' }, + { value: ['http://identifiers.org/so/SO:0000988'], label: 'Circular' }, + { value: ['http://identifiers.org/so/SO:0000985'], label: 'Double-stranded'}, + { value: ['http://identifiers.org/so/SO:0000984'], label: 'Single-stranded'}, + { value: ['http://identifiers.org/so/SO:0000987', 'http://identifiers.org/so/SO:0000985'], label: 'Linear double-stranded'}, + { value: ['http://identifiers.org/so/SO:0000988', 'http://identifiers.org/so/SO:0000985'], label: 'Circular double-stranded'}, + { value: ['http://identifiers.org/so/SO:0000987', 'http://identifiers.org/so/SO:0000984'], label: 'Linear single-stranded'}, + { value: ['http://identifiers.org/so/SO:0000988', 'http://identifiers.org/so/SO:0000984'], label: 'Circular single-stranded'}, + ] + + const getLabelFromValue = (value) => { + for (const type of types) { + if (String(type.value) === String(value)) { + return type.label; + } + } + return + } + + const getValueFromLabel = (label) => { + for (const type of types) { + if (String(type.label) === String(label)) { + return type.value; + } + } + return + } + + const setType = val => { + const selectedTypes = getValueFromLabel(val) + selectedTopology = selectedTypes + + mutateDocument(useStore.setState, state => { + state.types = state.types.filter(x => !x.startsWith('http://identifiers.org/so/SO:')) + state.document.root.type = state.types[0] //reset and only include dna region type + + // state.types.push(String(val)) + for (const x in selectedTypes) { + state.types.push(String(selectedTypes[x])) + state.document.root.addType(String(selectedTypes[x])); + } + }); + }; + + return ( +
+ + DNA Topology +