Skip to content

Commit

Permalink
Updating edit/register Upload with support for new required fields
Browse files Browse the repository at this point in the history
  • Loading branch information
maxsibilla committed Dec 3, 2024
1 parent 7cba394 commit 369b781
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 23 deletions.
15 changes: 8 additions & 7 deletions src/components/custom/edit/dataset/DatasetType.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ import {Col, Form, Row} from 'react-bootstrap';
import SenNetPopover from "../../../SenNetPopover";
import {getUBKGFullName} from "../../js/functions";

export default function DatasetType({datasetTypes, data, onChange}) {
export default function DatasetType({datasetTypes, data, label, labelDescription, dataValue, onChange}) {

console.log(datasetTypes)
return (
//Data Types
<>
<Form.Group className="mb-3" controlId="dataset_type">
<Form.Label>Dataset Type <span
<Form.Label>{label ? label : `Dataset Type` }<span
className="required">* </span>
<SenNetPopover className={'dataset_type'}
text={<>The type of data contained in this <code>Dataset</code>. Choose from one
text={labelDescription ? labelDescription : <>The type of data contained in this <code>Dataset</code>. Choose from one
of the available options.</>}>
<i className={'bi bi-question-circle-fill'}></i>
</SenNetPopover>
Expand All @@ -23,13 +24,13 @@ export default function DatasetType({datasetTypes, data, onChange}) {
(
<Form.Select required aria-label="Dataset Type" disabled>
<option
value={data.dataset_type}>{getUBKGFullName(data.dataset_type)}</option>
value={data.dataset_type}>{getUBKGFullName(dataValue ? data[dataValue] : data.dataset_type)}</option>
</Form.Select>
) : (
<Form.Select required aria-label="Dataset Type"
onChange={(e) => onChange(e, 'dataset_type', e.target.value)}
name={'dataset_type'}
defaultValue={data?.dataset_type}>
onChange={(e) => onChange(e, dataValue ? dataValue : 'dataset_type', e.target.value)}
name={dataValue ? dataValue : 'dataset_type'}
defaultValue={dataValue ? data?.[dataValue] : data?.dataset_type}>
<option value="">----</option>
{datasetTypes.map(data_type => {
return (
Expand Down
2 changes: 1 addition & 1 deletion src/pages/edit/dataset.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ export default function EditDataset() {
</Form.Group>
}

{/*/!*Data Types*!/*/}
{/*/!*Dataset Type*!/*/}
{editMode &&
<DatasetType
datasetTypes={dataTypes === null ? Object.values(cache.datasetTypes) : dataTypes}
Expand Down
68 changes: 53 additions & 15 deletions src/pages/edit/upload.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,23 @@ import Button from 'react-bootstrap/Button';
import Form from 'react-bootstrap/Form';
import {Layout} from "@elastic/react-search-ui-views";
import log from "loglevel";
import {cleanJson, eq, getRequestHeaders, getStatusColor} from "../../components/custom/js/functions";
import {getEntityData, update_create_dataset} from "../../lib/services";
import AppContext from '../../context/AppContext'
import EntityContext, {EntityProvider} from '../../context/EntityContext'
import {cleanJson, eq, getRequestHeaders, getStatusColor, getUBKGFullName} from "@/components/custom/js/functions";
import {getEntityData, update_create_dataset} from "@/lib/services";
import AppContext from '@/context/AppContext'
import EntityContext, {EntityProvider} from '@/context/EntityContext'
import $ from "jquery";
import DatasetRevertButton, {statusRevertTooltip} from "../../components/custom/edit/dataset/DatasetRevertButton";
import DatasetRevertButton, {statusRevertTooltip} from "@/components/custom/edit/dataset/DatasetRevertButton";

const AppFooter = dynamic(() => import("../../components/custom/layout/AppFooter"))
const AppNavbar = dynamic(() => import("../../components/custom/layout/AppNavbar"))
const DatasetSubmissionButton = dynamic(() => import("../../components/custom/edit/dataset/DatasetSubmissionButton"))
const EntityHeader = dynamic(() => import('../../components/custom/layout/entity/Header'))
const EntityFormGroup = dynamic(() => import('../../components/custom/layout/entity/FormGroup'))
const GroupSelect = dynamic(() => import("../../components/custom/edit/GroupSelect"))
const Header = dynamic(() => import("../../components/custom/layout/Header"))
const SenNetAlert = dynamic(() => import("../../components/SenNetAlert"))
const SenNetPopover = dynamic(() => import("../../components/SenNetPopover"))
const AppFooter = dynamic(() => import("@/components/custom/layout/AppFooter"))
const AppNavbar = dynamic(() => import("@/components/custom/layout/AppNavbar"))
const DatasetSubmissionButton = dynamic(() => import("@/components/custom/edit/dataset/DatasetSubmissionButton"))
const DatasetType = dynamic(() => import("@/components/custom/edit/dataset/DatasetType"))
const EntityHeader = dynamic(() => import('@/components/custom/layout/entity/Header'))
const EntityFormGroup = dynamic(() => import('@/components/custom/layout/entity/FormGroup'))
const GroupSelect = dynamic(() => import("@/components/custom/edit/GroupSelect"))
const Header = dynamic(() => import("@/components/custom/layout/Header"))
const SenNetAlert = dynamic(() => import("@/components/SenNetAlert"))
const SenNetPopover = dynamic(() => import("@/components/SenNetPopover"))


function EditUpload() {
Expand All @@ -41,7 +42,6 @@ function EditUpload() {
getCancelBtn, isAdminOrHasValue, getAssignedToGroupNames
} = useContext(EntityContext)
const {_t, cache, adminGroup, getBusyOverlay, toggleBusyOverlay, getPreviewView} = useContext(AppContext)

const router = useRouter()
const [source, setSource] = useState(null)

Expand Down Expand Up @@ -286,6 +286,44 @@ function EditUpload() {
text={<>Free text field to enter a description of
the <code>Upload</code>.</>}/>

{/*/!*Intended Dataset Type*!/*/}
<DatasetType
datasetTypes={Object.values(cache.datasetTypes)}
label={'Intended Dataset Type'}
labelDescription={<>The dataset type of the intended datasets that will be
uploaded as part of this <code>Upload</code>.</>}
dataValue={'intended_dataset_type'}
values={values} data={data} onChange={onChange}/>

{/*/!*Intended Organ*!/*/}
<Form.Group className="mb-3" controlId="intended_organ_group">
<Form.Label>Intended Organ<span
className="required">* </span>
<SenNetPopover className={'intended_organ'}
text={<>The organ that the data contained in
this <code>Upload</code> will be
registered/associated with.</>}>
<i className={'bi bi-question-circle-fill'}></i>
</SenNetPopover>
</Form.Label>

<Form.Select required aria-label="Intended Organ" id="intended_organ" onChange={e => {
onChange(e, e.target.id, e.target.value)
}}
defaultValue={data.intended_organ}>
<option value="">----</option>
{Object.entries(cache.organTypes).map(op => {
return (
<option key={op[0]} value={op[0]}>
{op[1]}
</option>
);

})}
</Form.Select>

</Form.Group>


<div className={'d-flex flex-row-reverse'}>
{getCancelBtn('upload')}
Expand Down

0 comments on commit 369b781

Please sign in to comment.