Merge branch 'master' into feat/api/add_statement

This commit is contained in:
Jalil Arfaoui 2016-12-20 17:01:29 +01:00
commit 65ecb15706
65 changed files with 916 additions and 906 deletions

View file

@ -31,38 +31,53 @@
"jsx": true
},
"globals": {
"document": false,
"window": false,
"global": false,
"require": false,
"expect": false,
"should": false,
"chai": false,
"sinon": false,
"Power2": false,
"Sine": false,
"__DEVELOPMENT__": false
},
"rules": {
"max-len": [0],
"new-cap": ["warn", {"capIsNewExceptions": [
"Immutable",
"Map",
"List",
"Set",
"OrderedSet",
"Range",
"Moment",
"Linker",
"Moment"
]}],
"comma-dangle": ["warn", "always-multiline"], // disallow or enforce trailing commas
"curly": ["warn", "multi-or-nest"], // specify curly brace conventions for all control statements
"indent": ["warn", 2, {"SwitchCase": 1}], // this option sets a specific tab width for your code (off by default)
"indent": ["warn", 2, {
"SwitchCase": 1,
"MemberExpression": 1,
"FunctionDeclaration": {"parameters": "first"},
"FunctionExpression": {"parameters": "first"},
"CallExpression": {"arguments": 1}
}], // this option sets a specific tab width for your code (off by default)
"brace-style": ["warn", "1tbs", { "allowSingleLine": true }], // enforce one true brace style (off by default)
"key-spacing": ["warn", {"beforeColon": false, "afterColon": true}], // enforces spacing between keys and values in object literal properties
"quotes": ["warn", "single", "avoid-escape"], // specify whether double or single quotes should be used
"keyword-spacing": ["warn", {"before": true, "after": true}], // require a space after certain keywords (off by default)
"no-underscore-dangle": [0],
"import/no-extraneous-dependencies": [0], // because broken
"import/no-unresolved": [0], // because broken
"import/extensions": [0],
"import/prefer-default-export": [0],
"global-require": [0],
"linebreak-style": "off",
// React
//"computed-property-spacing": ["warn", "never"], // disallow spaces inside computed properties
"react/jsx-indent-props": ["warn", 2]
"react/jsx-indent-props": ["warn", 2],
"react/forbid-prop-types": [0],
"react/no-unescaped-entities": [0],
"react/no-unused-prop-types": [0], // because broken
"react/sort-comp": [1, {
"order": [
"static-methods",
"lifecycle",
"/^on.+$/",
"everything-else",
"/^render.+$/",
"render"
]
}]
}
}

View file

@ -1,3 +1,4 @@
/* eslint-disable import/imports-first */
import jquery from 'jquery';
global.$ = jquery;
global.jQuery = jquery;

View file

@ -12,8 +12,8 @@
"copy-mocks": "node scripts/copy-mocks.js",
"renderer": "node ./renderer/renderer.js",
"clean": "./node_modules/.bin/rimraf ./build integration/main.css integration/static && echo --- Cleaned ---",
"lint": "eslint src",
"lint-fix": "eslint src --fix",
"lint": "eslint --ext .js --ext .jsx src webpack stories",
"lint-fix": "npm run lint -- --fix",
"test": "jest --coverage",
"test-watch": "jest --watch",
"e2e-test": "./node_modules/.bin/nightwatch",
@ -77,7 +77,7 @@
"@kadira/storybook-addon-knobs": "^1.4.1",
"babel-cli": "<6.3.0",
"babel-core": "<6.3.0",
"babel-eslint": "^6.0.0",
"babel-eslint": "^7.1.0",
"babel-loader": "~6.2.1",
"babel-plugin-ramda": "^1.1.6",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
@ -89,11 +89,11 @@
"copy-webpack-plugin": "^2.1.3",
"css-loader": "^0.23.0",
"enzyme": "^2.3.0",
"eslint": "^2.5.3",
"eslint-config-airbnb": "^6.2.0",
"eslint-plugin-import": "^1.10.2",
"eslint-plugin-jsx-a11y": "^1.5.5",
"eslint-plugin-react": "^4.2.3",
"eslint": "^3.9.1",
"eslint-config-airbnb": "^12.0.0",
"eslint-plugin-import": "^1.16.0",
"eslint-plugin-jsx-a11y": "^2.2.3",
"eslint-plugin-react": "^6.5.0",
"extract-text-webpack-plugin": "^0.9.1",
"file-loader": "^0.8.4",
"html-webpack-plugin": "^2.15.0",

