Skip to content

Commit

Permalink
Merge pull request #835 from codaco/fix/prompt-selectors
Browse files Browse the repository at this point in the history
Refactor prompt selectors
  • Loading branch information
jthrilly authored Jan 17, 2019
2 parents 5518027 + e29dda2 commit 5ef8852
Show file tree
Hide file tree
Showing 35 changed files with 466 additions and 410 deletions.
3 changes: 2 additions & 1 deletion config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/supports-screens">
<supports-screens android:anyDensity="false" android:largeScreens="true" android:normalScreens="false" android:requiresSmallestWidthDp="600" android:resizeable="false" android:smallScreens="false" android:xlargeScreens="true" />
</edit-config>
<content src="index.html" />
<content src="http://192.168.1.66:3000/" />
<access origin="*" />
<access origin="cdvfile://*" />
<allow-intent href="http://*/*" />
Expand All @@ -29,6 +29,7 @@
<icon density="xxxhdpi" src="www/icons/android/NC-Round-xxxhdpi.png" />
</platform>
<platform name="ios">
<allow-navigation href="*" />
<allow-navigation href="*" />
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"build-docs": "cross-env NODE_ENV=production jsdoc src -r -d docs-build -c ./jsdoc.conf.json --verbose",
"electron": "electron ./www",
"electron:dev": "cross-env NODE_ENV=development NC_DEVSERVER_FILE=\".devserver\" electron public/",
"ios:dev": "node scripts/check-dev-server.js && cross-env LIVE_RELOAD=1 cordova run ios --buildFlag='-UseModernBuildSystem=0' --developmentTeam=85EZ69PQHJ --device",
"ios:dev": "node scripts/check-dev-server.js && cross-env LIVE_RELOAD=1 cordova run ios --buildFlag='-UseModernBuildSystem=0' --developmentTeam=85EZ69PQHJ",
"android:dev": "node scripts/check-dev-server.js && cross-env LIVE_RELOAD=1 cordova run android",
"generate-icons": "node scripts/generate-app-icons.js",
"dist:android": "npm run build:android && cordova build android --release",
Expand Down Expand Up @@ -243,4 +243,4 @@
"cordova-plugin-network-canvas-client": {}
}
}
}
}
29 changes: 6 additions & 23 deletions public/protocols/development.netcanvas/protocol.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Development Protocol",
"description": "",
"description": "The Network Canvas development protocol is designed for our team to test new features. It is not intended for general use.",
"lastModified": "2018-10-01T00:00:00.000Z",
"networkCanvasVersion": "~4.0.0",
"variableRegistry": {
Expand Down Expand Up @@ -705,10 +705,8 @@
"type": "eda5e3bb-8e1c-4216-9e06-adc0ff6b7f73",
"attributes": {
"8a35cd77-7bc4-4c7e-b98a-673b6a21321f": "About My Health",
"8ee3a187-d4be-458e-8abb-71efcc071949": "",
"1e9ce62c-44c5-484d-9c26-0d20cc7d7238": "About My Health",
"66646d68-cd33-407b-a349-56707021df72": "About My Health",
"18fbc928-d027-42de-bc96-ff5c09bf4944": "",
"67132d2b-c371-4c57-a5eb-6520083f9d22": "55 E Washington St, Chicago, Illinois, 60602",
"bdc60147-fe7a-4c3c-a164-e5b370f6a281": 41.882945,
"931a7b23-e433-4e7e-8e13-48b72e5f0549": -87.62572,
Expand All @@ -722,7 +720,6 @@
"8ee3a187-d4be-458e-8abb-71efcc071949": "Access Anixter Center",
"1e9ce62c-44c5-484d-9c26-0d20cc7d7238": "Access - Anixter",
"66646d68-cd33-407b-a349-56707021df72": "Access - Anixter",
"18fbc928-d027-42de-bc96-ff5c09bf4944": "",
"67132d2b-c371-4c57-a5eb-6520083f9d22": "2020 N Clybourn Ave, Chicago, Illinois, 60614",
"bdc60147-fe7a-4c3c-a164-e5b370f6a281": 41.91837,
"931a7b23-e433-4e7e-8e13-48b72e5f0549": -87.660281,
Expand All @@ -736,7 +733,6 @@
"8ee3a187-d4be-458e-8abb-71efcc071949": "ACCESS Ashland Family Health Center",
"1e9ce62c-44c5-484d-9c26-0d20cc7d7238": "Access - Ashland Family Health Center",
"66646d68-cd33-407b-a349-56707021df72": "Access - Ashland Family Health Center",
"18fbc928-d027-42de-bc96-ff5c09bf4944": "",
"67132d2b-c371-4c57-a5eb-6520083f9d22": "5159 S Ashland Ave, Chicago, IL 60609",
"bdc60147-fe7a-4c3c-a164-e5b370f6a281": 41.799756,
"931a7b23-e433-4e7e-8e13-48b72e5f0549": -87.66443,
Expand All @@ -750,7 +746,6 @@
"8ee3a187-d4be-458e-8abb-71efcc071949": "ACCESS Auburn-Gresham Family Health Center",
"1e9ce62c-44c5-484d-9c26-0d20cc7d7238": "Access - Auburn-Gresham Family Health Center",
"66646d68-cd33-407b-a349-56707021df72": "Access - Auburn-Gresham Family Health Center",
"18fbc928-d027-42de-bc96-ff5c09bf4944": "",
"67132d2b-c371-4c57-a5eb-6520083f9d22": "8234 S Ashland Ave, Chicago, IL 60620",
"bdc60147-fe7a-4c3c-a164-e5b370f6a281": 41.743832,
"931a7b23-e433-4e7e-8e13-48b72e5f0549": -87.663648,
Expand All @@ -764,7 +759,6 @@
"8ee3a187-d4be-458e-8abb-71efcc071949": "ACCESS Booker Family Health Center",
"1e9ce62c-44c5-484d-9c26-0d20cc7d7238": "Access - Booker Family Health Center",
"66646d68-cd33-407b-a349-56707021df72": "Access - Booker Family Health Center",
"18fbc928-d027-42de-bc96-ff5c09bf4944": "",
"67132d2b-c371-4c57-a5eb-6520083f9d22": "654 E 47th St, Chicago, IL 60653",
"bdc60147-fe7a-4c3c-a164-e5b370f6a281": 41.809683,
"931a7b23-e433-4e7e-8e13-48b72e5f0549": -87.609344,
Expand All @@ -778,7 +772,6 @@
"8ee3a187-d4be-458e-8abb-71efcc071949": "ACCESS Brandon Family Health Center",
"1e9ce62c-44c5-484d-9c26-0d20cc7d7238": "Access - Brandon Family Health Center",
"66646d68-cd33-407b-a349-56707021df72": "Access - Brandon Family Health Center",
"18fbc928-d027-42de-bc96-ff5c09bf4944": "",
"67132d2b-c371-4c57-a5eb-6520083f9d22": "8300 S Brandon Ave, Chicago, IL 60617",
"bdc60147-fe7a-4c3c-a164-e5b370f6a281": 40.74453,
"931a7b23-e433-4e7e-8e13-48b72e5f0549": -87.547014,
Expand All @@ -792,7 +785,6 @@
"8ee3a187-d4be-458e-8abb-71efcc071949": "ACCESS Cabrini Family Health Center",
"1e9ce62c-44c5-484d-9c26-0d20cc7d7238": "Access - Cabrini Family Health Center",
"66646d68-cd33-407b-a349-56707021df72": "Access - Cabrini Family Health Center",
"18fbc928-d027-42de-bc96-ff5c09bf4944": "",
"67132d2b-c371-4c57-a5eb-6520083f9d22": "3450 S Archer Ave, Chicago, IL 60608",
"bdc60147-fe7a-4c3c-a164-e5b370f6a281": 41.831331,
"931a7b23-e433-4e7e-8e13-48b72e5f0549": -87.676624,
Expand All @@ -806,7 +798,6 @@
"8ee3a187-d4be-458e-8abb-71efcc071949": "ACCESS Centro Medico",
"1e9ce62c-44c5-484d-9c26-0d20cc7d7238": "Access - Centro Medico",
"66646d68-cd33-407b-a349-56707021df72": "Access - Centro Medico",
"18fbc928-d027-42de-bc96-ff5c09bf4944": "",
"67132d2b-c371-4c57-a5eb-6520083f9d22": "3700 W 26th St, Chicago, IL 60623",
"bdc60147-fe7a-4c3c-a164-e5b370f6a281": 41.844509,
"931a7b23-e433-4e7e-8e13-48b72e5f0549": -87.717409,
Expand All @@ -820,7 +811,6 @@
"8ee3a187-d4be-458e-8abb-71efcc071949": "ACCESS Centro Medico San Rafael",
"1e9ce62c-44c5-484d-9c26-0d20cc7d7238": "Access - Centro Medico San Rafael",
"66646d68-cd33-407b-a349-56707021df72": "Access - Centro Medico San Rafael",
"18fbc928-d027-42de-bc96-ff5c09bf4944": "",
"67132d2b-c371-4c57-a5eb-6520083f9d22": "3204 W 26th St, Chicago, IL 60623",
"bdc60147-fe7a-4c3c-a164-e5b370f6a281": 41.844713,
"931a7b23-e433-4e7e-8e13-48b72e5f0549": -87.705448,
Expand All @@ -834,7 +824,6 @@
"8ee3a187-d4be-458e-8abb-71efcc071949": "ACCESS Doctors Medical Center",
"1e9ce62c-44c5-484d-9c26-0d20cc7d7238": "Access - Doctors Medical Center",
"66646d68-cd33-407b-a349-56707021df72": "Access - Doctors Medical Center",
"18fbc928-d027-42de-bc96-ff5c09bf4944": "",
"67132d2b-c371-4c57-a5eb-6520083f9d22": "6240 W 55th St, Chicago, IL 60638",
"bdc60147-fe7a-4c3c-a164-e5b370f6a281": 41.792657,
"931a7b23-e433-4e7e-8e13-48b72e5f0549": -87.778601,
Expand All @@ -848,7 +837,6 @@
"8ee3a187-d4be-458e-8abb-71efcc071949": "ACCESS Evanston-Rogers Park Family Health Center",
"1e9ce62c-44c5-484d-9c26-0d20cc7d7238": "Access - Evanston-Rogers Park Family Health Center",
"66646d68-cd33-407b-a349-56707021df72": "Access - Evanston-Rogers Park Family Health Center",
"18fbc928-d027-42de-bc96-ff5c09bf4944": "",
"67132d2b-c371-4c57-a5eb-6520083f9d22": "1555 Howard St, Chicago, IL 60626",
"bdc60147-fe7a-4c3c-a164-e5b370f6a281": 42.019113,
"931a7b23-e433-4e7e-8e13-48b72e5f0549": -87.670241,
Expand All @@ -862,7 +850,6 @@
"8ee3a187-d4be-458e-8abb-71efcc071949": "ACCESS at Gary Comer Youth Center",
"1e9ce62c-44c5-484d-9c26-0d20cc7d7238": "Access - Gary Comer Youth Center",
"66646d68-cd33-407b-a349-56707021df72": "Access - Gary Comer Youth Center",
"18fbc928-d027-42de-bc96-ff5c09bf4944": "",
"67132d2b-c371-4c57-a5eb-6520083f9d22": "7200 S Ingleside Ave, Chicago, IL 60619",
"bdc60147-fe7a-4c3c-a164-e5b370f6a281": 41.764069,
"931a7b23-e433-4e7e-8e13-48b72e5f0549": -87.602436,
Expand Down Expand Up @@ -890,7 +877,6 @@
"8ee3a187-d4be-458e-8abb-71efcc071949": "ACCESS Humboldt Park Family Health Center",
"1e9ce62c-44c5-484d-9c26-0d20cc7d7238": "Access - Humboldt Park Family Health Center",
"66646d68-cd33-407b-a349-56707021df72": "Access - Humboldt Park Family Health Center",
"18fbc928-d027-42de-bc96-ff5c09bf4944": "",
"67132d2b-c371-4c57-a5eb-6520083f9d22": "3202 W North Ave, Chicago, IL 60647",
"bdc60147-fe7a-4c3c-a164-e5b370f6a281": 41.910444,
"931a7b23-e433-4e7e-8e13-48b72e5f0549": -87.707085,
Expand All @@ -904,7 +890,6 @@
"8ee3a187-d4be-458e-8abb-71efcc071949": "ACCESS at the Illinois Eye Institute",
"1e9ce62c-44c5-484d-9c26-0d20cc7d7238": "Access - Illinois Eye Institute",
"66646d68-cd33-407b-a349-56707021df72": "Access - Illinois Eye Institute",
"18fbc928-d027-42de-bc96-ff5c09bf4944": "",
"67132d2b-c371-4c57-a5eb-6520083f9d22": "3241 S Michigan Ave, Chicago, IL 60616",
"bdc60147-fe7a-4c3c-a164-e5b370f6a281": 41.835265,
"931a7b23-e433-4e7e-8e13-48b72e5f0549": -87.622279,
Expand All @@ -918,7 +903,6 @@
"8ee3a187-d4be-458e-8abb-71efcc071949": "ACCESS Kedzie Family Health Center",
"1e9ce62c-44c5-484d-9c26-0d20cc7d7238": "Access - Kedzie Family Health Center",
"66646d68-cd33-407b-a349-56707021df72": "Access - Kedzie Family Health Center",
"18fbc928-d027-42de-bc96-ff5c09bf4944": "",
"67132d2b-c371-4c57-a5eb-6520083f9d22": "3213 W 47th Pl, Chicago, IL 60632",
"bdc60147-fe7a-4c3c-a164-e5b370f6a281": 41.806249,
"931a7b23-e433-4e7e-8e13-48b72e5f0549": -87.704915,
Expand All @@ -932,7 +916,6 @@
"8ee3a187-d4be-458e-8abb-71efcc071949": "Servicios Medicos La Villita",
"1e9ce62c-44c5-484d-9c26-0d20cc7d7238": "Access - La Villita",
"66646d68-cd33-407b-a349-56707021df72": "Access - La Villita",
"18fbc928-d027-42de-bc96-ff5c09bf4944": "",
"67132d2b-c371-4c57-a5eb-6520083f9d22": "3303 W 26th St, Chicago, Illinois, 60623",
"bdc60147-fe7a-4c3c-a164-e5b370f6a281": 41.843835,
"931a7b23-e433-4e7e-8e13-48b72e5f0549": -87.707797,
Expand All @@ -946,7 +929,6 @@
"8ee3a187-d4be-458e-8abb-71efcc071949": "ACCESS Madison Family Health Center",
"1e9ce62c-44c5-484d-9c26-0d20cc7d7238": "Access - Madison Family Health Center",
"66646d68-cd33-407b-a349-56707021df72": "Access - Madison Family Health Center",
"18fbc928-d027-42de-bc96-ff5c09bf4944": "",
"67132d2b-c371-4c57-a5eb-6520083f9d22": "3800 W Madison St, Chicago, IL 60624",
"bdc60147-fe7a-4c3c-a164-e5b370f6a281": 41.881126,
"931a7b23-e433-4e7e-8e13-48b72e5f0549": -87.721142,
Expand Down Expand Up @@ -1134,10 +1116,11 @@
},
{
"id": "2we",
"text": "Within the past 2 weeks, who has provided advice?",
"additionalAttributes": {
"03b03617-46ae-41cb-9462-9acd8a17edd6": true
}
"text": "Prompt with no additional attributes"
},
{
"id": "2wj",
"text": "Second prompt with no additional attributes"
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion src/behaviours/DragAndDrop/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const willAccept = (accepts, source) => {
...source,
});
} catch (e) {
console.log('Error in accept() function', e, source); // eslint-disable-line no-console
console.warn('Error in accept() function', e, source); // eslint-disable-line no-console
return false;
}
};
Expand Down
14 changes: 11 additions & 3 deletions src/components/Canvas/EdgeLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,17 @@ export class EdgeLayout extends PureComponent {
edges: [],
};

