From cb6e028aaa71e9fe959dd3c755fb00c5e78ee303 Mon Sep 17 00:00:00 2001 From: Yelena Cox Date: Tue, 12 Nov 2024 10:31:22 -0600 Subject: [PATCH 01/30] committing to change branches --- src/components/Projects/Tables/TableStyling.scss | 11 +++++------ .../Projects/Terminologies/Terminology.jsx | 13 ++++++++++++- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/components/Projects/Tables/TableStyling.scss b/src/components/Projects/Tables/TableStyling.scss index 64e5b6e..3e9e654 100644 --- a/src/components/Projects/Tables/TableStyling.scss +++ b/src/components/Projects/Tables/TableStyling.scss @@ -81,14 +81,13 @@ input::file-selector-button:hover { white-space: nowrap; } display: flex; + &:hover .remove-mapping { + transition: all 0.4s linear; + opacity: 1; + } .remove-mapping { - padding-left:.25rem; + padding-left: 0.25rem; cursor: pointer; opacity: 0; - - &:hover { - transition: all .4s linear; - opacity: 1; - } } } diff --git a/src/components/Projects/Terminologies/Terminology.jsx b/src/components/Projects/Terminologies/Terminology.jsx index 6c7699b..4488e1d 100644 --- a/src/components/Projects/Terminologies/Terminology.jsx +++ b/src/components/Projects/Terminologies/Terminology.jsx @@ -14,7 +14,11 @@ import { Table, Tooltip, } from 'antd'; -import { CloseCircleOutlined } from '@ant-design/icons'; +import { + CloseCircleOutlined, + DownOutlined, + UpOutlined, +} from '@ant-design/icons'; import { EditMappingsModal } from './EditMappingModal'; import { EditTerminologyDetails } from './EditTerminologyDetails'; import { SettingsDropdownTerminology } from '../../Manager/Dropdown/SettingsDropdownTerminology'; @@ -153,6 +157,13 @@ It then shows the mappings as table data and alows the user to delete a mapping if (variableMappings && variableMappings.mappings?.length) { return variableMappings.mappings.map(code => (
+ + {/* */} + + + {code.display ? code.display : code.code} From ef6d90deed5f1cd5b32e6a06238e0440b10b81a5 Mon Sep 17 00:00:00 2001 From: Yelena Cox Date: Tue, 12 Nov 2024 11:37:57 -0600 Subject: [PATCH 02/30] committing to go back to main --- src/components/Manager/Utilitiy.jsx | 11 +++++++ .../Projects/Tables/TableDetails.jsx | 27 ++++++++++++---- .../Projects/Tables/TableStyling.scss | 10 ++++-- .../Projects/Terminologies/Terminology.jsx | 32 +++++++++++-------- 4 files changed, 58 insertions(+), 22 deletions(-) diff --git a/src/components/Manager/Utilitiy.jsx b/src/components/Manager/Utilitiy.jsx index 787a5d3..0cbe232 100644 --- a/src/components/Manager/Utilitiy.jsx +++ b/src/components/Manager/Utilitiy.jsx @@ -62,3 +62,14 @@ export const ontologyCounts = arr => { }; export const cleanedName = data => data?.toLowerCase().replaceAll(' ', '_'); + +export const mappingTooltip = code => { + return ( + <> +
+
{code.code}
+
{code?.display}
+
+ + ); +}; diff --git a/src/components/Projects/Tables/TableDetails.jsx b/src/components/Projects/Tables/TableDetails.jsx index e722a53..e3e9aea 100644 --- a/src/components/Projects/Tables/TableDetails.jsx +++ b/src/components/Projects/Tables/TableDetails.jsx @@ -15,7 +15,11 @@ import { Table, Tooltip, } from 'antd'; -import { CloseCircleOutlined } from '@ant-design/icons'; +import { + CloseCircleOutlined, + UpCircleOutlined, + DownCircleOutlined, +} from '@ant-design/icons'; import { EditTableDetails } from './EditTableDetails'; import { DeleteTable } from './DeleteTable'; import { LoadVariables } from './LoadVariables'; @@ -31,6 +35,7 @@ import { SettingsDropdownTable } from '../../Manager/Dropdown/SettingsDropdownTa import { RequiredLogin } from '../../Auth/RequiredLogin'; import { FilterSelect } from '../../Manager/MappingsFunctions/FilterSelect'; import { SearchContext } from '../../../Contexts/SearchContext'; +import { ellipsisString } from '../../Manager/Utilitiy'; export const TableDetails = () => { const [form] = Form.useForm(); @@ -248,16 +253,26 @@ It then shows the mappings as table data and alows the user to delete a mapping const variableMappings = mapping.find( item => item?.code === variable?.code ); - if (variableMappings && variableMappings.mappings?.length) { return variableMappings.mappings.map(code => ( -
+
+ + + + - {' '} - {code.display} + 25 + ? mappingTooltip(code) + : code.code + } + > + {ellipsisString(code.display ? code.display : code.code, '25')} + handleRemoveMapping(variableMappings, code)} > diff --git a/src/components/Projects/Tables/TableStyling.scss b/src/components/Projects/Tables/TableStyling.scss index 3e9e654..f6adc5e 100644 --- a/src/components/Projects/Tables/TableStyling.scss +++ b/src/components/Projects/Tables/TableStyling.scss @@ -81,13 +81,19 @@ input::file-selector-button:hover { white-space: nowrap; } display: flex; - &:hover .remove-mapping { + &:hover .mapping_actions { transition: all 0.4s linear; opacity: 1; } - .remove-mapping { + .mapping_actions { padding-left: 0.25rem; cursor: pointer; opacity: 0; } } + +.mapping_votes { + display: flex; + gap: 2px; + padding-right: 0.25rem; +} diff --git a/src/components/Projects/Terminologies/Terminology.jsx b/src/components/Projects/Terminologies/Terminology.jsx index 4488e1d..234c6dd 100644 --- a/src/components/Projects/Terminologies/Terminology.jsx +++ b/src/components/Projects/Terminologies/Terminology.jsx @@ -16,8 +16,8 @@ import { } from 'antd'; import { CloseCircleOutlined, - DownOutlined, - UpOutlined, + DownCircleOutlined, + UpCircleOutlined, } from '@ant-design/icons'; import { EditMappingsModal } from './EditMappingModal'; import { EditTerminologyDetails } from './EditTerminologyDetails'; @@ -32,6 +32,7 @@ import { PreferredTerminology } from './PreferredTerminology'; import { SearchContext } from '../../../Contexts/SearchContext'; import { FilterSelect } from '../../Manager/MappingsFunctions/FilterSelect'; import { AssignMappingsViaButton } from './AssignMappingsViaButton'; +import { ellipsisString, mappingTooltip } from '../../Manager/Utilitiy'; export const Terminology = () => { const [form] = Form.useForm(); @@ -153,24 +154,26 @@ It then shows the mappings as table data and alows the user to delete a mapping const variableMappings = mapping.find( item => item?.code === variable?.code ); - if (variableMappings && variableMappings.mappings?.length) { return variableMappings.mappings.map(code => ( -
- - {/* */} - - +
+ + + - - {code.display ? code.display : code.code} + 25 + ? mappingTooltip(code) + : code.code + } + > + {ellipsisString(code.display ? code.display : code.code, '25')} handleRemoveMapping(variableMappings, code)} > @@ -304,8 +307,9 @@ It then shows the mappings as table data and alows the user to delete a mapping { title: 'Description', dataIndex: 'description', + width: 300, }, - { title: 'Mapped Terms', dataIndex: 'mapped_terms', width: 90 }, + { title: 'Mapped Terms', dataIndex: 'mapped_terms', width: 120 }, { title: '', dataIndex: 'delete_column', From fed2769f6082f592061bfba83ae6df78c5446353 Mon Sep 17 00:00:00 2001 From: Yelena Cox Date: Tue, 12 Nov 2024 22:08:16 -0600 Subject: [PATCH 03/30] Began work on voting on a mapping --- .../MappingsFunctions/MappingVotes.jsx | 41 +++++++++++ .../Projects/Tables/TableDetails.jsx | 16 +++-- .../Projects/Tables/TableStyling.scss | 10 ++- .../Projects/Terminologies/Terminology.jsx | 68 +++++++++++++------ 4 files changed, 108 insertions(+), 27 deletions(-) create mode 100644 src/components/Manager/MappingsFunctions/MappingVotes.jsx diff --git a/src/components/Manager/MappingsFunctions/MappingVotes.jsx b/src/components/Manager/MappingsFunctions/MappingVotes.jsx new file mode 100644 index 0000000..84512a8 --- /dev/null +++ b/src/components/Manager/MappingsFunctions/MappingVotes.jsx @@ -0,0 +1,41 @@ +export const MappingVotes = ( + variableMappings, + code, + user, + vote, + vocabUrl, + terminologyId, + notification +) => { + const mappingVoteDTO = { + editor: user?.email, + vote: vote, + }; + + return fetch( + `${vocabUrl}/Terminology/${terminologyId}/user_input/${variableMappings?.code}/${code?.code}/mapping_votes`, + { + method: 'PUT', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify(mappingVoteDTO), + } + ) + .then(res => { + if (res.ok) { + return res.json(); + } else { + throw new Error('An unknown error occurred.'); + } + }) + .catch(error => { + if (error) { + notification.error({ + message: 'Error', + description: 'An error occurred saving the ontology preferences.', + }); + } + return error; + }); +}; diff --git a/src/components/Projects/Tables/TableDetails.jsx b/src/components/Projects/Tables/TableDetails.jsx index e3e9aea..c8f9398 100644 --- a/src/components/Projects/Tables/TableDetails.jsx +++ b/src/components/Projects/Tables/TableDetails.jsx @@ -235,13 +235,15 @@ and returns the length of the mapping array (i.e. returns the number of variable It then shows the mappings as table data and alows the user to delete a mapping from the table.*/ const noMapping = variable => { return ( - +
+ +
); }; diff --git a/src/components/Projects/Tables/TableStyling.scss b/src/components/Projects/Tables/TableStyling.scss index f6adc5e..89ad784 100644 --- a/src/components/Projects/Tables/TableStyling.scss +++ b/src/components/Projects/Tables/TableStyling.scss @@ -81,6 +81,7 @@ input::file-selector-button:hover { white-space: nowrap; } display: flex; + align-items: center; &:hover .mapping_actions { transition: all 0.4s linear; opacity: 1; @@ -94,6 +95,13 @@ input::file-selector-button:hover { .mapping_votes { display: flex; - gap: 2px; + flex-direction: column; + align-items: center; + // gap: 2px; padding-right: 0.25rem; + font-size: 0.7rem; +} + +.no_mapping_button { + padding-left: 2rem; } diff --git a/src/components/Projects/Terminologies/Terminology.jsx b/src/components/Projects/Terminologies/Terminology.jsx index 234c6dd..8bb2d56 100644 --- a/src/components/Projects/Terminologies/Terminology.jsx +++ b/src/components/Projects/Terminologies/Terminology.jsx @@ -16,8 +16,8 @@ import { } from 'antd'; import { CloseCircleOutlined, - DownCircleOutlined, - UpCircleOutlined, + DownOutlined, + UpOutlined, } from '@ant-design/icons'; import { EditMappingsModal } from './EditMappingModal'; import { EditTerminologyDetails } from './EditTerminologyDetails'; @@ -33,6 +33,7 @@ import { SearchContext } from '../../../Contexts/SearchContext'; import { FilterSelect } from '../../Manager/MappingsFunctions/FilterSelect'; import { AssignMappingsViaButton } from './AssignMappingsViaButton'; import { ellipsisString, mappingTooltip } from '../../Manager/Utilitiy'; +import { MappingVotes } from '../../Manager/MappingsFunctions/MappingVotes'; export const Terminology = () => { const [form] = Form.useForm(); @@ -129,21 +130,23 @@ and returns the length of the mapping array (i.e. returns the number of codes ma It then shows the mappings as table data and alows the user to delete a mapping from the table.*/ const noMapping = variable => ( - +
+ +
); const matchCode = variable => { @@ -158,8 +161,35 @@ It then shows the mappings as table data and alows the user to delete a mapping return variableMappings.mappings.map(code => (
- - + + MappingVotes( + variableMappings, + code, + user, + 'up', + vocabUrl, + terminologyId, + notification + ) + } + /> + 0 + + MappingVotes( + variableMappings, + code, + user, + 'down', + vocabUrl, + terminologyId, + notification + ) + } + /> Date: Wed, 13 Nov 2024 12:48:58 -0600 Subject: [PATCH 04/30] Began work on adding mapping comments --- .../MappingsFunctions/FilterOntology.jsx | 17 +-- .../MappingsFunctions/MappingComments.jsx | 101 ++++++++++++++++++ .../MappingsFunctions/MappingVotes.jsx | 2 +- .../SelectPreferredTerminologies.jsx | 33 +----- .../Projects/Terminologies/Terminology.jsx | 19 ++++ 5 files changed, 123 insertions(+), 49 deletions(-) create mode 100644 src/components/Manager/MappingsFunctions/MappingComments.jsx diff --git a/src/components/Manager/MappingsFunctions/FilterOntology.jsx b/src/components/Manager/MappingsFunctions/FilterOntology.jsx index 595e074..167d012 100644 --- a/src/components/Manager/MappingsFunctions/FilterOntology.jsx +++ b/src/components/Manager/MappingsFunctions/FilterOntology.jsx @@ -87,21 +87,6 @@ export const FilterOntology = ({ } }; - const selectedOntDisplay = (ont, i) => { - return ( - <> -
-
-
-
{ont?.curie}
-
-
{ont?.ontology_title}
-
-
- - ); - }; - const checkBoxDisplay = (ont, i) => { return ( <> @@ -211,7 +196,7 @@ export const FilterOntology = ({ value={selected} onChange={e => onCheckboxChange(e, selected)} > - {selectedOntDisplay(selected, i)} + {checkBoxDisplay(selected, i)} ))}
diff --git a/src/components/Manager/MappingsFunctions/MappingComments.jsx b/src/components/Manager/MappingsFunctions/MappingComments.jsx new file mode 100644 index 0000000..6b6ce4d --- /dev/null +++ b/src/components/Manager/MappingsFunctions/MappingComments.jsx @@ -0,0 +1,101 @@ +import { Button, Form, Input, Modal, notification } from 'antd'; +import { useContext } from 'react'; +import { myContext } from '../../../App'; + +export const MappingComments = ({ + code, + variableMappings, + setComment, + terminologyId, +}) => { + const [form] = Form.useForm(); + const { vocabUrl, user } = useContext(myContext); + const { TextArea } = Input; + + const onClose = () => { + setComment(null); + }; + + const onFinish = values => { + const mappingCommentDTO = { + editor: user?.email, + note: values.comment, + }; + + return fetch( + `${vocabUrl}/Terminology/${terminologyId}/user_input/${variableMappings}/${code}/mapping_conversations`, + { + method: 'PUT', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify(mappingCommentDTO), + } + ) + .then(res => { + if (res.ok) { + return res.json(); + } else { + throw new Error('An unknown error occurred.'); + } + }) + .catch(error => { + if (error) { + notification.error({ + message: 'Error', + description: 'An error occurred saving the comment.', + }); + } + return error; + }); + }; + + return ( + <> + Close]} + maskClosable={false} + closeIcon={false} + destroyOnClose={true} + > +
{ + form.validateFields().then(values => { + onFinish(values); + onClose(); + }); + }} + preserve={false} + > + +