View file

@ -1,10 +1,11 @@
/* eslint-disable jsx-a11y/href-no-hash */
import React from 'react';
import paths from 'constants/paths';
import { Link } from 'react-router';
const Footer = () => (
<footer className="footer">
<div className="col-md-1"></div>
<div className="col-md-1" />
<div className="col-md-3">
<small>
<a href="#">Crédits</a>
@ -20,7 +21,7 @@ const Footer = () => (
</ul>
</nav>
</div>
<div className="col-md-1"></div>
<div className="col-md-1" />
</footer>
);

View file

@ -1,3 +1,5 @@
/* eslint-disable jsx-a11y/href-no-hash */
import React, { PropTypes } from 'react';
import { Link } from 'react-router';
import paths from 'constants/paths';
@ -6,12 +8,12 @@ const ConnectedUserMenu = ({ user, onLogOut }) => (
<li className="dropdown">
<a href="#" className="dropdown-toggle" data-toggle="dropdown">
{user.name}
<b className="caret"></b>
<b className="caret" />
</a>
<ul className="dropdown-menu">
<li><Link to={paths.getFor.user(user)}>Profil</Link></li>
<li className="divider"></li>
<li><a onClick={onLogOut}>Déconnexion</a></li>
<li className="divider" />
<li><a href="#" onClick={onLogOut}>Déconnexion</a></li>
</ul>
</li>
);

View file

@ -4,13 +4,14 @@ import cssModules from 'react-css-modules';
import { Navbar, Nav, NavItem } from 'react-bootstrap';
import { LinkContainer, IndexLinkContainer } from 'react-router-bootstrap';
import paths from 'constants/paths';
import ConnectedUserMenu from './';
import paths from 'constants/paths';
import logoImg from './images/logo_header.png';
import styles from './Header.css';
const renderUserMenu = (isConnected) => (
const renderUserMenu = isConnected => (
isConnected
? <ConnectedUserMenu />
: [
@ -25,7 +26,7 @@ const Header = () => (
<Navbar.Brand>
<IndexLinkContainer to="/" styleName="logo">
<NavItem>
<img src={logoImg} />
<img alt="Brand Logo" src={logoImg} />
</NavItem>
</IndexLinkContainer>
</Navbar.Brand>

View file

@ -1,5 +1,6 @@
/* eslint-disable no-unused-vars */
import React from 'react';
// eslint-disable-next-line no-unused-vars
import { storiesOf, action, linkTo } from '@kadira/storybook';
import { withKnobs, text, boolean, number } from '@kadira/storybook-addon-knobs';

View file

@ -1,3 +1,5 @@
/* eslint-disable no-unused-vars */
import { curry } from 'ramda';
import axios from 'axios';
import Config from 'Config';
@ -13,5 +15,4 @@ export const getStatements = () => get('statements');
export const getPublicFiguresAutocomplete = typed => get(`autocomplete/public_figure/${typed}`);
export const getSubjectsAutocomplete = typed => get(`autocomplete/subject/${typed}`);
export const getPositions = subjectId => get(`subjects/${subjectId}/positions`);
export const postStatement = statement => post('statements', statement);

View file

@ -1,5 +1,5 @@
require('bootstrap-loader');
import moment from 'moment';
import 'bootstrap-loader';
const locale = 'fr';
moment.locale(locale);
@ -18,5 +18,6 @@ moment.locale(locale, {
if (process.env.NODE_ENV !== 'production') { // DEBUG/DEV MODE
const Immutable = require('immutable');
const installDevTools = require('immutable-devtools').default;
installDevTools(Immutable);
}

View file

@ -1,4 +1,4 @@
import React, { PropTypes, Component } from 'react';
import React, { Component, PropTypes } from 'react';
import { Button } from 'react-bootstrap';
import AddStatementModal from 'components/AddStatementModal';
import connect from './connector';

View file

@ -5,6 +5,7 @@ import AddSubjectFrom from './AddSubjectForm';
const SubjectStep = ({ selected, onSelection }) => (
<Well>
<<<<<<< HEAD
<FormGroup controlId="subjectSelect" validationState={selected && !selected.customOption ? 'success' : undefined}>
<ControlLabel>Quel est le sujet qui fait débat ?</ControlLabel>
{(!selected || !selected.customOption) &&
@ -16,6 +17,11 @@ const SubjectStep = ({ selected, onSelection }) => (
onChange={onSelection}
onCancel={() => onSelection(null)}
/>}
=======
<FormGroup controlId="subjectSelect" validationState={!!selected ? 'success' : undefined}>
<ControlLabel>Quel est le sujet qui fait débat ?</ControlLabel>
<SubjectAutocompleteInput selected={selected} onSelection={onSelection} />
>>>>>>> master
</FormGroup>
</Well>
);

View file

@ -2,6 +2,12 @@ import React, { PropTypes } from 'react';
import { propEq, prop, compose, find } from 'ramda';
import { Well } from 'react-bootstrap';
const getPositionInSubject = (position, subject) => compose(
find(po => propEq('id', position, po)),
prop('positions'),
)(subject);
const SummaryStep = ({
publicFigure, subject, position, date, evidenceUrl, evidenceFile, evidenceSource, quote, note, tags,
}) => (

View file

@ -1,7 +1,7 @@
import { connect } from 'react-redux';
import {
getAddStatementPublicFigure, getAddStatementSubject, getAddStatementPosition,
getAddStatementEvidenceUrl, getAddStatementEvidenceFile
getAddStatementEvidenceUrl, getAddStatementEvidenceFile,
} from 'store/selectors';
import {
onAddStatementPublicFigureSelection, onAddStatementSubjectSelection, onAddStatementPositionSelection,

View file

@ -1,20 +1,20 @@
import React, { PropTypes } from 'react';
const getText = nb => {
const getText = (nb) => {
if (nb === 0)
return "Aucun sujet actif";
return 'Aucun sujet actif';
else if (nb > 1)
return nb + "sujets actifs";
return `${nb}sujets actifs`;
return "1 sujet actif";
return '1 sujet actif';
};
const AssociatedSubjects = ({ publicFigure }) => (
<h6 style={{ color: "#f21e40 !important" }}>{getText(publicFigure.nbActiveSubjects)}</h6>
<h6 style={{ color: '#f21e40 !important' }}>{getText(publicFigure.nbActiveSubjects)}</h6>
);
AssociatedSubjects.propTypes = {
publicFigure: PropTypes.object.isRequired
publicFigure: PropTypes.object.isRequired,
};
export default AssociatedSubjects;

View file

@ -1,3 +1,4 @@
/* eslint-disable no-unused-vars */
import React from 'react';
import { storiesOf, action, linkTo } from '@kadira/storybook';
import Identity from './';

View file

@ -1,5 +1,5 @@
import React, { PropTypes, Component } from 'react';
import CSSModules from 'react-css-modules';
import cssModules from 'react-css-modules';
import Statement from './Statement';
import LastStatementsStyle from './LastStatements.css';
import connect from './connector';
@ -32,4 +32,4 @@ class LastStatements extends Component {
}
}
export default connect(CSSModules(LastStatements, LastStatementsStyle));
export default connect(cssModules(LastStatements, LastStatementsStyle));

View file

@ -6,7 +6,7 @@ const PublicFigureAvatar = ({ publicFigure }) => (
<div
styleName="wrapper"
style={{
backgroundImage: !!publicFigure.picture
backgroundImage: publicFigure.picture
? `url(${publicFigure.picture.url})`
: undefined,
}}

View file

@ -1,5 +1,6 @@
/* eslint-disable no-unused-vars */
import React from 'react';
// eslint-disable-next-line no-unused-vars
import { storiesOf, action, linkTo } from '@kadira/storybook';
import { withKnobs, text, boolean, number } from '@kadira/storybook-addon-knobs';
import withReadme from 'storybook-readme/with-readme';

View file

@ -13,7 +13,6 @@ const parseSubjects = raw => pipe(
)
)(raw.data);
class SubjectAutocompleteInput extends Component {
static propTypes = {
@ -57,6 +56,24 @@ class SubjectAutocompleteInput extends Component {
onSelection = compose(this.props.onSelection, head);
loadSuggestions = (typed) => {
if (this.props.selected) this.props.onSelection(null);
if (typed.length) {
getSubjectsAutocomplete(typed)
.then((response) => {
this.setState({
suggestions: flattenAttributes(response.data.data),
});
}); }
};
renderMenuItemChildren = (typeaheadProps, subject) => (
<div>
<p>{subject.title} </p>
<small>{take(100)(subject.presentation)}</small>
</div>
);
render() {
return (
<Typeahead

View file

@ -1,4 +0,0 @@
import React from 'react';
const Empty = () => <span />;
export default Empty;

View file

@ -3,8 +3,8 @@ export default {
subjects: '/s',
publicFigures: '/p',
getFor: {
subject: (s) => `/s/${s.slug}`,
publicFigure: (pf) => `/p/${pf.slug}`,
subject: s => `/s/${s.slug}`,
publicFigure: pf => `/p/${pf.slug}`,
},
manual: '/guide',
about: '/about',

View file

@ -1,11 +1,11 @@
import { pipe, always } from 'ramda';
import { pipe } from 'ramda';
const print = message => x => {
if (!!message) console.warn(message);
const print = message => (x) => {
if (message) console.warn(message);
return x;
};
const printWithPrefix = (prefix) => (x) => {
const printWithPrefix = prefix => (x) => {
console.warn('-------------------------------');
console.warn(`---- ${prefix}: `, x);
return x;
@ -16,5 +16,5 @@ const printAfter = printWithPrefix('AFTER');
export const withConsole = (f, message) => pipe(printBefore, print(message), f, printAfter);
export const log = x => { console.log(x); return x; }; /* eslint no-console: 0 */
export const warn = x => { console.warn(x); return x; }; /* eslint no-console: 0 */
export const log = (x) => { console.log(x); return x; }; /* eslint no-console: 0 */
export const warn = (x) => { console.warn(x); return x; }; /* eslint no-console: 0 */

View file

@ -1,4 +1,5 @@
import { complement } from 'ramda';
export const hasWindow = () => (typeof window !== 'undefined');
export const isClientSide = hasWindow;
export const isServerSide = complement(hasWindow);

View file

@ -1,9 +1,6 @@
import 'react-hot-loader/patch'; // https://github.com/gaearon/redux-devtools/commit/64f58b7010a1b2a71ad16716eb37ac1031f93915
import 'babel-polyfill';
// First boot side effects
import './boot.js';
import React from 'react';
import ReactDOM from 'react-dom';
import { AppContainer } from 'react-hot-loader';
@ -11,6 +8,10 @@ import { match } from 'react-router';
// Styles
import 'styles/_main.css';
// First boot side effects
import './boot.js';
// Redux
import { store, history } from './store'; // Redux store
import Root from './root'; // App root (Router, Provider, Hot reload ...
@ -20,7 +21,7 @@ import routes from './routes'; // React-router routes
const loadApplication = (DOMElementId) => {
const DOMElement = document.getElementById(DOMElementId);
match({ history, routes, location }, () => {
match({ history, routes }, () => {
ReactDOM.render(
<AppContainer>
<Root store={store} history={history} />

View file

@ -13,12 +13,12 @@ const Contact = () => (
<ul className="list-inline banner-social-buttons">
<li>
<a href="mailto:contact@debats.co" className="btn btn-default btn-lg">
<i className="fa fa-envelope-o fa-fw"></i><span className="network-name">&nbsp;Courriel</span>
<i className="fa fa-envelope-o fa-fw" /><span className="network-name">&nbsp;Courriel</span>
</a>
</li>
<li>
<a href="https://twitter.com/debatsco" className="btn btn-default btn-lg">
<i className="fa fa-twitter fa-fw"></i> <span className="network-name">Twitter</span>
<i className="fa fa-twitter fa-fw" /> <span className="network-name">Twitter</span>
</a>
</li>
</ul>

View file

@ -4,7 +4,7 @@ import styles from './Guide.css';
const Guide = () => (
<div>
<div className="col-md-1"></div>
<div className="col-md-1" />
<div className="col-md-10">
<h1>Mode d'emploi</h1>
@ -152,7 +152,7 @@ const Guide = () => (
</div>
</div>
</div>
<div className="col-md-1"></div>
<div className="col-md-1" />
</div>
);

View file

@ -1,7 +1,7 @@
import React from 'react';
import cssModules from 'react-css-modules';
import HomeSubjects from './HomeSubjects';
import LastStatements from 'components/LastStatements';
import HomeSubjects from './HomeSubjects';
import bgSrc from './images/intro-bg.jpg';
import styles from './Home.css';
import AddStatementButton from 'components/AddStatementButton';
@ -29,10 +29,11 @@ const Home = () => (
</tbody>
</table>
</div>
<div className="col-md-1" />
<div className="col-md-3 col-centered" style={{ textAlign: 'right' }}>
<LastStatements />
</div>
<div className="col-md-1"></div>
<div className="col-md-1" />
</div>
);

View file

@ -1,10 +1,12 @@
import React, { PropTypes } from 'react';
import paths from '../../../constants/paths';
import cssModules from 'react-css-modules';
import { Link } from 'react-router';
import paths from 'constants/paths';
import PublicFigureAvatar from 'components/PublicFigureAvatar';
import AssociatedSubjects from 'components/AssociatedSubjects';
import PublicFigureStyle from './PublicFigure.css';
import cssModules from 'react-css-modules';
const PublicFigureInList = ({ publicFigure }) => (
<table className="table">
@ -43,13 +45,3 @@ PublicFigureInList.propTypes = {
};
export default cssModules(PublicFigureInList, PublicFigureStyle);
/*
<script type="text/javascript">
$(document).ready(function() {
$(".figure-presentation-text").shorten();
});
</script>
*/

View file

@ -1,7 +1,8 @@
import React, { PropTypes, Component } from 'react';
import LastStatements from 'components/LastStatements';
import PublicFigureInList from './PublicFigureInList';
import connect from './connector';
import LastStatements from 'components/LastStatements';
class PublicFigures extends Component {

View file

@ -1,81 +0,0 @@
import React from 'react';
import { Route, IndexRoute } from 'react-router';
// Main Page
import Main from 'Main/index';
export default (
<Route path="/" component={Main}>
<IndexRoute
getComponent={(nextState, done) => {
require.ensure([], require => {
done(null, require('pages/Home').default);
}, 'home');
}}
/>
<Route
path="contact"
name="contact"
getComponent={(nextState, done) => {
require.ensure([], require => {
done(null, require('pages/Contact').default);
}, 'contact');
}}
/>
<Route
path="about"
name="about"
getComponent={(nextState, done) => {
require.ensure([], require => {
done(null, require('pages/About').default);
}, 'about');
}}
/>
<Route
path="guide"
name="guide"
getComponent={(nextState, done) => {
require.ensure([], require => {
done(null, require('pages/Guide').default);
}, 'guide');
}}
/>
<Route path="s" name="subjects">
<IndexRoute
name="subjects.index"
getComponent={(nextState, done) => {
require.ensure([], require => {
done(null, require('pages/Subjects').default);
}, 'subjects.index');
}}
/>
<Route
name="subjects.page"
path=":subjectSlug"
getComponent={(nextState, done) => {
require.ensure([], require => {
done(null, require('pages/Subject').default);
}, 'subjects.page');
}}
/>
</Route>
<Route path="p" name="publicFigures">
<IndexRoute
name="publicFigures.index"
getComponent={(nextState, done) => {
require.ensure([], require => {
done(null, require('pages/PublicFigures').default);
}, 'publicFigures.index');
}}
/>
<Route
name="publicFigures.page"
path=":publicFigureSlug"
getComponent={(nextState, done) => {
require.ensure([], require => {
done(null, require('pages/publicFigure').default);
}, 'publicFigures.page');
}}
/>
</Route>
</Route>
);

82
src/routes/index.jsx Normal file
View file

@ -0,0 +1,82 @@
import React from 'react';
import { Route, IndexRoute } from 'react-router';
// Main Page
import Main from 'Main/index';
export default (
<Route path="/" component={Main}>
<IndexRoute
getComponent={(nextState, done) => {
require.ensure([], (require) => {
done(null, require('pages/Home').default);
}, 'home');
}}
/>
<Route
path="contact"
name="contact"
getComponent={(nextState, done) => {
require.ensure([], (require) => {
done(null, require('pages/Contact').default);
}, 'contact');
}}
/>
<Route
path="about"
name="about"
getComponent={(nextState, done) => {
require.ensure([], (require) => {
done(null, require('pages/About').default);
}, 'about');
}}
/>
<Route
path="guide"
name="guide"
getComponent={(nextState, done) => {
require.ensure([], (require) => {
done(null, require('pages/Guide').default);
}, 'guide');
}}
/>
<Route path="s" name="subjects">
<IndexRoute
name="subjects.index"
getComponent={(nextState, done) => {
require.ensure([], (require) => {
done(null, require('pages/Subjects').default);
}, 'subjects.index');
}}
/>
<Route
name="subjects.page"
path=":subjectSlug"
getComponent={(nextState, done) => {
require.ensure([], (require) => {
done(null, require('pages/Subject').default);
}, 'subjects.page');
}}
/>
</Route>
<Route path="p" name="publicFigures">
<IndexRoute
name="publicFigures.index"
getComponent={(nextState, done) => {
require.ensure([], (require) => {
done(null, require('pages/PublicFigures').default);
}, 'publicFigures.index');
}}
/>
<Route
name="publicFigures.page"
path=":publicFigureSlug"
getComponent={(nextState, done) => {
require.ensure([], (require) => {
done(null, require('pages/publicFigure').default);
}, 'publicFigures.page');
}}
/>
</Route>
</Route>
);

View file

@ -1,6 +1,6 @@
import types from '../actions_types';
export const onAddStatementValidate = (newStatement) => ({
export const onAddStatementValidate = newStatement => ({
type: types.ADD_STATEMENT_VALIDATE,
payload: { ...newStatement },
});

View file

@ -1,16 +1,15 @@
import { createStore, applyMiddleware, combineReducers, compose } from 'redux';
import createSagaMiddleware from 'redux-saga';
import { routerReducer, routerMiddleware } from 'react-router-redux';
import { routerReducer, routerMiddleware, syncHistoryWithStore } from 'react-router-redux';
import { map } from 'ramda';
import { isClientSide } from 'helpers/env';
import rootSaga from './sagas';
import { entitiesReducer, addStatementReducer } from './reducers';
import { useRouterHistory } from 'react-router';
import { syncHistoryWithStore } from 'react-router-redux';
import createHashHistory from 'history/lib/createHashHistory';
import createMemoryHistory from 'history/lib/createMemoryHistory';
import rootSaga from './sagas';
import { entitiesReducer } from './reducers';
// Build history
const createHistory = isClientSide() ? createHashHistory : createMemoryHistory;
// const browserHistory = useScroll(useRouterHistory(createHistory))();
@ -23,7 +22,6 @@ const initialState = isClientSide() ? window.__INITIAL_STATE__ : {};
const reducer = combineReducers({
routing: routerReducer,
entities: entitiesReducer,
addStatement: addStatementReducer,
});
// MIDDLEWARE

View file

@ -1,45 +0,0 @@
import {
assoc, compose, not, allPass, prop, isNil, either, complement,
} from 'ramda';
import actionsTypes from '../actions_types';
const initialState = {
publicFigureId: null,
subjectId: null,
positionId: null,
statementDate: null,
evidenceUrl: null,
evidenceFile: null,
quote: null,
note: null,
tags: [],
};
const isPublicFigureChosen = compose(not, isNil, prop('publicFigureId'));
const isSubjectChosen = compose(not, isNil, prop('publicFigureId'));
const isPositionChosen = compose(not, isNil, prop('publicFigureId'));
const isStatementComplete = allPass([
compose(not, isNil, prop('statementDate')),
compose(not, isNil, prop('quote')),
compose(not, isNil, prop('statementDate')),
either(
compose(not, isNil, prop('evidenceUrl')),
compose(not, isNil, prop('evidenceFile')),
)
]);
const isPublicFigureMissing = complement(isPublicFigureChosen);
const isSubjectMissing = complement(isSubjectChosen);
const isPositionMissing = complement(isPositionChosen);
const isStatementIncomplete = complement(isStatementComplete);
export const addStatementReducer = (state = initialState, action) => {
switch (action.type) {
case actionsTypes.ADD_STATEMENT_PUBLIC_FIGURE_SELECTION: return assoc('publicFigureId', action.id, state);
case actionsTypes.ADD_STATEMENT_SUBJECT_SELECTION: return assoc('subjectId', action.id, state);
case actionsTypes.ADD_STATEMENT_POSITION_SELECTION: return assoc('positionId', action.id, state);
case actionsTypes.ADD_STATEMENT_UPDATE_EVIDENCE_URL: return assoc('evidenceUrl', action.url, state);
case actionsTypes.ADD_STATEMENT_UPDATE_EVIDENCE_FILE: return assoc('evidenceFile', action.file, state);
default: return state;
}
};

View file

@ -1,7 +1,8 @@
import actionsType from '../actions_types';
import { map, compose, prop, merge, assoc, not, isNil, pipe, when } from 'ramda';
const initialState = {};
import { indexAndGroup } from 'api/jsonApiParser';
import actionsType from '../actions_types';
const initialState = {};
const isNotNil = compose(not, isNil);

View file

@ -1,2 +1,2 @@
export * from './entities';
export * from './addStatement';

View file

@ -1,9 +1,10 @@
import { identity } from 'ramda';
import actionsTypes from '../actions_types';
import { takeEvery } from 'redux-saga';
import { call, put } from 'redux-saga/effects';
import { getSubjects, getStatements, getPositions } from 'api/debats';
import actionsTypes from '../actions_types';
const getApiCallFor = (entityType, entityRequest) => {
switch (entityType) {
case 'statements': return getStatements;
@ -41,3 +42,4 @@ function* fetchEntityIfNeeded(action) {
export function* watchEntityAccess() {
yield* takeEvery(actionsTypes.ENTITY_ACCESS, fetchEntityIfNeeded);
}

View file

@ -2,8 +2,6 @@ import { createSelector } from 'reselect';
import { prop, propEq, find, pipe, dissoc, when, not, isNil, compose } from 'ramda';
import { getPublicFigures, getSubjects, getPositions, enrichWithRelationships } from './entities';
import { withConsole } from 'helpers/debug';
const isNotNil = compose(not, isNil);
const getAddState = state => state.addStatement;

View file

@ -1,10 +1,10 @@
import { curry, assoc, compose, when, take, path, is, map, isNil, always, values, propEq, ifElse, pipe, find } from 'ramda';
export const getSubjects = state => values(state.entities.subjects);
export const getPositions = state => values(state.entities.positions);
export const getStatements = state => values(state.entities.statements);
export const getPublicFigures = state => values(state.entities['public-figures']);
import { withConsole, warn } from 'helpers/debug';
const getEntityByRef = curry(
(sourceEntities, entityReference) => ifElse(

View file

@ -1,4 +1,6 @@
/* eslint-disable import/export */ // since positions.js is an empty file
export * from './positions';
export * from './publicFigures';
export * from './statements';
export * from './subjects';

View file

@ -1,4 +1,6 @@
import { values, pipe, compose, map, dissoc, prop } from 'ramda';
/* eslint-disable no-unused-vars */
import { values, pipe, compose, map, dissoc } from 'ramda';
import { whenNotNil } from 'helpers/ramda-ext';
import { createSelector } from 'reselect';
import { enrichWithRelationships, getSubjects, getPublicFigures } from './entities';

View file

@ -2,7 +2,7 @@ import { values, pipe, map, compose, dissoc } from 'ramda';
import { createSelector } from 'reselect';
import { whenNotNil } from 'helpers/ramda-ext';
import {
enrichWithRelationship, getPublicFigures, getPositions, getSubjects, getStatements
enrichWithRelationship, getPublicFigures, getPositions, getSubjects, getStatements,
} from './entities';
const injectPublicFigure = enrichWithRelationship('publicFigure', 'public-figure');

View file

@ -1,9 +1,8 @@
import { values, pipe, compose, map, dissoc, propEq } from 'ramda';
import { find, values, pipe, compose, map, dissoc, propEq } from 'ramda';
import { createSelector } from 'reselect';
import { whenNotNil } from 'helpers/ramda-ext';
import { enrichWithRelationships, getPublicFigures, getPositions, getSubjects } from './entities';
import { withConsole } from 'helpers/debug';
import { enrichWithRelationships, getPublicFigures, getPositions, getSubjects } from './entities';
export const getHomeSubjects = state => values(getSubjects(state));

View file

@ -1,3 +1,3 @@
import { urlRegex } from './generic';
export const isValidEvidenceUrl = (tested) => urlRegex.test(tested);
export const isValidEvidenceUrl = tested => urlRegex.test(tested);

View file

@ -1,4 +1,5 @@
const CONSTANTS = require('../webpack/constants');
const APP_PATH = CONSTANTS.APP_PATH;
const loaders = [

View file

@ -12,7 +12,7 @@ const postcssHide = require('postcss-hide');
const CONSTANTS = require('./constants');
const makeMap = aPath => {
const makeMap = (aPath) => {
try {
return webpackPostcssTools.makeVarMap(aPath);
} catch (e) {
@ -24,6 +24,7 @@ const makeMap = aPath => {
const map = makeMap('./src/styles/_constants.css');
// eslint-disable-next-line no-unused-vars
module.exports = webpack => [
postcssMixins({
mixinsDir: path.join(CONSTANTS.APP_PATH, 'style', 'mixins'),

View file

@ -1,6 +1,6 @@
const path = require('path');
const CONSTANTS = require('./constants');
const APP_ROOT = CONSTANTS.APP_ROOT;
module.exports = {

View file

@ -5,6 +5,7 @@ const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const CONSTANTS = require('./constants');
const APP_ROOT = CONSTANTS.APP_ROOT;
const SRC_FOLDER = CONSTANTS.SRC_FOLDER;

View file

@ -5,6 +5,7 @@ const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const CONSTANTS = require('./constants');
const APP_ROOT = CONSTANTS.APP_ROOT;
const APP_PATH = CONSTANTS.APP_PATH;
const SRC_FOLDER = CONSTANTS.SRC_FOLDER;
@ -34,7 +35,7 @@ config.devtool = 'cheap-module-source-map';
config.cache = false;
config.debug = false;
config.entry = `${APP_PATH}/index.js`;
config.output.path = outputPath;;
config.output.path = outputPath;
module.exports = config;

View file

@ -2,6 +2,7 @@ const config = require('./webpack.base.config');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CONSTANTS = require('./constants');
const APP_PATH = CONSTANTS.APP_PATH;
const APP_NAME = CONSTANTS.APP_NAME;
const SRC_FOLDER = CONSTANTS.SRC_FOLDER;
@ -13,7 +14,7 @@ config.plugins.push(new HtmlWebpackPlugin({
filename: 'index.html',
}));
config.entry = `${APP_PATH}/index.js`;
config.entry = `${APP_PATH}/index.jsx`;
config.output = {
filename: `${APP_NAME}.[name].[hash].js`,
};

View file

@ -5,6 +5,7 @@ const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const CONSTANTS = require('./constants');
const APP_ROOT = CONSTANTS.APP_ROOT;
const SRC_FOLDER = CONSTANTS.SRC_FOLDER;