renderEdge = ({ key, from, to, type }) => (
<Edge key={key} from={from} to={to} type={type} viewBoxScale={viewBoxScale} />
);
renderEdge = (edge) => {
if (!['key', 'from', 'to', 'type'].every(prop => prop in edge)) {
return null;
}

const { key, from, to, type } = edge;

return (
<Edge key={key} from={from} to={to} type={type} viewBoxScale={viewBoxScale} />
);
};

render() {
const { edges } = this.props;
Expand Down
6 changes: 4 additions & 2 deletions src/components/Canvas/NodeLayout.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { isEmpty, isEqual, pick, has } from 'lodash';
import { isEmpty, isEqual, pick, has, isNil } from 'lodash';
import LayoutNode from '../../containers/Canvas/LayoutNode';
import { nodePrimaryKeyProperty, getNodeAttributes, nodeAttributesProperty } from '../../ducks/modules/network';

Expand Down Expand Up @@ -73,7 +73,9 @@ class NodeLayout extends Component {
<div className="node-layout">
{ nodes.map((node) => {
const nodeAttributes = getNodeAttributes(node);
if (!has(nodeAttributes, layoutVariable)) { return null; }
if (!has(nodeAttributes, layoutVariable) || isNil(nodeAttributes[layoutVariable])) {
return null;
}

return (
<LayoutNode
Expand Down
1 change: 1 addition & 0 deletions src/components/Canvas/__tests__/EdgeLayout.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { EdgeLayout } from '../EdgeLayout';
const mockEdgeCoords = [
{
key: 'foo_bar_baz',
type: 'type',
from: {
x: 100,
y: 100,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ ShallowWrapper {
"x": 100,
"y": 100,
},
"type": "type",
},
]
}
Expand Down Expand Up @@ -53,7 +54,7 @@ ShallowWrapper {
"y": 100,
}
}
type={undefined}
type="type"
viewBoxScale={100}
/>
</svg>,
Expand All @@ -79,7 +80,7 @@ ShallowWrapper {
"y": 100,
}
}
type={undefined}
type="type"
viewBoxScale={100}
/>,
],
Expand All @@ -102,7 +103,7 @@ ShallowWrapper {
"x": 100,
"y": 100,
},
"type": undefined,
"type": "type",
"viewBoxScale": 100,
},
"ref": null,
Expand Down Expand Up @@ -138,7 +139,7 @@ ShallowWrapper {
"y": 100,
}
}
type={undefined}
type="type"
viewBoxScale={100}
/>
</svg>,
Expand All @@ -164,7 +165,7 @@ ShallowWrapper {
"y": 100,
}
}
type={undefined}
type="type"
viewBoxScale={100}
/>,
],
Expand All @@ -187,7 +188,7 @@ ShallowWrapper {
"x": 100,
"y": 100,
},
"type": undefined,
"type": "type",
"viewBoxScale": 100,
},
"ref": null,
Expand Down
1 change: 0 additions & 1 deletion src/containers/Canvas/LayoutNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class LayoutNode extends PureComponent {
selected,
selectedColor,
} = this.props;

