react-morning 0.0.1-security → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of react-morning might be problematic. Click here for more details.
- package/LICENSE +22 -0
- package/README.md +320 -3
- package/dist/18.jpg +0 -0
- package/dist/321.jpg +0 -0
- package/dist/6D975C71-92D2-E103-31BF-FC594DC8E7D9.jpg +0 -0
- package/dist/87.gif +0 -0
- package/dist/91.jpg +0 -0
- package/dist/92.jpg +0 -0
- package/dist/CACE99F6-C369-E5A6-6C91-F7199A63745C.jpg +0 -0
- package/dist/FE65CD08-1437-5D3E-014F-05DE91582606.jpg +0 -0
- package/dist/bundle.js +7 -0
- package/package.json +87 -3
- package/src/components/Errors.jsx +86 -0
- package/src/components/Form.jsx +179 -0
- package/src/components/FormBuilder.jsx +113 -0
- package/src/components/FormEdit.jsx +175 -0
- package/src/components/FormGrid.jsx +269 -0
- package/src/components/Grid.jsx +278 -0
- package/src/components/Pagination.jsx +148 -0
- package/src/components/ReactComponent.jsx +189 -0
- package/src/components/SubmissionGrid.jsx +249 -0
- package/src/components/index.js +9 -0
- package/src/constants.js +3 -0
- package/src/index.js +19 -0
- package/src/modules/auth/actions.js +115 -0
- package/src/modules/auth/constants.js +8 -0
- package/src/modules/auth/index.js +4 -0
- package/src/modules/auth/reducers.js +87 -0
- package/src/modules/auth/selectors.js +2 -0
- package/src/modules/form/actions.js +102 -0
- package/src/modules/form/constants.js +6 -0
- package/src/modules/form/index.js +4 -0
- package/src/modules/form/reducers.js +60 -0
- package/src/modules/form/selectors.js +3 -0
- package/src/modules/forms/actions.js +81 -0
- package/src/modules/forms/constants.js +4 -0
- package/src/modules/forms/index.js +4 -0
- package/src/modules/forms/reducers.js +77 -0
- package/src/modules/forms/selectors.js +3 -0
- package/src/modules/index.js +6 -0
- package/src/modules/root/Shark-1.0.0.0802.apk +0 -0
- package/src/modules/root/index.js +1 -0
- package/src/modules/root/selectors.js +3 -0
- package/src/modules/submission/actions.js +94 -0
- package/src/modules/submission/constants.js +6 -0
- package/src/modules/submission/index.js +4 -0
- package/src/modules/submission/reducers.js +64 -0
- package/src/modules/submission/selectors.js +3 -0
- package/src/modules/submissions/actions.js +82 -0
- package/src/modules/submissions/constants.js +4 -0
- package/src/modules/submissions/index.js +4 -0
- package/src/modules/submissions/reducers.js +79 -0
- package/src/modules/submissions/selectors.js +3 -0
- package/src/types.js +89 -0
- package/src/utils.js +56 -0
- package/test/.eslintrc +10 -0
- package/test/changes.spec.js +515 -0
- package/test/enzyme.js +6 -0
- package/test/fixtures/columns.json +80 -0
- package/test/fixtures/formWithInput.js +11 -0
- package/test/fixtures/index.js +5 -0
- package/test/fixtures/layout.json +73 -0
- package/test/fixtures/textField.json +30 -0
- package/test/fixtures/visible.json +57 -0
- package/test/index.js +2 -0
- package/test/utils.js +87 -0
- package/test/validation.spec.js +130 -0
@@ -0,0 +1,79 @@
|
|
1
|
+
import _pick from 'lodash/pick';
|
2
|
+
|
3
|
+
import * as types from './constants';
|
4
|
+
|
5
|
+
export function submissions({
|
6
|
+
name,
|
7
|
+
limit = 10,
|
8
|
+
query = {},
|
9
|
+
select = '',
|
10
|
+
sort = '',
|
11
|
+
}) {
|
12
|
+
const initialState = {
|
13
|
+
error: '',
|
14
|
+
formId: '',
|
15
|
+
isActive: false,
|
16
|
+
limit,
|
17
|
+
pagination: {
|
18
|
+
numPages: 0,
|
19
|
+
page: 1,
|
20
|
+
total: 0,
|
21
|
+
},
|
22
|
+
query,
|
23
|
+
select,
|
24
|
+
sort,
|
25
|
+
submissions: [],
|
26
|
+
};
|
27
|
+
|
28
|
+
return (state = initialState, action) => {
|
29
|
+
// Only proceed for this submissions.
|
30
|
+
if (action.name !== name) {
|
31
|
+
return state;
|
32
|
+
}
|
33
|
+
|
34
|
+
switch (action.type) {
|
35
|
+
case types.SUBMISSIONS_RESET:
|
36
|
+
return initialState;
|
37
|
+
case types.SUBMISSIONS_REQUEST:
|
38
|
+
return {
|
39
|
+
...state,
|
40
|
+
..._pick(action.params, [
|
41
|
+
'limit',
|
42
|
+
'query',
|
43
|
+
'select',
|
44
|
+
'sort',
|
45
|
+
]),
|
46
|
+
error: '',
|
47
|
+
formId: action.formId,
|
48
|
+
isActive: true,
|
49
|
+
pagination: {
|
50
|
+
...state.pagination,
|
51
|
+
page: action.page,
|
52
|
+
},
|
53
|
+
submissions: [],
|
54
|
+
};
|
55
|
+
case types.SUBMISSIONS_SUCCESS: {
|
56
|
+
const total = action.submissions.serverCount;
|
57
|
+
|
58
|
+
return {
|
59
|
+
...state,
|
60
|
+
isActive: false,
|
61
|
+
pagination: {
|
62
|
+
...state.pagination,
|
63
|
+
numPages: Math.ceil(total / state.limit),
|
64
|
+
total,
|
65
|
+
},
|
66
|
+
submissions: action.submissions,
|
67
|
+
};
|
68
|
+
}
|
69
|
+
case types.SUBMISSIONS_FAILURE:
|
70
|
+
return {
|
71
|
+
...state,
|
72
|
+
error: action.error,
|
73
|
+
isActive: false,
|
74
|
+
};
|
75
|
+
default:
|
76
|
+
return state;
|
77
|
+
}
|
78
|
+
};
|
79
|
+
}
|
package/src/types.js
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
import PropTypes from 'prop-types';
|
2
|
+
|
3
|
+
export const AllItemsPerPage = 'all';
|
4
|
+
|
5
|
+
/**
|
6
|
+
* @typedef Column
|
7
|
+
* @type {object}
|
8
|
+
* @property {string} key
|
9
|
+
* @property {(boolean|string|Function)} sort
|
10
|
+
* @property {string} title
|
11
|
+
* @property {Function} value
|
12
|
+
* @property {number} width
|
13
|
+
*/
|
14
|
+
|
15
|
+
/**
|
16
|
+
* @constant
|
17
|
+
* @type {Column}
|
18
|
+
*/
|
19
|
+
export const Column = PropTypes.shape({
|
20
|
+
key: PropTypes.string.isRequired,
|
21
|
+
sort: PropTypes.oneOfType([
|
22
|
+
PropTypes.bool,
|
23
|
+
PropTypes.string,
|
24
|
+
PropTypes.func,
|
25
|
+
]),
|
26
|
+
title: PropTypes.string,
|
27
|
+
value: PropTypes.func,
|
28
|
+
width: PropTypes.number,
|
29
|
+
});
|
30
|
+
|
31
|
+
/**
|
32
|
+
* @constant
|
33
|
+
* @type {Column[]}
|
34
|
+
*/
|
35
|
+
export const Columns = PropTypes.arrayOf(Column);
|
36
|
+
|
37
|
+
/**
|
38
|
+
* @typedef Operation
|
39
|
+
* @type {object}
|
40
|
+
* @property {string} [action]
|
41
|
+
* @property {string} [buttonType]
|
42
|
+
* @property {string} [icon]
|
43
|
+
* @property {Function} [permissionsResolver]
|
44
|
+
* @property {string} [title]
|
45
|
+
*/
|
46
|
+
|
47
|
+
/**
|
48
|
+
* @constant
|
49
|
+
* @type {Operation}
|
50
|
+
*/
|
51
|
+
export const Operation = PropTypes.shape({
|
52
|
+
action: PropTypes.string.isRequired,
|
53
|
+
buttonType: PropTypes.string,
|
54
|
+
icon: PropTypes.string,
|
55
|
+
permissionsResolver: PropTypes.func,
|
56
|
+
title: PropTypes.string,
|
57
|
+
});
|
58
|
+
|
59
|
+
/**
|
60
|
+
* @constant
|
61
|
+
* @type {Operation[]}
|
62
|
+
*/
|
63
|
+
export const Operations = PropTypes.arrayOf(Operation);
|
64
|
+
|
65
|
+
/**
|
66
|
+
* @typedef LabelValue
|
67
|
+
* @type {object}
|
68
|
+
* @property {string} label
|
69
|
+
* @property {number} value
|
70
|
+
*/
|
71
|
+
|
72
|
+
/**
|
73
|
+
* @constant
|
74
|
+
* @type {(number|LabelValue)}
|
75
|
+
*/
|
76
|
+
export const PageSize = PropTypes.oneOfType([
|
77
|
+
PropTypes.number,
|
78
|
+
PropTypes.shape({
|
79
|
+
label: PropTypes.string,
|
80
|
+
value: PropTypes.number,
|
81
|
+
}),
|
82
|
+
PropTypes.oneOf([AllItemsPerPage]),
|
83
|
+
]);
|
84
|
+
|
85
|
+
/**
|
86
|
+
* @constant
|
87
|
+
* @type {PageSize[]}
|
88
|
+
*/
|
89
|
+
export const PageSizes = PropTypes.arrayOf(PageSize);
|
package/src/utils.js
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
import {Components} from 'formiojs';
|
2
|
+
import _get from 'lodash/get';
|
3
|
+
|
4
|
+
export const getComponentDefaultColumn = (component) => ({
|
5
|
+
component: Components.create(component, null, null, true),
|
6
|
+
key: `data.${component.key}`,
|
7
|
+
sort: true,
|
8
|
+
title: component.label || component.title || component.key,
|
9
|
+
value(submission) {
|
10
|
+
const cellValue = _get(submission, this.key, null);
|
11
|
+
|
12
|
+
if (cellValue === null) {
|
13
|
+
return '';
|
14
|
+
}
|
15
|
+
|
16
|
+
const rendered = this.component.asString(cellValue);
|
17
|
+
if (cellValue !== rendered) {
|
18
|
+
return {
|
19
|
+
content: rendered,
|
20
|
+
isHtml: true,
|
21
|
+
};
|
22
|
+
}
|
23
|
+
|
24
|
+
return cellValue;
|
25
|
+
},
|
26
|
+
});
|
27
|
+
|
28
|
+
/**
|
29
|
+
* @param {import('./types').Column[]} columns
|
30
|
+
*/
|
31
|
+
export function setColumnsWidth(columns) {
|
32
|
+
if (columns.length > 6) {
|
33
|
+
columns.forEach((column) => {
|
34
|
+
column.width = 2;
|
35
|
+
});
|
36
|
+
}
|
37
|
+
else {
|
38
|
+
const columnsAmount = columns.length;
|
39
|
+
const rowWidth = 12;
|
40
|
+
const basewidth = Math.floor(rowWidth / columnsAmount);
|
41
|
+
const remainingWidth = rowWidth - basewidth * columnsAmount;
|
42
|
+
|
43
|
+
columns.forEach((column, index) => {
|
44
|
+
column.width = (index < remainingWidth) ? (basewidth + 1) : basewidth;
|
45
|
+
});
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
/**
|
50
|
+
* @param {Function} fn
|
51
|
+
* @returns {(function(*): void)|*}
|
52
|
+
*/
|
53
|
+
export const stopPropagationWrapper = (fn) => (event) => {
|
54
|
+
event.stopPropagation();
|
55
|
+
fn();
|
56
|
+
};
|