Skip to content

Commit 9bd2ea6

Browse files
committed
Merge branch 'master' into #58-fix-pending-changes
2 parents 36ce9d5 + 55d81c6 commit 9bd2ea6

121 files changed

Lines changed: 1606 additions & 105 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"presets": [
3+
[
4+
"env",
5+
{
6+
"modules": false
7+
}
8+
],
9+
"react",
10+
"stage-2"
11+
]
12+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "reactboiler",
3+
"version": "1.0.0",
4+
"description": "",
5+
"scripts": {
6+
"start": "webpack-dev-server"
7+
},
8+
"author": "Braulio Diez",
9+
"license": "ISC",
10+
"dependencies": {
11+
"bootstrap": "^3.3.7",
12+
"core-js": "^2.4.1",
13+
"jquery": "^3.2.0",
14+
"lc-form-validation": "file:../../../../lib/",
15+
"react": "^15.4.2",
16+
"react-dom": "^15.4.2",
17+
"react-redux": "^5.0.3",
18+
"redux": "^3.6.0",
19+
"redux-thunk": "^2.2.0"
20+
},
21+
"devDependencies": {
22+
"babel-core": "^6.24.0",
23+
"babel-loader": "^6.4.1",
24+
"babel-preset-env": "^1.2.2",
25+
"babel-preset-react": "^6.23.0",
26+
"babel-preset-stage-2": "^6.22.0",
27+
"css-loader": "^0.27.3",
28+
"extract-text-webpack-plugin": "^2.1.0",
29+
"file-loader": "^0.10.1",
30+
"html-webpack-plugin": "^2.28.0",
31+
"style-loader": "^0.14.1",
32+
"url-loader": "^0.5.8",
33+
"webpack": "^2.2.1",
34+
"webpack-dev-server": "^2.4.2"
35+
}
36+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export const actionsDef = {
2+
customer: {
3+
CUSTOMER_PROCESS_UI_INPUT_START: 'CUSTOMER_UI_INPUT_START',
4+
CUSTOMER_PROCESS_UI_INPUT_COMPLETED: 'CUSTOMER_UI_INPUT_COMPLETED',
5+
CUSTOMER_SAVE_START: 'CUSTOMER_SAVE_START',
6+
CUSTOMER_SAVE_COMPLETED: 'CUSTOMER_SAVE_COMPLETED'
7+
}
8+
};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { actionsDef } from './actionsDef';
2+
3+
export const customerSaveCompleted = (formValidationResult) => {
4+
return {
5+
type: actionsDef.customer.CUSTOMER_SAVE_COMPLETED,
6+
formValidationResult
7+
}
8+
};
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { customerSaveCompleted } from './customerSaveCompleted';
2+
import { customerFormValidation } from '../components/sampleForm/validations/customerFormValidation';
3+
4+
export function customerSaveStart(viewModel) {
5+
6+
return (dispatcher) => {
7+
customerFormValidation.validateForm(viewModel).then(
8+
(formValidationResult) => {
9+
if (formValidationResult.succeeded) {
10+
// Call here the async call to save
11+
// additional logic or actions to be added on a real case
12+
console.log("Save Completed");
13+
}
14+
dispatcher(customerSaveCompleted(formValidationResult));
15+
}
16+
);
17+
}
18+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { customerUIInputCompleted } from './customerUInputCompleted';
2+
import { customerFormValidation } from '../components/sampleForm/validations/customerFormValidation';
3+
4+
export function customerUIInputStart(viewModel, fieldName, value) {
5+
return (dispatcher) => {
6+
customerFormValidation.validateField(viewModel, fieldName, value).then(
7+
(fieldValidationResult) => {
8+
dispatcher(customerUIInputCompleted(fieldName, value, fieldValidationResult));
9+
}
10+
);
11+
}
12+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { actionsDef } from "./actionsDef";
2+
3+
export const customerUIInputCompleted = (fieldName, value, fieldValidationResult) => {
4+
return {
5+
type: actionsDef.customer.CUSTOMER_PROCESS_UI_INPUT_COMPLETED,
6+
fieldName,
7+
value,
8+
fieldValidationResult
9+
}
10+
};
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import React from 'react';
2+
import ReduxThunk from 'redux-thunk';
3+
import { createStore, applyMiddleware } from 'redux';
4+
import { Provider } from 'react-redux';
5+
import reducers from '../reducers'
6+
import { ContainerSampleForm } from './sampleForm/sampleForm.container';
7+
8+
const store = createStore(
9+
reducers,
10+
applyMiddleware(ReduxThunk)
11+
);
12+
13+
export default class App extends React.Component {
14+
render() {
15+
return (
16+
<Provider store={store}>
17+
<div className="container-fluid">
18+
<ContainerSampleForm />
19+
</div>
20+
</Provider>
21+
);
22+
}
23+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import React from 'react';
2+
3+
export class Input extends React.Component {
4+
static propTypes = {
5+
name: React.PropTypes.string.isRequired,
6+
label: React.PropTypes.string.isRequired,
7+
type: React.PropTypes.string,
8+
value: React.PropTypes.string.isRequired,
9+
onChange: React.PropTypes.func.isRequired,
10+
error: React.PropTypes.string.isRequired,
11+
};
12+
13+
static defaultProps = {
14+
type: 'text',
15+
};
16+
17+
render() {
18+
let wrapperClass = 'form-group';
19+
if (this.props.error && this.props.error.length > 0) {
20+
wrapperClass = '${wrapperClass} has-error';
21+
}
22+
23+
return (
24+
<div className={wrapperClass}>
25+
<label htmlFor={this.props.name}>{this.props.label}</label>
26+
<div className="field">
27+
<input
28+
type={this.props.type}
29+
id={this.props.name}
30+
name={this.props.name}
31+
className="form-control"
32+
placeholder={this.props.placeholder}
33+
ref={this.props.name}
34+
value={this.props.value}
35+
onChange={this.props.onChange} />
36+
<div className="help-block">{this.props.error}</div>
37+
</div>
38+
</div>
39+
);
40+
}
41+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { connect } from 'react-redux';
2+
import { SampleForm } from './sampleForm';
3+
import { customerUIInputStart } from '../../actions/customerUIInputStart';
4+
import { customerSaveStart } from '../../actions/customerSaveStart';
5+
6+
const mapStateToProps = (state) => {
7+
return {
8+
customer: state.customer.customer,
9+
errors: state.customer.customerErrors
10+
}
11+
};
12+
13+
const mapDispatchToProps = (dispatch) => {
14+
return {
15+
fireValidationFieldValueChanged: (viewModel, fieldName, value) => {
16+
return dispatch(customerUIInputStart(viewModel, fieldName, value));
17+
},
18+
saveCustomer: (customer) => {
19+
return dispatch(customerSaveStart(customer));
20+
}
21+
}
22+
};
23+
24+
export const ContainerSampleForm = connect(
25+
mapStateToProps,
26+
mapDispatchToProps
27+
)(SampleForm);

0 commit comments

Comments
 (0)