Skip to content

Commit ef490d1

Browse files
authored
Merge pull request #782 from complexdatacollective/fix/validation-not-saving
Fix/validation not saving
2 parents 71912b9 + 42ab990 commit ef490d1

File tree

24 files changed

+203
-861
lines changed

24 files changed

+203
-861
lines changed

network-canvas

src/components/Codebook/EntityType.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ const EntityType = ({
4040
</h2>
4141
</div>
4242
<div className="codebook__entity-meta">
43-
{ !inUse && <Tag>not in use</Tag> }
44-
{ inUse && (
45-
<>
46-
<em>used in:</em>
47-
{' '}
48-
{stages}
49-
</>
50-
) }
43+
{!inUse && <Tag>not in use</Tag>}
44+
{inUse && (
45+
<>
46+
<em>used in:</em>
47+
{' '}
48+
{stages}
49+
</>
50+
)}
5151
</div>
5252
<div className="codebook__entity-control">
5353
<Button
@@ -65,16 +65,16 @@ const EntityType = ({
6565
</Button>
6666
</div>
6767
</div>
68-
{ variables.length > 0
68+
{variables.length > 0
6969
&& (
70-
<div className="codebook__entity-variables">
71-
<h3>Variables:</h3>
72-
<Variables
73-
variables={variables}
74-
entity={entity}
75-
type={type}
76-
/>
77-
</div>
70+
<div className="codebook__entity-variables">
71+
<h3>Variables:</h3>
72+
<Variables
73+
variables={variables}
74+
entity={entity}
75+
type={type}
76+
/>
77+
</div>
7878
)}
7979
</div>
8080
);
@@ -97,8 +97,8 @@ EntityType.propTypes = {
9797
EntityType.defaultProps = {
9898
variables: [],
9999
inUse: true, // Don't allow delete unless we explicitly say so
100-
handleDelete: () => {},
101-
handleEdit: () => {},
100+
handleDelete: () => { },
101+
handleEdit: () => { },
102102
};
103103

104104
const mapStateToProps = (state, { entity, type }) => {
@@ -116,7 +116,7 @@ const withEntityHandlers = compose(
116116
}),
117117
withHandlers({
118118
handleEdit: ({ openScreen, entity, type }) => () => {
119-
openScreen('type', { entity, type, metaOnly: true });
119+
openScreen('type', { entity, type });
120120
},
121121
handleDelete: ({
122122
deleteType, openDialog, entity, type, name, inUse,

src/components/Form/Fields/VariablePicker/VariablePill.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { useDispatch, useSelector } from 'react-redux';
1414
import { actionCreators as codebookActions } from '@modules/protocol/codebook';
1515
import { required as requiredValidation, uniqueByList, allowedVariableName } from '@app/utils/validations';
1616
import TextInput from '@codaco/ui/lib/components/Fields/Text';
17-
import { makeGetVariableFromUUID, getVariablesForSubject } from '../../../../selectors/codebook';
17+
import { makeGetVariableWithEntity, getVariablesForSubject } from '../../../../selectors/codebook';
1818
import { getColorForType, getIconForType } from '../../../../config/variables';
1919

2020
const EDIT_COMPLETE_BUTTON_ID = 'editCompleteButton';
@@ -72,7 +72,7 @@ const EditableVariablePill = ({ uuid }) => {
7272

7373
const {
7474
name, type, entity, entityType,
75-
} = useSelector(makeGetVariableFromUUID(uuid));
75+
} = useSelector(makeGetVariableWithEntity(uuid));
7676

7777
const [newName, setNewName] = useState(name);
7878

@@ -131,7 +131,7 @@ const EditableVariablePill = ({ uuid }) => {
131131
<>
132132
<BaseVariablePill type={type} ref={ref}>
133133
<AnimatePresence initial={false} exitBeforeEnter>
134-
{ editing ? (
134+
{editing ? (
135135
<motion.div
136136
key="edit"
137137
style={{ flex: 1 }}

src/components/Screens/VariableEditorScreen.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/components/Screens/screenIndex.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { get } from 'lodash';
33
import StageEditorScreen from './StageEditorScreen';
44
import Codebook from './CodebookScreen';
55
import TypeEditorScreen from './TypeEditorScreen';
6-
import VariableEditorScreen from './VariableEditorScreen';
76
import NewStageScreen from './NewStageScreen';
87
import AssetsScreen from './AssetsScreen';
98

@@ -13,7 +12,6 @@ const SCREEN_INDEX = {
1312
stage: StageEditorScreen,
1413
codebook: Codebook,
1514
type: TypeEditorScreen,
16-
variable: VariableEditorScreen,
1715
newStage: NewStageScreen,
1816
assets: AssetsScreen,
1917
};

src/components/TypeEditor/Options.js

Lines changed: 0 additions & 166 deletions
This file was deleted.

src/components/TypeEditor/TypeEditor.js

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { getCodebook } from '@selectors/protocol';
1111
import ColorPicker from '../Form/Fields/ColorPicker';
1212
import IconOption from './IconOption';
1313
import getPalette from './getPalette';
14-
import Variables from './Variables';
1514

1615
const ICON_OPTIONS = [
1716
'add-a-person',
@@ -23,8 +22,6 @@ const TypeEditor = ({
2322
entity,
2423
type,
2524
existingTypes,
26-
isNew,
27-
metaOnly,
2825
}) => {
2926
const dispatch = useDispatch();
3027
const getFormValue = formValueSelector(form);
@@ -43,7 +40,7 @@ const TypeEditor = ({
4340
<>
4441
<div className="stage-heading stage-heading--collapsed stage-heading--shadow">
4542
<Layout>
46-
<h2>{ type ? `Edit ${entity}` : `Create ${entity}` }</h2>
43+
<h2>{type ? `Edit ${entity}` : `Create ${entity}`}</h2>
4744
</Layout>
4845
</div>
4946
<Layout>
@@ -57,8 +54,8 @@ const TypeEditor = ({
5754
{' '}
5855
type. This name will be used to identify this type in the
5956
codebook, and in your data exports.
60-
{ entity === 'node' && ' Some examples might be "Person", "Place", or "Organization".' }
61-
{ entity === 'edge' && ' Some examples might be "Friends" or "Works With".' }
57+
{entity === 'node' && ' Some examples might be "Person", "Place", or "Organization".'}
58+
{entity === 'edge' && ' Some examples might be "Friends" or "Works With".'}
6259
</p>
6360
<ValidatedField
6461
component={Fields.Text}
@@ -88,7 +85,7 @@ const TypeEditor = ({
8885
validation={{ required: true }}
8986
/>
9087
</Section>
91-
{ entity === 'node'
88+
{entity === 'node'
9289
&& (
9390
<Section
9491
title="Icon"
@@ -111,20 +108,6 @@ const TypeEditor = ({
111108
/>
112109
</Section>
113110
)}
114-
{(!isNew && !metaOnly)
115-
&& (
116-
<Section title="Option Values">
117-
<Variables
118-
form={form}
119-
name="variables"
120-
sortableProperties={['name', 'type']}
121-
initialSortOrder={{
122-
direction: 'asc',
123-
property: 'name',
124-
}}
125-
/>
126-
</Section>
127-
)}
128111
</Layout>
129112
</>
130113
);
@@ -136,14 +119,10 @@ TypeEditor.propTypes = {
136119
form: PropTypes.string.isRequired,
137120
// eslint-disable-next-line react/forbid-prop-types
138121
existingTypes: PropTypes.array.isRequired,
139-
isNew: PropTypes.bool,
140-
metaOnly: PropTypes.bool,
141122
};
142123

143124
TypeEditor.defaultProps = {
144125
type: null,
145-
isNew: false,
146-
metaOnly: false,
147126
};
148127

149128
const mapStateToProps = (state, { type, isNew }) => {

0 commit comments

Comments
 (0)