diff --git a/client/package.json b/client/package.json index 2c40644de..89a3764c0 100644 --- a/client/package.json +++ b/client/package.json @@ -34,6 +34,7 @@ "@material-ui/icons": "4.9.1", "@material-ui/lab": "4.0.0-alpha.56", "@material-ui/pickers": "3.3.10", + "@material/tooltip": "14.0.0", "@testing-library/jest-dom": "5.16.5", "@testing-library/react": "13.4.0", "@testing-library/user-event": "14.4.3", diff --git a/client/src/components/controls/DateInputField.tsx b/client/src/components/controls/DateInputField.tsx index 2b029675b..6850b2c6c 100644 --- a/client/src/components/controls/DateInputField.tsx +++ b/client/src/components/controls/DateInputField.tsx @@ -41,7 +41,7 @@ const useStyles = makeStyles(({ palette, typography, breakpoints }) => ({ '& .MuiSvgIcon-root': { height: 20, width: 20 - } + }, } })); diff --git a/client/src/components/controls/LabelTooltipText.tsx b/client/src/components/controls/LabelTooltipText.tsx new file mode 100644 index 000000000..cc3169cd2 --- /dev/null +++ b/client/src/components/controls/LabelTooltipText.tsx @@ -0,0 +1,71 @@ +import React from 'react'; +import { makeStyles } from '@material-ui/core/styles'; +import { Typography, TypographyProps, Tooltip, PropTypes } from '@material-ui/core'; +import { HelpOutline } from '@material-ui/icons'; + +const useStyles = makeStyles(({ spacing }) => ({ + container: { + display: 'flex', + padding: ({ padding }: LabelTooltipTextProps ) => padding ? padding : '0px 10px', + //borderRadius: 5, + //border: `1px dashed #0086ff`, + width: ({ width }: LabelTooltipTextProps ) => width || '100%', + marginTop: ({ marginTop }: LabelTooltipTextProps ) => spacing(marginTop || 0), + //backgroundColor: ({ required, error }: LabelTooltipTextProps ) => (error ? fade(palette.error.light, 0.3) : required ? palette.primary.light : palette.secondary.light) + }, + label: { + color: 'auto' + }, + loading: { + position: 'absolute', + top: 16, + right: 10 + } +})); + +interface LabelTooltipTextProps { + error?: boolean; + label?: string; + labelProps?: TypographyProps; + labelTooltipTxt: string; + marginTop?: number; + padding?: string; + renderLabel?: boolean; + width?: string; + align?: PropTypes.Alignment; +} + +function LabelTooltipText(props: LabelTooltipTextProps): React.ReactElement { + const { label, labelTooltipTxt, labelProps, renderLabel, align = 'left', } = props; + const classes = useStyles(props); + + let content: React.ReactNode = ( + <> + + {label} + + + ); + + if (labelTooltipTxt) { + const tooltipContent = ( + <> + + {label} + + + + + + ); + content = tooltipContent; + } + + if (renderLabel === false) { + content = null; + } + + return
{content}
; +} + +export default LabelTooltipText; \ No newline at end of file diff --git a/client/src/components/shared/AssetIdentifiers.tsx b/client/src/components/shared/AssetIdentifiers.tsx index d7770e6c1..c2b02d3c0 100644 --- a/client/src/components/shared/AssetIdentifiers.tsx +++ b/client/src/components/shared/AssetIdentifiers.tsx @@ -7,6 +7,7 @@ import { eVocabularySetID } from '@dpo-packrat/common'; import FieldType from './FieldType'; import IdentifierList from './IdentifierList'; +//Styles const useStyles = makeStyles(({ palette, spacing }) => ({ assetIdentifier: { display: 'flex', @@ -31,6 +32,7 @@ const useStyles = makeStyles(({ palette, spacing }) => ({ } })); +//Defines the prop type interface AssetIdentifiersProps { systemCreated: boolean; identifiers: StateIdentifier[]; @@ -44,11 +46,18 @@ interface AssetIdentifiersProps { } function AssetIdentifiers(props: AssetIdentifiersProps): React.ReactElement { + + //Props - types defined in interface const { systemCreated, identifiers, onSystemCreatedChange, onAddIdentifer, onUpdateIdentifer, onRemoveIdentifer, subjectView, onUpdateIdIdentifierPreferred, identifierName } = props; + + //Component styling const classes = useStyles(); + + //Handles state change for the Identifier entries const [getEntries, getInitialEntry] = useVocabularyStore(state => [state.getEntries, state.getInitialEntry]); + //Function creates object to define new identifier const addIdentifer = (initialEntry: number | null) => { const newIdentifier: StateIdentifier = { id: identifiers.length + 1, @@ -62,11 +71,13 @@ function AssetIdentifiers(props: AssetIdentifiersProps): React.ReactElement { onAddIdentifer(updatedIdentifiers); }; + //Function removes Identifier const removeIdentifier = (_idIdentifier: number, id: number) => { const updatedIdentifiers = lodash.filter(identifiers, identifier => identifier.id !== id); onRemoveIdentifer(updatedIdentifiers); }; + //Function updates any changes to the Identifier const updateIdentifierFields = (id: number, name: string, value: string | number | boolean) => { const updatedIdentifiers = identifiers.map(identifier => { if (identifier.id === id) { @@ -80,10 +91,12 @@ function AssetIdentifiers(props: AssetIdentifiersProps): React.ReactElement { onUpdateIdentifer(updatedIdentifiers); }; + //The label of the Asset Identifier UI (currently says 'Model Identifier(s)) const label: string = (identifierName ? identifierName : 'Asset') + ' Identifier(s)'; return ( + //The Identifier Component - + @@ -98,6 +111,8 @@ function AssetIdentifiers(props: AssetIdentifiersProps): React.ReactElement { System will create an identifier + + {/*May need to write the logic here to check if there are no identifiers in existence.*/} {!identifiers.length && (