Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FD-1753 -- Loading bug for mappings search #131

Merged
merged 3 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export const GetMappingsModal = ({
}, [apiPreferencesCode, searchProp]);

useEffect(() => {
if (!!currentSearchProp) {
if (!!currentSearchProp && apiPreferencesCode !== undefined) {
fetchResults(page, currentSearchProp);
}
}, [page, currentSearchProp]);
Expand Down
11 changes: 3 additions & 8 deletions src/components/Manager/MappingsFunctions/MappingReset.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export const MappingReset = ({
// If there is a currentSearchProp in the search bar, it evaluates to true and runs the search function.
// The function is run when the code and when the page changes.
useEffect(() => {
if (!!currentSearchProp) {
if (!!currentSearchProp && apiPreferencesCode !== undefined) {
fetchResults(page, currentSearchProp);
}
}, [page, currentSearchProp]);
Expand Down Expand Up @@ -348,18 +348,13 @@ export const MappingReset = ({
))}
</div>
</Form.Item>
)}{' '}
)}
{results?.length > 0 ? (
<>
<Form.Item
name={['filtered_mappings']}
valuePropName="value"
rules={[
{
required: true,
message: 'Please make a selection.',
},
]}
rules={[{ required: false }]}
>
{filteredResultsArray?.length > 0 ? (
<Checkbox.Group
Expand Down
2 changes: 1 addition & 1 deletion src/components/Manager/MappingsFunctions/MappingSearch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const MappingSearch = ({
// If there is a currentSearchProp in the search bar, it evaluates to true and runs the search function.
// The function is run when the code and when the page changes.
useEffect(() => {
if (!!currentSearchProp) {
if (!!currentSearchProp && apiPreferencesCode !== undefined) {
fetchResults(page, currentSearchProp);
}
}, [page, currentSearchProp]);
Expand Down
17 changes: 9 additions & 8 deletions src/components/Projects/Studies/AddStudy.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const AddStudy = ({ addStudy, setAddStudy }) => {
const [loading, setLoading] = useState(false);
const [form] = Form.useForm();
const { vocabUrl, setStudy } = useContext(myContext);
const { TextArea } = Input;

const navigate = useNavigate();
// Submit function for adding a new study.
Expand Down Expand Up @@ -75,26 +76,26 @@ export const AddStudy = ({ addStudy, setAddStudy }) => {
<h2>Create Study</h2>
<Form.Item
name="name"
label="Name"
label="Name / Short Code"
rules={[{ required: true, message: 'Please input Study name.' }]}
>
<Input />
</Form.Item>

<Form.Item
name="description"
label="Description"
rules={[{ required: false }]}
>
<Input />
</Form.Item>
<Form.Item
name="title"
label="Title"
rules={[{ required: true, message: 'Please input Study title.' }]}
>
<Input />
</Form.Item>
<Form.Item
name="description"
label="Description"
rules={[{ required: false }]}
>
<TextArea />
</Form.Item>
<Form.Item
name="identifier_prefix"
label="Identifier Prefix"
Expand Down
6 changes: 4 additions & 2 deletions src/components/Projects/Studies/EditStudyDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { myContext } from '../../../App';
export const EditStudyDetails = ({ form, study, setStudy, edit, setEdit }) => {
const [loading, setLoading] = useState(false);
const { vocabUrl } = useContext(myContext);
const { TextArea } = Input;

// Sets the initial values displayed in the form and esnures they are current
const changeHandler = () => {
form.setFieldsValue({
Expand Down Expand Up @@ -66,7 +68,7 @@ export const EditStudyDetails = ({ form, study, setStudy, edit, setEdit }) => {
<h2>{study.name ? study.name : study.id}</h2>
<Form.Item
name="name"
label="Name"
label="Name / Short Code"
rules={[{ required: true, message: 'Please input Study name.' }]}
>
<Input />
Expand All @@ -83,7 +85,7 @@ export const EditStudyDetails = ({ form, study, setStudy, edit, setEdit }) => {
label="Description"
rules={[{ required: false }]}
>
<Input />
<TextArea />
</Form.Item>
<Form.Item
name="url"
Expand Down
16 changes: 14 additions & 2 deletions src/components/Projects/Tables/TableDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,16 @@ import './TableStyling.scss';
import { Link, useNavigate, useParams } from 'react-router-dom';
import { Spinner } from '../../Manager/Spinner';
import { getById } from '../../Manager/FetchManager';
import { Card, Col, Form, notification, Row, Table, Button } from 'antd';
import {
Button,
Card,
Col,
Form,
notification,
Row,
Table,
Tooltip,
} from 'antd';
import { CloseCircleOutlined } from '@ant-design/icons';
import { EditTableDetails } from './EditTableDetails';
import { DeleteTable } from './DeleteTable';
Expand Down Expand Up @@ -252,7 +261,10 @@ 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 => (
<div className="mapping" key={code.display}>
<span className="mapping-display">{code.display}</span>
<span className="mapping-display">
{' '}
<Tooltip title={code.code}>{code.display}</Tooltip>
</span>
<span
className="remove-mapping"
onClick={() => handleRemoveMapping(variableMappings, code)}
Expand Down
6 changes: 4 additions & 2 deletions src/components/Projects/Terminologies/Terminology.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { myContext } from '../../../App';
import './Terminology.scss';
import { Spinner } from '../../Manager/Spinner';
import { getById } from '../../Manager/FetchManager';
import { Col, Form, notification, Row, Table, Button } from 'antd';
import { Button, Col, Form, notification, Row, Table, Tooltip } from 'antd';
import { CloseCircleOutlined } from '@ant-design/icons';
import { EditMappingsModal } from './EditMappingModal';
import { EditTerminologyDetails } from './EditTerminologyDetails';
Expand Down Expand Up @@ -137,7 +137,9 @@ 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 => (
<div className="mapping" key={code.display}>
<span className="mapping-display">{code.display}</span>
<span className="mapping-display">
<Tooltip title={code.code}>{code.display}</Tooltip>
</span>
<span
className="remove-mapping"
onClick={() => handleRemoveMapping(variableMappings, code)}
Expand Down