- toggleRelation(primaryName, v.id)
- }
- >
- {v.formattedName}
+
))}
diff --git a/app/frontend/src/components/SelectedStructuredNames.js b/app/frontend/src/components/SelectedStructuredNames.js
index 04dd2819..9ca7b6ea 100644
--- a/app/frontend/src/components/SelectedStructuredNames.js
+++ b/app/frontend/src/components/SelectedStructuredNames.js
@@ -6,6 +6,7 @@ import {
} from '../store/selected_structured_names/actions'
import { loadServerData } from '../services/server'
import { formatStructuredName, parseId } from '../utilities'
+import {SnameTooltip} from './SnameTooltip'
export const SelectedStructuredNames = () => {
const [selection, dbNames] = useSelector(state => {
@@ -23,6 +24,7 @@ export const SelectedStructuredNames = () => {
.map(v => {
return {
id: v,
+ structuredName: state.map[v],
formattedName: formatName(state.map[v]),
}
}),
@@ -74,7 +76,8 @@ export const SelectedStructuredNames = () => {
))}
{selection.map(v => (
-
+
+
{v.formattedName}
)
}
diff --git a/app/frontend/src/components/SnameTooltip.js b/app/frontend/src/components/SnameTooltip.js
new file mode 100644
index 00000000..5ad7a5de
--- /dev/null
+++ b/app/frontend/src/components/SnameTooltip.js
@@ -0,0 +1,53 @@
+import React from 'react'
+import { useSelector } from 'react-redux'
+
+export const SnameTooltip = ({ sname }) => {
+ console.log(sname)
+ const qualifierName = {
+ 1: 'Chronostratigraphy',
+ 2: 'Lithostratigraphy',
+ 3: 'Regional Standard',
+ 4: 'Chemostratigraphy',
+ 5: 'Biostratigraphy',
+ 6: 'Sequence-stratigraphy',
+ }
+
+ const data = useSelector(state => {
+ return {
+ ...sname,
+ reference: state.map[sname.reference_id],
+ name: state.map[sname.name_id],
+ qualifier: state.map[sname.qualifier_id],
+ qualifierName:
+ state.map[state.map[sname.qualifier_id].qualifier_name_id],
+ location: state.map[sname.location_id],
+ }
+ })
+
+ const remarks = data.remarks ?
Remarks: {data.remarks}
: <>>
+ const reference = data.reference ? (
+
{`${data.reference.title} (${data.reference.year})`}
+ ) : (
+ <>>
+ )
+
+ if (!data.name || !data.location || !data.qualifierName)
+ return <>>
+
+ return (
+
+
+
{data.name.name}
+
{data.location.name}
+
{data.qualifierName.name}
+
+ {`${
+ qualifierName[data.qualifier.stratigraphic_qualifier_id]
+ } level ${1}`}
+
+ {remarks}
+ {reference}
+
+
+ )
+}
diff --git a/app/frontend/src/components/Submit.js b/app/frontend/src/components/Submit.js
index cb3662e6..2b7d8f26 100644
--- a/app/frontend/src/components/Submit.js
+++ b/app/frontend/src/components/Submit.js
@@ -69,8 +69,6 @@ export const Submit = () => {
),
}
- console.log(submit_data)
-
const csrfmiddlewaretoken = document.querySelector(
'[name=csrfmiddlewaretoken]'
).value
diff --git a/app/frontend/src/components/__tests__/RelationSelector.test.js b/app/frontend/src/components/__tests__/RelationSelector.test.js
index 539ad0cb..c50dc2a3 100644
--- a/app/frontend/src/components/__tests__/RelationSelector.test.js
+++ b/app/frontend/src/components/__tests__/RelationSelector.test.js
@@ -187,7 +187,7 @@ describe('When some structured names have been selected, but no relations formed
expect(relationSelectorOnTheLeft.childNodes).toHaveLength(3)
relationSelectorOnTheLeft.childNodes.forEach(childNode => {
- expect(options).toContain(childNode.innerHTML)
+ expect(options).toContain(childNode.childNodes[1].innerHTML)
})
})
@@ -198,7 +198,9 @@ describe('When some structured names have been selected, but no relations formed
const options = [dbSname1Formatted, dbSname2Formatted]
expect(relationSelectorOnTheRight.childNodes).toHaveLength(2)
relationSelectorOnTheRight.childNodes.forEach(childNode => {
- expect(options).toContain(childNode.childNodes[3].innerHTML)
+ expect(options).toContain(
+ childNode.childNodes[1].childNodes[3].innerHTML
+ )
})
})
@@ -313,7 +315,8 @@ describe('When some structured names have been selected, but no relations formed
const relationSelectorOnTheRight = screen.getByTestId(
relationSelectorSidesTestIds.right
)
- const firstOption = relationSelectorOnTheRight.childNodes[0].lastChild
+ const firstOption =
+ relationSelectorOnTheRight.childNodes[0].childNodes[1].childNodes[3]
const firstOptionsFormattedName = firstOption.innerHTML
userEvent.click(firstOption)
const relationsList = screen.getByTestId('active-relations-list')
@@ -324,7 +327,8 @@ describe('When some structured names have been selected, but no relations formed
const relationSelectorOnTheRight = screen.getByTestId(
relationSelectorSidesTestIds.right
)
- const firstOption = relationSelectorOnTheRight.childNodes[0].lastChild
+ const firstOption =
+ relationSelectorOnTheRight.childNodes[0].childNodes[1].childNodes[3]
userEvent.click(firstOption)
const checkbox = await screen.findByRole('checkbox')
expect(checkbox).not.toBeChecked()
diff --git a/app/frontend/src/components/__tests__/Sname.test.js b/app/frontend/src/components/__tests__/Sname.test.js
index d37861c7..5ce78822 100644
--- a/app/frontend/src/components/__tests__/Sname.test.js
+++ b/app/frontend/src/components/__tests__/Sname.test.js
@@ -68,12 +68,8 @@ describe('Sname', () => {
})
test('shows structured name information', () => {
- const name = screen.getByText(/1a/)
- const qualifier = screen.getByText(/Bio_Ammonite/)
- const location = screen.getByText(/Alabama/)
- expect(name).toBeInTheDocument()
- expect(qualifier).toBeInTheDocument()
- expect(location).toBeInTheDocument()
+ const sname = screen.getByText('1a / Bio_Ammonite / Alabama')
+ expect(sname).toBeInTheDocument()
})
test('shows "delete" button', () => {
diff --git a/app/frontend/src/index.css b/app/frontend/src/index.css
index bd20f829..2ea36ff6 100644
--- a/app/frontend/src/index.css
+++ b/app/frontend/src/index.css
@@ -27,4 +27,29 @@
.check-notop {
top: 0 !important;
-}
\ No newline at end of file
+}
+
+.tooltip-wrapper {
+ position: relative;
+ opacity: 0;
+}
+
+.tooltip-content {
+ display: none;
+ position: absolute;
+ max-width: 400px;
+ max-height: 200px;
+ overflow-y: auto;
+ transform: translateY(-100%);
+}
+
+.tooltip:hover > .tooltip-wrapper > .tooltip-content {
+ display: inline-block;
+}
+
+.tooltip:hover > .tooltip-wrapper {
+ width: auto;
+ height: auto;
+ opacity: 1;
+ transition: opacity 0.1s linear 1.6s;
+}