Skip to content

Commit

Permalink
Merge pull request #368 from codaco/feature/quick-add-namegen
Browse files Browse the repository at this point in the history
implement quick add property in name gen editor
  • Loading branch information
jthrilly authored Jan 18, 2019
2 parents e7697b0 + ca73deb commit e2a1b13
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 34 deletions.
4 changes: 3 additions & 1 deletion config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,9 @@ module.exports = {
// It is guaranteed to exist because we tweak it in `env.js`
process.env.NODE_PATH.split(path.delimiter).filter(Boolean),
),
alias: {},
alias: {
concaveman: path.join(paths.appSrc, 'utils', 'webShims', 'concavemock.js'),
},
plugins: [
// Prevents users from importing files from outside of src/ (or node_modules/).
// This often causes confusion because we only process files within src/ with babel.
Expand Down
4 changes: 2 additions & 2 deletions src/components/StageEditor/Interfaces/NameGenerator.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
Name,
NodeType,
Form,
FormWithQuickAdd,
NameGeneratorPrompts,
NodePanels,
} from '../sections';
Expand All @@ -10,7 +10,7 @@ const NameGenerator = {
sections: [
Name,
NodeType,
Form,
FormWithQuickAdd,
NameGeneratorPrompts,
NodePanels,
],
Expand Down
58 changes: 58 additions & 0 deletions src/components/StageEditor/sections/FormWithQuickAdd.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import React, { PureComponent } from 'react';
import { connect } from 'react-redux';
import { compose } from 'recompose';
import cx from 'classnames';
import { Field, formValueSelector } from 'redux-form';
import Guidance from '../../Guidance';
import { Toggle } from '../../../ui/components/Fields';
import Form from './Form';

class FormWithQuickAdd extends PureComponent {
render() {
const {
quickAdd,
disabled,
} = this.props;

const formClasses = cx(
'stage-editor-section',
{ 'stage-editor-section--disabled': disabled },
);

return (
<div>
<Guidance contentId="guidance.editor.quickAdd">
<div className={formClasses}>
<h2 id="issue-form">Quick Add</h2>
<p>Should this stage use the quick add function?</p>
<div className="stage-editor-section-form">
<Field
name="quickAdd"
component={Toggle}
label="Enable the quick add function"
/>
</div>
</div>
</Guidance>
{ !quickAdd && <Form {...this.props} /> }
</div>
);
}
}

const mapStateToProps = (state, { form }) => {
const selector = formValueSelector(form.name);
const quickAdd = selector(state, 'quickAdd');
const nodeType = selector(state, 'subject.type');

return {
quickAdd,
disabled: !nodeType,
};
};

export { FormWithQuickAdd };

export default compose(
connect(mapStateToProps),
)(FormWithQuickAdd);
1 change: 1 addition & 0 deletions src/components/StageEditor/sections/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export { default as Title } from './Title';
export { default as Name } from './Name';
export { default as NodeType } from './NodeType';
export { default as Form } from './Form';
export { default as FormWithQuickAdd } from './FormWithQuickAdd';
export { default as NameGeneratorPrompts } from './NameGeneratorPrompts';
export { default as NameGeneratorListPrompts } from './NameGeneratorListPrompts';
export { default as NameGeneratorAutoCompletePrompts } from './NameGeneratorAutoCompletePrompts';
Expand Down
14 changes: 14 additions & 0 deletions src/locales/en-US.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,20 @@ export default {
</p>
</Fragment>
),
'guidance.editor.quickAdd': (
<Fragment>
<h3>The Quick Add function</h3>
<p>Using the quick add function allowa your participants to create a node by simply
entering a display label for it and pressing the enter key. The quick add form does not
obscure the node list, and will stay open and focused while the participant types,
providing an ideal environment for quickly listing off names.
</p>
<p>This function bypasses the new node form, and no other node attribute data collection is
possible at the time the node is created (although it can of course be collected in future
stages).
</p>
</Fragment>
),
'guidance.editor.form': (
<Fragment>
<h3>Choosing a Form</h3>
Expand Down
2 changes: 1 addition & 1 deletion src/network-canvas
2 changes: 1 addition & 1 deletion src/ui
Submodule ui updated from 42cef8 to c94c23
2 changes: 2 additions & 0 deletions src/utils/webShims/concavemock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Temporary workaround until unsafe-eval issue is resolved
module.exports = () => {};
29 changes: 0 additions & 29 deletions src/utils/webShims/mockProtocol.json
Original file line number Diff line number Diff line change
Expand Up @@ -473,35 +473,6 @@
"entity": "node",
"type": "d39a47507bbe27c2a7948861847f3607eda8e1be"
},
"skipLogic": {
"action": "SHOW",
"operator": "EXACTLY",
"value": "3",
"filter": {
"join": "OR",
"rules": [
{
"type": "alter",
"id": "15218241538622",
"options": {
"type": "d39a47507bbe27c2a7948861847f3607eda8e1be",
"attribute": "6ae999552a0d2dca14d62e2bc8b764d377b1dd6c",
"operator": "EXACTLY",
"value": "Dee"
}
},
{
"type": "ego",
"id": "15218241553253",
"options": {
"attribute": "6ae999552a0d2dca14d62e2bc8b764d377b1dd6c",
"operator": "EXACTLY",
"value": "Bob"
}
}
]
}
},
"panels": [
{
"title": "Already mentioned",
Expand Down

0 comments on commit e2a1b13

Please sign in to comment.