From 19799c0eb8465c72fd4d26648751a2f992b16ec0 Mon Sep 17 00:00:00 2001 From: Adam Gibson Date: Thu, 7 Mar 2024 08:35:51 -0600 Subject: [PATCH 01/11] SCRUM-3794 add NOTTemplate --- src/main/cliapp/src/components/Templates/NotTemplate.js | 8 ++++++++ .../diseaseAnnotationsPage/DiseaseAnnotationsTable.js | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 src/main/cliapp/src/components/Templates/NotTemplate.js diff --git a/src/main/cliapp/src/components/Templates/NotTemplate.js b/src/main/cliapp/src/components/Templates/NotTemplate.js new file mode 100644 index 000000000..5538a06fa --- /dev/null +++ b/src/main/cliapp/src/components/Templates/NotTemplate.js @@ -0,0 +1,8 @@ +import React from 'react' +import { EllipsisTableCell } from '../EllipsisTableCell'; + +export const NotTemplate = ({ value }) => { + if (value === null || value === undefined || typeof value !== 'boolean') return null; + const textString = value ? "NOT" : ""; + return {textString}; +} diff --git a/src/main/cliapp/src/containers/diseaseAnnotationsPage/DiseaseAnnotationsTable.js b/src/main/cliapp/src/containers/diseaseAnnotationsPage/DiseaseAnnotationsTable.js index 7a49b220b..bc63b0376 100644 --- a/src/main/cliapp/src/containers/diseaseAnnotationsPage/DiseaseAnnotationsTable.js +++ b/src/main/cliapp/src/containers/diseaseAnnotationsPage/DiseaseAnnotationsTable.js @@ -22,6 +22,7 @@ import { DiseaseTemplate } from '../../components/Templates/DiseaseTemplate'; import { GenomicEntityTemplate } from '../../components/Templates/genomicEntity/GenomicEntityTemplate'; import { GenomicEntityListTemplate } from '../../components/Templates/genomicEntity/GenomicEntityListTemplate'; import { BooleanTemplate } from '../../components/Templates/BooleanTemplate'; +import { NotTemplate } from '../../components/Templates/NotTemplate'; import { ControlledVocabularyDropdown } from '../../components/ControlledVocabularySelector'; import { ConditionRelationHandleDropdown } from '../../components/ConditionRelationHandleSelector'; @@ -935,7 +936,7 @@ export const DiseaseAnnotationsTable = () => { { field: "negated", header: "Negated", - body: (rowData) => , + body: (rowData) => , sortable: true, filterConfig: FILTER_CONFIGS.negatedFilterConfig, editor: (props) => negatedEditor(props) From a0d0e7c89669eaecbfc71a1b684cb2c6a4aa50d0 Mon Sep 17 00:00:00 2001 From: Adam Gibson Date: Thu, 7 Mar 2024 09:03:42 -0600 Subject: [PATCH 02/11] SCRUM-3794 add tests for NotTemplate --- .../Templates/__tests__/NotTemplate.test.js | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/main/cliapp/src/components/Templates/__tests__/NotTemplate.test.js diff --git a/src/main/cliapp/src/components/Templates/__tests__/NotTemplate.test.js b/src/main/cliapp/src/components/Templates/__tests__/NotTemplate.test.js new file mode 100644 index 000000000..0118a4c0e --- /dev/null +++ b/src/main/cliapp/src/components/Templates/__tests__/NotTemplate.test.js @@ -0,0 +1,25 @@ +import { render } from '@testing-library/react'; +import { NotTemplate } from '../NotTemplate'; +import '../../../tools/jest/setupTests'; + +describe('NotTemplate', () => { + + it('should return null when value is null', () => { + const { container } = render(); + expect(container.firstChild).toBeNull(); + }); + + it('should return a component with the text "NOT" when the value is true', () => { + const { getByText } = render(); + expect(getByText("NOT")).toBeInTheDocument(); + }); + it('should return a component with an empty string when the value is false', () => { + const { container } = render(); + expect(container.textContent).toBe(''); + }); + + it('should return null when value is not a boolean', () => { + const { container } = render(); + expect(container.firstChild).toBeNull(); + }); +}); \ No newline at end of file From 6a4f71574291e685cc5dbf21478b57bd1d5fdb4b Mon Sep 17 00:00:00 2001 From: Adam Gibson Date: Fri, 8 Mar 2024 08:42:07 -0600 Subject: [PATCH 03/11] SCRUM-3794 add NotEditor --- .../src/components/Editors/NotEditor.js | 29 +++++++++++++++++++ .../DiseaseAnnotationsTable.js | 28 +++++------------- 2 files changed, 37 insertions(+), 20 deletions(-) create mode 100644 src/main/cliapp/src/components/Editors/NotEditor.js diff --git a/src/main/cliapp/src/components/Editors/NotEditor.js b/src/main/cliapp/src/components/Editors/NotEditor.js new file mode 100644 index 000000000..803f10964 --- /dev/null +++ b/src/main/cliapp/src/components/Editors/NotEditor.js @@ -0,0 +1,29 @@ +import React, { useState } from 'react'; +import { Dropdown } from "primereact/dropdown"; + +export function NotEditor({ props, value, editorChange }) { + const [selectedValue, setSelectedValue] = useState(value); + const textString = value ? "NOT" : ""; + const options = [ + { label: "NOT", value: true }, + { label: "null", value: false } + ]; + + const onChange = (e) => { + setSelectedValue(e.value); + editorChange(e, props); + } + + return ( + <> + onChange(e)} + showClear={false} + placeholder={textString} + style={{ width: '100%' }} + /> + + ); +} diff --git a/src/main/cliapp/src/containers/diseaseAnnotationsPage/DiseaseAnnotationsTable.js b/src/main/cliapp/src/containers/diseaseAnnotationsPage/DiseaseAnnotationsTable.js index bc63b0376..ba40bf144 100644 --- a/src/main/cliapp/src/containers/diseaseAnnotationsPage/DiseaseAnnotationsTable.js +++ b/src/main/cliapp/src/containers/diseaseAnnotationsPage/DiseaseAnnotationsTable.js @@ -24,6 +24,8 @@ import { GenomicEntityListTemplate } from '../../components/Templates/genomicEnt import { BooleanTemplate } from '../../components/Templates/BooleanTemplate'; import { NotTemplate } from '../../components/Templates/NotTemplate'; +import { NotEditor } from '../../components/Editors/NotEditor'; + import { ControlledVocabularyDropdown } from '../../components/ControlledVocabularySelector'; import { ConditionRelationHandleDropdown } from '../../components/ConditionRelationHandleSelector'; import { ControlledVocabularyMultiSelectDropdown } from '../../components/ControlledVocabularyMultiSelector'; @@ -429,26 +431,12 @@ export const DiseaseAnnotationsTable = () => { ); }; - const onNegatedEditorValueChange = (props, event) => { - let updatedAnnotations = [...props.props.value]; - if (event.value || event.value === '') { - updatedAnnotations[props.rowIndex].negated = JSON.parse(event.value.name); - } - }; + const onNegatedEditorValueChange = (event, props) => { + if(event.value === undefined || event.value === null) return; - const negatedEditor = (props) => { - return ( - <> - - - - ); - }; + let updatedAnnotations = [...props.props.value]; + updatedAnnotations[props.rowIndex].negated = event.value; + } const onInternalEditorValueChange = (props, event) => { let updatedAnnotations = [...props.props.value]; @@ -939,7 +927,7 @@ export const DiseaseAnnotationsTable = () => { body: (rowData) => , sortable: true, filterConfig: FILTER_CONFIGS.negatedFilterConfig, - editor: (props) => negatedEditor(props) + editor: (props) => }, { field: "diseaseAnnotationObject.name", From 9fc618df9e79b015d8b614831eb2a7f1319d03c1 Mon Sep 17 00:00:00 2001 From: Adam Gibson Date: Mon, 11 Mar 2024 09:12:51 -0500 Subject: [PATCH 04/11] SCRUM-3794 add tests for NotEditor --- .../src/components/Editors/NotEditor.js | 1 + .../Editors/__tests__/NotEditor.test.js | 64 +++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 src/main/cliapp/src/components/Editors/__tests__/NotEditor.test.js diff --git a/src/main/cliapp/src/components/Editors/NotEditor.js b/src/main/cliapp/src/components/Editors/NotEditor.js index 803f10964..f73b9aa6f 100644 --- a/src/main/cliapp/src/components/Editors/NotEditor.js +++ b/src/main/cliapp/src/components/Editors/NotEditor.js @@ -17,6 +17,7 @@ export function NotEditor({ props, value, editorChange }) { return ( <> onChange(e)} diff --git a/src/main/cliapp/src/components/Editors/__tests__/NotEditor.test.js b/src/main/cliapp/src/components/Editors/__tests__/NotEditor.test.js new file mode 100644 index 000000000..46575434c --- /dev/null +++ b/src/main/cliapp/src/components/Editors/__tests__/NotEditor.test.js @@ -0,0 +1,64 @@ +import { render, fireEvent, within } from '@testing-library/react'; +import { NotEditor } from '../NotEditor'; +import '../../../tools/jest/setupTests'; + +describe('NotEditor', () => { + it('should display "null" as the placeholder text when the initial value is false', () => { + const props = {}; + const value = false; + const editorChange = jest.fn(); + + const result = render(); + + expect(result.getAllByText("null")).toHaveLength(2); + }); + + it('should render a Dropdown component with no options when value prop is undefined', () => { + const props = {}; + const value = undefined; + const editorChange = jest.fn(); + + const result = render(); + + + expect(result.getByText("empty")).toBeInTheDocument(); + }); + + it('should update the selected value when an option is selected', () => { + const props = {}; + const value = false; + const editorChange = jest.fn(); + + + const result = render(); + const span = result.container.getElementsByTagName('span')[0]; + + expect(within(span).getByText('null')).toBeInTheDocument(); + + fireEvent.click(span); + + const option = result.getAllByText('NOT'); + fireEvent.click(option[0]); + const updatedSpan = result.container.getElementsByTagName('span')[0]; + + + expect(within(updatedSpan).getByText('NOT')).toBeInTheDocument(); + }); + + it('should call editorChange when an option is selected', () => { + const props = {}; + const value = true; + const editorChange = jest.fn(); + const result = render(); + const span = result.container.getElementsByTagName('span')[0]; + + fireEvent.click(span); + + + const option = result.getAllByText('null'); + fireEvent.click(option[0]); + + expect(editorChange).toHaveBeenCalledTimes(1); + }); + +}); \ No newline at end of file From 52725d046bb9fffc502bc30cd9485ac38deba112 Mon Sep 17 00:00:00 2001 From: Adam Gibson Date: Mon, 11 Mar 2024 11:21:43 -0500 Subject: [PATCH 05/11] SCRUM-3794 update filter dropdown and header name --- .../components/Filters/FilterComponentBinaryDropDown.js | 2 +- src/main/cliapp/src/constants/FilterFields.js | 8 ++++---- .../diseaseAnnotationsPage/DiseaseAnnotationsTable.js | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/cliapp/src/components/Filters/FilterComponentBinaryDropDown.js b/src/main/cliapp/src/components/Filters/FilterComponentBinaryDropDown.js index e15175c72..fb80666fd 100644 --- a/src/main/cliapp/src/components/Filters/FilterComponentBinaryDropDown.js +++ b/src/main/cliapp/src/components/Filters/FilterComponentBinaryDropDown.js @@ -2,7 +2,7 @@ import React, { useRef } from "react"; import { Dropdown } from "primereact/dropdown"; export function FilterComponentBinaryDropDown({ isInEditMode, filterConfig, currentFilters, onFilter }) { - const options = useRef(["true", "false"]); + const options = useRef(filterConfig.options || ["true", "false"]); const fieldSet = filterConfig.fieldSets[0]; diff --git a/src/main/cliapp/src/constants/FilterFields.js b/src/main/cliapp/src/constants/FilterFields.js index 56032443e..e1b604f48 100644 --- a/src/main/cliapp/src/constants/FilterFields.js +++ b/src/main/cliapp/src/constants/FilterFields.js @@ -594,7 +594,7 @@ export const FILTER_CONFIGS = Object.freeze({ isExtinctFilterConfig: { filterComponentType: "dropdown", fieldSets: [FIELD_SETS.isExtinctFieldSet] }, obsoleteFilterConfig: { filterComponentType: "dropdown", fieldSets: [FIELD_SETS.obsoleteFieldSet] }, internalFilterConfig: { filterComponentType: "dropdown", fieldSets: [FIELD_SETS.internalFieldSet] }, - negatedFilterConfig: { filterComponentType: "dropdown", fieldSets: [FIELD_SETS.negatedFieldSet] }, + negatedFilterConfig: { filterComponentType: "dropdown", fieldSets: [FIELD_SETS.negatedFieldSet], options: [ { label: "NOT", value: "true" }, { label: "null", value: "false" } ] }, annotationTypeFilterConfig: { filterComponentType: "multiselect", fieldSets: [FIELD_SETS.annotationTypeFieldSet], aggregationFieldSet: FIELD_SETS.daAggregationFieldSet, useKeywordFields: true }, diseaseDataProviderFilterConfig: { filterComponentType: "multiselect", fieldSets: [FIELD_SETS.dataProviderFieldSet], aggregationFieldSet: FIELD_SETS.daAggregationFieldSet, useKeywordFields: true }, @@ -605,12 +605,12 @@ export const FILTER_CONFIGS = Object.freeze({ agmDataProviderFilterConfig: { filterComponentType: "multiselect", fieldSets: [FIELD_SETS.dataProviderFieldSet], aggregationFieldSet: FIELD_SETS.agmAggregationFieldSet, useKeywordFields: true }, diseaseQualifiersFilterConfig: { filterComponentType: "multiselect", fieldSets: [FIELD_SETS.diseaseQualifiersFieldSet], aggregationFieldSet: FIELD_SETS.daAggregationFieldSet, useKeywordFields: true }, relationFilterConfig: { filterComponentType: "multiselect", fieldSets: [FIELD_SETS.relationFieldSet], aggregationFieldSet: FIELD_SETS.daAggregationFieldSet, useKeywordFields: true }, - paRelationFilterConfig: { filterComponentType: "multiselect", fieldSets: [FIELD_SETS.relationFieldSet], aggregationFieldSet: FIELD_SETS.paAggregationFieldSet, useKeywordFields: true }, + paRelationFilterConfig: { filterComponentType: "multiselect", fieldSets: [FIELD_SETS.relationFieldSet], aggregationFieldSet: FIELD_SETS.paAggregationFieldSet, useKeywordFields: true }, geneticModifierRelationFilterConfig: { filterComponentType: "multiselect", fieldSets: [FIELD_SETS.geneticModifierRelationFieldSet], aggregationFieldSet: FIELD_SETS.daAggregationFieldSet, useKeywordFields: true }, geneticSexFilterConfig: { filterComponentType: "multiselect", fieldSets: [FIELD_SETS.geneticSexFieldSet], aggregationFieldSet: FIELD_SETS.daAggregationFieldSet, useKeywordFields: true }, secondaryDataProviderFilterConfig: { filterComponentType: "multiselect", fieldSets: [FIELD_SETS.secondaryDataProviderFieldSet], aggregationFieldSet: FIELD_SETS.daAggregationFieldSet, useKeywordFields: true }, - speciesDataProviderFilterConfig: { filterComponentType: "multiselect", fieldSets: [FIELD_SETS.dataProviderFieldSet], aggregationFieldSet: FIELD_SETS.speciesAggregationFieldSet, useKeywordFields: true }, - evidenceCodesFilterConfig: { filterComponentType: "multiselect", fieldSets: [FIELD_SETS.evidenceCodesFieldSet], aggregationFieldSet: FIELD_SETS.daAggregationFieldSet, useKeywordFields: true }, + speciesDataProviderFilterConfig: { filterComponentType: "multiselect", fieldSets: [FIELD_SETS.dataProviderFieldSet], aggregationFieldSet: FIELD_SETS.speciesAggregationFieldSet, useKeywordFields: true }, + evidenceCodesFilterConfig: { filterComponentType: "multiselect", fieldSets: [FIELD_SETS.evidenceCodesFieldSet], aggregationFieldSet: FIELD_SETS.daAggregationFieldSet, useKeywordFields: true }, variantDataProviderFilterConfig: { filterComponentType: "multiselect", fieldSets: [FIELD_SETS.dataProviderFieldSet], aggregationFieldSet: FIELD_SETS.variantAggregationFieldSet, useKeywordFields: true }, variantStatusFilterConfig: { filterComponentType: "multiselect", fieldSets: [FIELD_SETS.variantStatusFieldSet], aggregationFieldSet: FIELD_SETS.variantAggregationFieldSet,useKeywordFields: true }, diff --git a/src/main/cliapp/src/containers/diseaseAnnotationsPage/DiseaseAnnotationsTable.js b/src/main/cliapp/src/containers/diseaseAnnotationsPage/DiseaseAnnotationsTable.js index ba40bf144..6e155a4aa 100644 --- a/src/main/cliapp/src/containers/diseaseAnnotationsPage/DiseaseAnnotationsTable.js +++ b/src/main/cliapp/src/containers/diseaseAnnotationsPage/DiseaseAnnotationsTable.js @@ -923,7 +923,7 @@ export const DiseaseAnnotationsTable = () => { }, { field: "negated", - header: "Negated", + header: "Not", body: (rowData) => , sortable: true, filterConfig: FILTER_CONFIGS.negatedFilterConfig, From 060f9626e945ab8f0b3744fd6ee7ee05d3eb0df0 Mon Sep 17 00:00:00 2001 From: Adam Gibson Date: Mon, 11 Mar 2024 11:50:04 -0500 Subject: [PATCH 06/11] SCRUM-3794 add NotEditor to NewAnnotationForm --- .../cliapp/src/components/Editors/NotEditor.js | 1 + .../diseaseAnnotationsPage/NewAnnotationForm.js | 17 +++++------------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/main/cliapp/src/components/Editors/NotEditor.js b/src/main/cliapp/src/components/Editors/NotEditor.js index f73b9aa6f..c9dec2ae1 100644 --- a/src/main/cliapp/src/components/Editors/NotEditor.js +++ b/src/main/cliapp/src/components/Editors/NotEditor.js @@ -18,6 +18,7 @@ export function NotEditor({ props, value, editorChange }) { <> onChange(e)} diff --git a/src/main/cliapp/src/containers/diseaseAnnotationsPage/NewAnnotationForm.js b/src/main/cliapp/src/containers/diseaseAnnotationsPage/NewAnnotationForm.js index 6c0982ce5..8ce4d7f90 100644 --- a/src/main/cliapp/src/containers/diseaseAnnotationsPage/NewAnnotationForm.js +++ b/src/main/cliapp/src/containers/diseaseAnnotationsPage/NewAnnotationForm.js @@ -6,6 +6,7 @@ import { Toast } from "primereact/toast"; import { MultiSelect } from 'primereact/multiselect'; import { useMutation, useQueryClient } from "react-query"; import { FormErrorMessageComponent } from "../../components/Error/FormErrorMessageComponent"; +import { NotEditor } from "../../components/Editors/NotEditor"; import { classNames } from "primereact/utils"; import { DiseaseAnnotationService } from "../../service/DiseaseAnnotationService"; import { Splitter, SplitterPanel } from "primereact/splitter"; @@ -75,7 +76,7 @@ export const NewAnnotationForm = ({ const geneticModifierRelationTerms = useControlledVocabularyService('disease_genetic_modifier_relation'); const [uiErrorMessages, setUiErrorMessages] = useState({}); const areUiErrors = useRef(false); - const newAnnotationOptionalFields = ["Asserted Genes", "Asserted Allele", "Negated", "With", "Related Notes", "Experimental Conditions", "Experiments", "Genetic Sex", + const newAnnotationOptionalFields = ["Asserted Genes", "Asserted Allele", "Not", "With", "Related Notes", "Experimental Conditions", "Experiments", "Genetic Sex", "Disease Qualifiers", "SGD Strain Background", "Annotation Type", "Genetic Modifier Relation", "Genetic Modifiers","Internal"]; let defaultUserSettings = getDefaultFormState("DiseaseAnnotations", newAnnotationOptionalFields, undefined); const { settings: settingsKey , mutate: setSettingsKey } = useGetUserSettings('DiseaseAnnotationsFormSettings', defaultUserSettings, false); @@ -566,22 +567,14 @@ export const NewAnnotationForm = ({ - {selectedFormFields?.includes("Negated") && ( + {selectedFormFields?.includes("Not") && ( <>
- +
- +
From 569709408bc68771e1ca1bb5f3af300f10c398b1 Mon Sep 17 00:00:00 2001 From: Adam Gibson Date: Mon, 11 Mar 2024 12:10:31 -0500 Subject: [PATCH 07/11] SCRUM-3794 update case --- .../diseaseAnnotationsPage/DiseaseAnnotationsTable.js | 2 +- .../containers/diseaseAnnotationsPage/NewAnnotationForm.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/cliapp/src/containers/diseaseAnnotationsPage/DiseaseAnnotationsTable.js b/src/main/cliapp/src/containers/diseaseAnnotationsPage/DiseaseAnnotationsTable.js index 6e155a4aa..f842525b2 100644 --- a/src/main/cliapp/src/containers/diseaseAnnotationsPage/DiseaseAnnotationsTable.js +++ b/src/main/cliapp/src/containers/diseaseAnnotationsPage/DiseaseAnnotationsTable.js @@ -923,7 +923,7 @@ export const DiseaseAnnotationsTable = () => { }, { field: "negated", - header: "Not", + header: "NOT", body: (rowData) => , sortable: true, filterConfig: FILTER_CONFIGS.negatedFilterConfig, diff --git a/src/main/cliapp/src/containers/diseaseAnnotationsPage/NewAnnotationForm.js b/src/main/cliapp/src/containers/diseaseAnnotationsPage/NewAnnotationForm.js index 8ce4d7f90..b7457df74 100644 --- a/src/main/cliapp/src/containers/diseaseAnnotationsPage/NewAnnotationForm.js +++ b/src/main/cliapp/src/containers/diseaseAnnotationsPage/NewAnnotationForm.js @@ -76,7 +76,7 @@ export const NewAnnotationForm = ({ const geneticModifierRelationTerms = useControlledVocabularyService('disease_genetic_modifier_relation'); const [uiErrorMessages, setUiErrorMessages] = useState({}); const areUiErrors = useRef(false); - const newAnnotationOptionalFields = ["Asserted Genes", "Asserted Allele", "Not", "With", "Related Notes", "Experimental Conditions", "Experiments", "Genetic Sex", + const newAnnotationOptionalFields = ["Asserted Genes", "Asserted Allele", "NOT", "With", "Related Notes", "Experimental Conditions", "Experiments", "Genetic Sex", "Disease Qualifiers", "SGD Strain Background", "Annotation Type", "Genetic Modifier Relation", "Genetic Modifiers","Internal"]; let defaultUserSettings = getDefaultFormState("DiseaseAnnotations", newAnnotationOptionalFields, undefined); const { settings: settingsKey , mutate: setSettingsKey } = useGetUserSettings('DiseaseAnnotationsFormSettings', defaultUserSettings, false); @@ -567,11 +567,11 @@ export const NewAnnotationForm = ({
- {selectedFormFields?.includes("Not") && ( + {selectedFormFields?.includes("NOT") && ( <>
- +
From e094318720606f629ace6f7d452c7e3f9c6e5de8 Mon Sep 17 00:00:00 2001 From: Adam Gibson Date: Tue, 12 Mar 2024 08:57:25 -0500 Subject: [PATCH 08/11] SCRUM-3794 update DiseaseAnnotationsTable tests --- .../__tests__/DiseaseAnnotationsTable.test.js | 6 ++++-- .../containers/diseaseAnnotationsPage/mockData/mockData.js | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/cliapp/src/containers/diseaseAnnotationsPage/__tests__/DiseaseAnnotationsTable.test.js b/src/main/cliapp/src/containers/diseaseAnnotationsPage/__tests__/DiseaseAnnotationsTable.test.js index ffcaed57f..2318a7d09 100644 --- a/src/main/cliapp/src/containers/diseaseAnnotationsPage/__tests__/DiseaseAnnotationsTable.test.js +++ b/src/main/cliapp/src/containers/diseaseAnnotationsPage/__tests__/DiseaseAnnotationsTable.test.js @@ -37,7 +37,8 @@ describe("", () => { const modInternalIdTd = await result.findByText("mockModInternalId"); const subjectTd = await result.findByText(/C57BL\/6J-Rfx3/i); const relationTd = await result.findByText("is_model_of"); - const negatedInternalObsoleteArray = await result.findAllByText("false"); + const internalObsoleteArray = await result.findAllByText("false"); + const NOTArray = await result.findAllByText("NOT"); const diseaseTd = await result.findByText(/visceral heterotaxy/i); const referenceTd = await result.findByText(/MGI:5284969/i); const evidenceCodeTd = await result.findByText(/TAS/i); @@ -63,7 +64,8 @@ describe("", () => { expect(modInternalIdTd).toBeInTheDocument(); expect(subjectTd).toBeInTheDocument(); expect(relationTd).toBeInTheDocument(); - expect(negatedInternalObsoleteArray.length).toEqual(3); + expect(internalObsoleteArray.length).toEqual(2); + expect(NOTArray.length).toEqual(2); expect(diseaseTd).toBeInTheDocument(); expect(referenceTd).toBeInTheDocument(); expect(evidenceCodeTd).toBeInTheDocument(); diff --git a/src/main/cliapp/src/containers/diseaseAnnotationsPage/mockData/mockData.js b/src/main/cliapp/src/containers/diseaseAnnotationsPage/mockData/mockData.js index 4442d524d..5e423d5f2 100644 --- a/src/main/cliapp/src/containers/diseaseAnnotationsPage/mockData/mockData.js +++ b/src/main/cliapp/src/containers/diseaseAnnotationsPage/mockData/mockData.js @@ -96,7 +96,7 @@ export const data = { } ] }, - "negated": false, + "negated": true, "relation": { "dateCreated": "2022-01-26T09:40:54.020724Z", "dateUpdated": "2022-01-26T09:40:54.020726Z", From bb2a2e6996e40087c90cf4454e4cab7e551db874 Mon Sep 17 00:00:00 2001 From: Adam Gibson Date: Wed, 13 Mar 2024 13:55:32 -0500 Subject: [PATCH 09/11] SCRUM-3794 remove null option from NotEditor --- .../cliapp/src/components/Editors/NotEditor.js | 18 ++++++++++++++---- .../DiseaseAnnotationsTable.js | 4 ++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/main/cliapp/src/components/Editors/NotEditor.js b/src/main/cliapp/src/components/Editors/NotEditor.js index c9dec2ae1..3d5ba1cd8 100644 --- a/src/main/cliapp/src/components/Editors/NotEditor.js +++ b/src/main/cliapp/src/components/Editors/NotEditor.js @@ -6,12 +6,22 @@ export function NotEditor({ props, value, editorChange }) { const textString = value ? "NOT" : ""; const options = [ { label: "NOT", value: true }, - { label: "null", value: false } ]; const onChange = (e) => { - setSelectedValue(e.value); - editorChange(e, props); + let event; + if(e.value === undefined){ + event = { + target: { + value: false, + name: e.target.name + } + } + } else { + event = e; + } + setSelectedValue(event.target.value); + editorChange(event, props); } return ( @@ -22,7 +32,7 @@ export function NotEditor({ props, value, editorChange }) { value={selectedValue} options={options} onChange={(e) => onChange(e)} - showClear={false} + showClear={true} placeholder={textString} style={{ width: '100%' }} /> diff --git a/src/main/cliapp/src/containers/diseaseAnnotationsPage/DiseaseAnnotationsTable.js b/src/main/cliapp/src/containers/diseaseAnnotationsPage/DiseaseAnnotationsTable.js index f842525b2..d2151ead2 100644 --- a/src/main/cliapp/src/containers/diseaseAnnotationsPage/DiseaseAnnotationsTable.js +++ b/src/main/cliapp/src/containers/diseaseAnnotationsPage/DiseaseAnnotationsTable.js @@ -432,10 +432,10 @@ export const DiseaseAnnotationsTable = () => { }; const onNegatedEditorValueChange = (event, props) => { - if(event.value === undefined || event.value === null) return; + if(event.target.value === undefined || event.target.value === null) return; let updatedAnnotations = [...props.props.value]; - updatedAnnotations[props.rowIndex].negated = event.value; + updatedAnnotations[props.rowIndex].negated = event.target.value; } const onInternalEditorValueChange = (props, event) => { From 963684db6173932d19a8f9cf417a6f01f6de490c Mon Sep 17 00:00:00 2001 From: Adam Gibson Date: Wed, 13 Mar 2024 13:58:41 -0500 Subject: [PATCH 10/11] SCRUM-3794 update NotEditor tests --- .../components/Editors/__tests__/NotEditor.test.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/cliapp/src/components/Editors/__tests__/NotEditor.test.js b/src/main/cliapp/src/components/Editors/__tests__/NotEditor.test.js index 46575434c..bb1c66886 100644 --- a/src/main/cliapp/src/components/Editors/__tests__/NotEditor.test.js +++ b/src/main/cliapp/src/components/Editors/__tests__/NotEditor.test.js @@ -3,14 +3,14 @@ import { NotEditor } from '../NotEditor'; import '../../../tools/jest/setupTests'; describe('NotEditor', () => { - it('should display "null" as the placeholder text when the initial value is false', () => { + it('should display "NOT" as the placeholder text when the initial value is true', () => { const props = {}; - const value = false; + const value = true; const editorChange = jest.fn(); const result = render(); - expect(result.getAllByText("null")).toHaveLength(2); + expect(result.getAllByText("NOT")).toHaveLength(2); }); it('should render a Dropdown component with no options when value prop is undefined', () => { @@ -33,7 +33,7 @@ describe('NotEditor', () => { const result = render(); const span = result.container.getElementsByTagName('span')[0]; - expect(within(span).getByText('null')).toBeInTheDocument(); + expect(within(span).getByText('empty')).toBeInTheDocument(); fireEvent.click(span); @@ -47,7 +47,7 @@ describe('NotEditor', () => { it('should call editorChange when an option is selected', () => { const props = {}; - const value = true; + const value = false; const editorChange = jest.fn(); const result = render(); const span = result.container.getElementsByTagName('span')[0]; @@ -55,7 +55,7 @@ describe('NotEditor', () => { fireEvent.click(span); - const option = result.getAllByText('null'); + const option = result.getAllByText('NOT'); fireEvent.click(option[0]); expect(editorChange).toHaveBeenCalledTimes(1); From 12bf3dd0e4a01c2a2a95e7b9fe928b7fab22d77e Mon Sep 17 00:00:00 2001 From: Adam Gibson Date: Wed, 13 Mar 2024 14:02:05 -0500 Subject: [PATCH 11/11] SCRUM-3794 update placeholder text --- src/main/cliapp/src/components/Editors/NotEditor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/cliapp/src/components/Editors/NotEditor.js b/src/main/cliapp/src/components/Editors/NotEditor.js index 3d5ba1cd8..75e8a6264 100644 --- a/src/main/cliapp/src/components/Editors/NotEditor.js +++ b/src/main/cliapp/src/components/Editors/NotEditor.js @@ -3,7 +3,7 @@ import { Dropdown } from "primereact/dropdown"; export function NotEditor({ props, value, editorChange }) { const [selectedValue, setSelectedValue] = useState(value); - const textString = value ? "NOT" : ""; + const textString = selectedValue ? "NOT" : ""; const options = [ { label: "NOT", value: true }, ];