Skip to content

Commit

Permalink
fix problem where breakpt fields could not accept data
Browse files Browse the repository at this point in the history
  • Loading branch information
elewis2 committed Apr 30, 2024
1 parent 0214b23 commit a6435a1
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 19 deletions.
13 changes: 10 additions & 3 deletions src/components/FormField/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,12 @@ const FormField = ({
iterable,
format,
} = model;
const linkedClass = schemaDefn.get(linkedClassName, false);
let linkedClass;
if (typeof linkedClassName === 'string') {

Check failure on line 82 in src/components/FormField/index.tsx

View workflow job for this annotation

GitHub Actions / build

Expected blank line before this statement
linkedClass = schemaDefn.get(linkedClassName);
} else {
linkedClass = linkedClassName;
}

const inputValue = formContent[name];
const generated = Boolean(model.generated && formVariant !== FORM_VARIANT.SEARCH);
Expand All @@ -103,7 +108,6 @@ const FormField = ({
}

let value = inputValue;

if (formVariant !== FORM_VARIANT.SEARCH) {

Check failure on line 111 in src/components/FormField/index.tsx

View workflow job for this annotation

GitHub Actions / build

Expected blank line before this statement
if (value === undefined || (!nullable && value === null)) {
if (defaultValue !== undefined) {
Expand All @@ -119,7 +123,6 @@ const FormField = ({
}

let propComponent;

if (type === 'boolean') {

Check failure on line 126 in src/components/FormField/index.tsx

View workflow job for this annotation

GitHub Actions / build

Expected blank line before this statement
propComponent = (
<BooleanField
Expand Down Expand Up @@ -147,7 +150,9 @@ const FormField = ({
/>
);
} else if (type.includes('embedded') && linkedClass) {

Check failure on line 152 in src/components/FormField/index.tsx

View workflow job for this annotation

GitHub Actions / build

Block must not be padded by blank lines

if (iterable && linkedClass.name === 'StatementReview') {

Check failure on line 154 in src/components/FormField/index.tsx

View workflow job for this annotation

GitHub Actions / build

Block must not be padded by blank lines

propComponent = (
<StatementReviewsTable
label={name}
Expand All @@ -158,6 +163,7 @@ const FormField = ({
/>
);
} else if (linkedClass.name === 'Permissions') {

Check failure on line 165 in src/components/FormField/index.tsx

View workflow job for this annotation

GitHub Actions / build

Block must not be padded by blank lines

// permissions table of checkboxes
propComponent = (
<PermissionsTable
Expand All @@ -170,6 +176,7 @@ const FormField = ({
/>
);
} else if (POSITION_CLASSES.includes(linkedClass.name)) {

Check failure on line 178 in src/components/FormField/index.tsx

View workflow job for this annotation

GitHub Actions / build

Block must not be padded by blank lines

propComponent = (
<PositionForm
baseVariant={baseModel}
Expand Down
10 changes: 5 additions & 5 deletions src/components/RecordAutocomplete/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,10 @@ const RecordAutocomplete = (props: RecordAutocompleteProps) => {
}}
label={label}
placeholder={
(disabled || selectedValues.length)
? ''
: placeholder
}
(disabled || selectedValues.length)
? ''
: placeholder
}
required={required}
/>
)}
Expand All @@ -301,7 +301,7 @@ RecordAutocomplete.defaultProps = {
isMulti: false,
label: '',
minSearchLength: 1,
onChange: () => {},
onChange: () => { },
placeholder: 'Search Records by Name or ID',
required: false,
singleLoad: false,
Expand Down
10 changes: 5 additions & 5 deletions src/components/RecordForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,11 @@ const RecordForm = ({
variant={variant}
/>
</FormContext.Provider>
{variant === FORM_VARIANT.VIEW && schemaDefn.get(modelName).inherits.includes('V') && (
{variant === FORM_VARIANT.VIEW && schemaDefn.children(modelName).includes('V') && (
<>
<EdgeTable recordId={form.formContent['@rid']} />
<RelatedStatementsTable recordId={form.formContent['@rid']} />
{schemaDefn.get(modelName).inherits.includes('Ontology') && (
{schemaDefn.children(modelName).includes('Ontology') && (
<RelatedVariantsTable recordId={form.formContent['@rid']} />
)}
</>
Expand All @@ -253,7 +253,7 @@ const RecordForm = ({
// for spacing issues only
: (<div />)}
{actionInProgress && (
<CircularProgress size={50} />
<CircularProgress size={50} />
)}
{variant === FORM_VARIANT.NEW || (variant === FORM_VARIANT.EDIT && !isEdge)
? (
Expand Down Expand Up @@ -281,8 +281,8 @@ const RecordForm = ({

RecordForm.defaultProps = {
modelName: null,
onError: () => {},
onSubmit: () => {},
onError: () => { },
onSubmit: () => { },
onToggleState: undefined,
rid: null,
variant: FORM_VARIANT.VIEW,
Expand Down
4 changes: 2 additions & 2 deletions src/components/VariantForm/BreakpointForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import React, { useCallback, useContext, useState } from 'react';
import FormContext from '@/components/FormContext';
import FormField from '@/components/FormField';

interface BreakpointFormProps{
interface BreakpointFormProps {
/** the Position class */
coordinateType: string;
/**
Expand Down Expand Up @@ -85,7 +85,7 @@ const BreakpointForm = ({
clearable={false}
label={`end (${coordinateType})`}
model={{
...model.properties.break1Start,
...model.properties.break1End,
name: end,
mandatory: required,
linkedClass: schemaDefn.get(coordinateType),
Expand Down
6 changes: 3 additions & 3 deletions src/services/api/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Wrapper for api, handles all requests and special functions.
*/
import { util } from '@bcgsc-pori/graphkb-schema';
import { util, schema as schemaDefn } from '@bcgsc-pori/graphkb-schema';
import * as jc from 'json-cycle';
import qs from 'qs';
import { QueryClient } from 'react-query';
Expand Down Expand Up @@ -124,10 +124,10 @@ const getDefaultSuggestionQueryBody = (model) => (textInput) => {
limit: MAX_SUGGESTIONS,
neighbors: 1,
};

if (model.inherits.includes('Ontology') || model.name === 'Ontology') {
if (model && model.name && schemaDefn.children(model.name) && schemaDefn.children(model.name).includes('Ontology') || model.name === 'Ontology') {
body.orderBy = ['source.sort', 'name', 'sourceId'];
}

return body;
};

Expand Down
2 changes: 1 addition & 1 deletion src/services/schema.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function getEdges<ReqFields extends string = string>(node: GeneralRecordType<Req
}

const isEdge = (cls) => !!(schemaDefn.get(cls)
&& schemaDefn.get(cls).inherits.some((inherited) => inherited === 'E'));
&& schemaDefn.children(cls).some((inherited) => inherited === 'E'));

/**
* Validates a value against some property model and returns the new property tracking object
Expand Down

0 comments on commit a6435a1

Please sign in to comment.