Skip to content

Commit 5000de9

Browse files
authored
Revert "Ldpm formio library updates"
1 parent 5c94f3a commit 5000de9

24 files changed

+2963
-2953
lines changed

Changelog.md

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,6 @@ All notable changes to this project will be documented in this file
44
The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

7-
## 5.0.0-alpha.1
8-
### Changed
9-
- Refactored to work with latest React version.
10-
11-
## 4.3.0
12-
### Changed
13-
- Upgrade formio.js to 4.9.0.
14-
15-
## 4.2.6
16-
### Changed
17-
- Update dependencies for security updates.
18-
19-
## 4.2.5
20-
### Fixed
21-
- Check validity return correct value.
22-
23-
## 4.2.4
24-
### Fixed
25-
- Empty wizard change event.
26-
- Project access not setting correctly in auth state.
27-
287
## 4.2.3
298
### Fixed
309
- Change event on builder.

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ npm-compatible packaging system such as [Browserify](http://browserify.org/) or
1515

1616
```
1717
npm install react-formio --save
18-
npm install formiojs --save // Install formiojs since it is a peerDependency
1918
```
2019

2120
## Components
@@ -87,7 +86,7 @@ Please note that the FormBuilder component does not load and save from/to a url.
8786
| ```onSaveComponent``` | ```component```: object | Triggered when the component settings dialog is saved and closed |
8887
| ```onCancelComponent``` | ```component```: object | Triggered when the component settings dialog is cancelled |
8988
| ```onDeleteComponent``` | ```component```: object | Triggered when a component is removed from the form |
90-
| ```onUpdateComponent``` | ```component```: object | Triggered when a component is added or moved in the form |
89+
| ```updateComponent``` | ```component```: object | Triggered when a component is added or moved in the form |
9190

9291

9392
#### Example

lib/components/Errors.js

Lines changed: 91 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Object.defineProperty(exports, "__esModule", {
44
value: true
55
});
66

7+
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
8+
79
var _react = require('react');
810

911
var _react2 = _interopRequireDefault(_react);
@@ -14,93 +16,110 @@ var _propTypes2 = _interopRequireDefault(_propTypes);
1416

1517
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1618

17-
var Errors = function Errors(props) {
18-
var hasErrors = function hasErrors(error) {
19-
if (Array.isArray(error)) {
20-
return error.filter(function (item) {
21-
return !!item;
22-
}).length !== 0;
23-
}
19+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2420

25-
return !!error;
26-
};
21+
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
2722

28-
var formatError = function formatError(error) {
29-
if (typeof error === 'string') {
30-
return error;
31-
}
23+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
3224

33-
if (Array.isArray(error)) {
34-
return error.map(formatError);
35-
}
25+
var Errors = function (_Component) {
26+
_inherits(Errors, _Component);
3627

37-
if (error.hasOwnProperty('errors')) {
38-
return Object.keys(error.errors).map(function (key, index) {
39-
var item = error.errors[key];
40-
return _react2.default.createElement(
41-
'div',
42-
{ key: index },
43-
_react2.default.createElement(
44-
'strong',
45-
null,
46-
item.name,
47-
' (',
48-
item.path,
49-
')'
50-
),
51-
' - ',
52-
item.message
53-
);
54-
});
55-
}
28+
function Errors() {
29+
_classCallCheck(this, Errors);
5630

57-
// If this is a standard error.
58-
if (error.hasOwnProperty('message')) {
59-
return error.message;
60-
}
31+
return _possibleConstructorReturn(this, (Errors.__proto__ || Object.getPrototypeOf(Errors)).apply(this, arguments));
32+
}
6133

62-
// If this is a joy validation error.
63-
if (error.hasOwnProperty('name') && error.name === 'ValidationError') {
64-
return error.details.map(function (item, index) {
65-
return _react2.default.createElement(
66-
'div',
67-
{ key: index },
68-
item.message
69-
);
70-
});
71-
}
34+
_createClass(Errors, [{
35+
key: 'hasErrors',
36+
value: function hasErrors(error) {
37+
if (Array.isArray(error)) {
38+
return error.filter(function (item) {
39+
return !!item;
40+
}).length !== 0;
41+
}
7242

73-
// If a conflict error occurs on a form, the form is returned.
74-
if (error.hasOwnProperty('_id') && error.hasOwnProperty('display')) {
75-
return 'Another user has saved this form already. Please reload and re-apply your changes.';
43+
return !!error;
7644
}
45+
}, {
46+
key: 'formatError',
47+
value: function formatError(error) {
48+
if (typeof error === 'string') {
49+
return error;
50+
}
51+
52+
if (Array.isArray(error)) {
53+
return error.map(this.formatError);
54+
}
55+
56+
if (error.hasOwnProperty('errors')) {
57+
return Object.keys(error.errors).map(function (key, index) {
58+
var item = error.errors[key];
59+
return _react2.default.createElement(
60+
'div',
61+
{ key: index },
62+
_react2.default.createElement(
63+
'strong',
64+
null,
65+
item.name,
66+
' (',
67+
item.path,
68+
')'
69+
),
70+
' - ',
71+
item.message
72+
);
73+
});
74+
}
75+
76+
// If this is a standard error.
77+
if (error.hasOwnProperty('message')) {
78+
return error.message;
79+
}
80+
81+
// If this is a joy validation error.
82+
if (error.hasOwnProperty('name') && error.name === 'ValidationError') {
83+
return error.details.map(function (item, index) {
84+
return _react2.default.createElement(
85+
'div',
86+
{ key: index },
87+
item.message
88+
);
89+
});
90+
}
91+
92+
// If a conflict error occurs on a form, the form is returned.
93+
if (error.hasOwnProperty('_id') && error.hasOwnProperty('display')) {
94+
return 'Another user has saved this form already. Please reload and re-apply your changes.';
95+
}
96+
97+
return 'An error occurred. See console logs for details.';
98+
}
99+
}, {
100+
key: 'render',
101+
value: function render() {
102+
// If there are no errors, don't render anything.
103+
if (!this.hasErrors(this.props.errors)) {
104+
return null;
105+
}
106+
107+
return _react2.default.createElement(
108+
'div',
109+
{ className: 'alert alert-' + this.props.type, role: 'alert' },
110+
this.formatError(this.props.errors)
111+
);
112+
}
113+
}]);
77114

78-
return 'An error occurred. See console logs for details.';
79-
};
80-
81-
// If there are no errors, don't render anything.
82-
var errors = props.errors,
83-
type = props.type;
84-
85-
86-
if (!hasErrors(errors)) {
87-
return null;
88-
}
89-
90-
return _react2.default.createElement(
91-
'div',
92-
{ className: 'alert alert-' + type, role: 'alert' },
93-
formatError(errors)
94-
);
95-
};
115+
return Errors;
116+
}(_react.Component);
96117

97118
Errors.propTypes = {
98119
errors: _propTypes2.default.any,
99120
type: _propTypes2.default.string
100121
};
101-
102122
Errors.defaultProps = {
103123
type: 'danger'
104124
};
105-
106125
exports.default = Errors;

0 commit comments

Comments
 (0)