const nodeAttributes = getNodeAttributes(node);

const { x, y } = nodeAttributes[layoutVariable];
Expand Down
30 changes: 15 additions & 15 deletions src/containers/Canvas/NodeLayout.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { bindActionCreators } from 'redux';
import { isNil } from 'lodash';
import { connect } from 'react-redux';
import { compose, withHandlers, withState } from 'recompose';
import { has } from 'lodash';
import { withBounds } from '../../behaviours';
import { actionCreators as sessionsActions } from '../../ducks/modules/sessions';
import { nodePrimaryKeyProperty, nodeAttributesProperty } from '../../ducks/modules/network';
Expand All @@ -21,7 +21,8 @@ const withDropHandlers = withHandlers({
onDrop: ({ updateNode, layoutVariable, setRerenderCount, rerenderCount, width, height, x, y }) =>
(item) => {
updateNode(
item.meta,
item.meta[nodePrimaryKeyProperty],
{},
{
[layoutVariable]: relativeCoords({ width, height, x, y }, item),
},
Expand All @@ -30,19 +31,18 @@ const withDropHandlers = withHandlers({
// Horrible hack for performance (only re-render nodes on drop, not on drag)
setRerenderCount(rerenderCount + 1);
},
onDrag: ({ layoutVariable, updateNode, width, height, x, y }) => (item) => {
if (!has(item.meta[nodeAttributesProperty], layoutVariable)) { return; }

updateNode(
item.meta,
{
[layoutVariable]: relativeCoords({ width, height, x, y }, item),
},
);
},
onDragEnd: ({ layoutVariable, setRerenderCount, rerenderCount }) => (item) => {
if (!has(item.meta[nodeAttributesProperty], layoutVariable)) { return; }

onDrag: ({ layoutVariable, updateNode, width, height, x, y }) =>
(item) => {
if (isNil(item.meta[nodeAttributesProperty][layoutVariable])) { return; }
updateNode(
item.meta[nodePrimaryKeyProperty],
{},
{
[layoutVariable]: relativeCoords({ width, height, x, y }, item),
},
);
},
onDragEnd: ({ setRerenderCount, rerenderCount }) => () => {
// make sure to also re-render nodes that were updated on drag end
setRerenderCount(rerenderCount + 1);
},
Expand Down
Loading

0 comments on commit 5ef8852

Please sign in to comment.