@sis-cc/dotstatsuite-visions 7.15.1 → 7.16.0
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.
- package/es/ChartsConfig/ChartsConfig.js +0 -1
- package/es/UserRightForm/Input.js +129 -0
- package/es/UserRightForm/Permissions.js +122 -0
- package/es/UserRightForm/PermsissionsTabs.js +98 -0
- package/es/UserRightForm/UserRightForm.js +432 -0
- package/es/UserRightForm/index.js +62 -0
- package/es/index.js +1 -0
- package/lib/ChartsConfig/ChartsConfig.js +0 -1
- package/lib/UserRightForm/Input.js +163 -0
- package/lib/UserRightForm/Permissions.js +149 -0
- package/lib/UserRightForm/PermsissionsTabs.js +119 -0
- package/lib/UserRightForm/UserRightForm.js +463 -0
- package/lib/UserRightForm/index.js +16 -0
- package/lib/index.js +10 -1
- package/package.json +1 -1
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import * as R from 'ramda';
|
|
6
|
+
import cx from 'classnames';
|
|
7
|
+
import { makeStyles } from '@material-ui/core/styles';
|
|
8
|
+
import TextField from '@material-ui/core/TextField';
|
|
9
|
+
import InputAdornment from '@material-ui/core/InputAdornment';
|
|
10
|
+
import IconButton from '@material-ui/core/IconButton';
|
|
11
|
+
import Done from '@material-ui/icons/Done';
|
|
12
|
+
import { withInput } from '../Input/with-input';
|
|
13
|
+
|
|
14
|
+
var useStyles = makeStyles(function () {
|
|
15
|
+
return {
|
|
16
|
+
visibility: {
|
|
17
|
+
visibility: 'hidden'
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
var LefttIcon = function LefttIcon(_ref) {
|
|
23
|
+
var Icon = _ref.Icon;
|
|
24
|
+
return React.createElement(Icon, null);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
LefttIcon.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
28
|
+
Icon: PropTypes.object
|
|
29
|
+
} : {};
|
|
30
|
+
|
|
31
|
+
var RightIcon = function RightIcon(_ref2) {
|
|
32
|
+
var onSubmit = _ref2.onSubmit,
|
|
33
|
+
_ref2$Icon = _ref2.Icon,
|
|
34
|
+
Icon = _ref2$Icon === undefined ? Done : _ref2$Icon;
|
|
35
|
+
return React.createElement(
|
|
36
|
+
IconButton,
|
|
37
|
+
{ color: 'primary', onClick: function onClick() {
|
|
38
|
+
return onSubmit();
|
|
39
|
+
} },
|
|
40
|
+
React.createElement(Icon, null)
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
RightIcon.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
45
|
+
Icon: PropTypes.object,
|
|
46
|
+
onSubmit: PropTypes.func,
|
|
47
|
+
classes: PropTypes.object
|
|
48
|
+
} : {};
|
|
49
|
+
|
|
50
|
+
export var MyInput = function MyInput(_ref3) {
|
|
51
|
+
var _cx;
|
|
52
|
+
|
|
53
|
+
var id = _ref3.id,
|
|
54
|
+
label = _ref3.label,
|
|
55
|
+
name = _ref3.name,
|
|
56
|
+
placeholder = _ref3.placeholder,
|
|
57
|
+
leftIcon = _ref3.leftIcon,
|
|
58
|
+
rightIcon = _ref3.rightIcon,
|
|
59
|
+
value = _ref3.value,
|
|
60
|
+
type = _ref3.type,
|
|
61
|
+
onChange = _ref3.onChange,
|
|
62
|
+
onSubmit = _ref3.onSubmit,
|
|
63
|
+
fullWidth = _ref3.fullWidth,
|
|
64
|
+
withValidationIcon = _ref3.withValidationIcon,
|
|
65
|
+
textFieldProps = _ref3.textFieldProps,
|
|
66
|
+
inputProps = _ref3.inputProps,
|
|
67
|
+
endAdornment = _ref3.endAdornment;
|
|
68
|
+
|
|
69
|
+
var classes = useStyles();
|
|
70
|
+
var startAdornment = R.isNil(leftIcon) ? null : React.createElement(
|
|
71
|
+
InputAdornment,
|
|
72
|
+
{ position: 'start' },
|
|
73
|
+
React.createElement(LefttIcon, { Icon: leftIcon })
|
|
74
|
+
);
|
|
75
|
+
var endMyadornment = R.or(withValidationIcon, !R.isNil(rightIcon)) ? React.createElement(
|
|
76
|
+
InputAdornment,
|
|
77
|
+
{ position: 'end', className: cx((_cx = {}, _cx[classes.visibility] = R.isEmpty(value), _cx)) },
|
|
78
|
+
React.createElement(RightIcon, { onSubmit: onSubmit, Icon: rightIcon })
|
|
79
|
+
) : null;
|
|
80
|
+
|
|
81
|
+
var onEnterLabel = function onEnterLabel(event) {
|
|
82
|
+
if (event.key === 'Enter') {
|
|
83
|
+
event.preventDefault();
|
|
84
|
+
if (R.is(Function, onSubmit)) {
|
|
85
|
+
onSubmit();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
return React.createElement(TextField, _extends({
|
|
91
|
+
'data-testid': 'input-test-id',
|
|
92
|
+
margin: 'dense',
|
|
93
|
+
fullWidth: fullWidth,
|
|
94
|
+
id: id,
|
|
95
|
+
name: name,
|
|
96
|
+
type: type,
|
|
97
|
+
label: label,
|
|
98
|
+
value: value,
|
|
99
|
+
variant: 'outlined',
|
|
100
|
+
placeholder: placeholder,
|
|
101
|
+
onChange: onChange,
|
|
102
|
+
onKeyPress: onEnterLabel,
|
|
103
|
+
InputProps: {
|
|
104
|
+
startAdornment: startAdornment,
|
|
105
|
+
endAdornment: R.isNil(endAdornment) ? endMyadornment : endAdornment
|
|
106
|
+
},
|
|
107
|
+
inputProps: inputProps
|
|
108
|
+
}, textFieldProps));
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
MyInput.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
112
|
+
id: PropTypes.string,
|
|
113
|
+
name: PropTypes.string,
|
|
114
|
+
label: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
|
115
|
+
placeholder: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
|
116
|
+
leftIcon: PropTypes.object,
|
|
117
|
+
rightIcon: PropTypes.object,
|
|
118
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
119
|
+
type: PropTypes.string,
|
|
120
|
+
onChange: PropTypes.func,
|
|
121
|
+
onSubmit: PropTypes.func,
|
|
122
|
+
fullWidth: PropTypes.bool,
|
|
123
|
+
withValidationIcon: PropTypes.bool,
|
|
124
|
+
textFieldProps: PropTypes.object,
|
|
125
|
+
inputProps: PropTypes.object,
|
|
126
|
+
endAdornment: PropTypes.node
|
|
127
|
+
} : {};
|
|
128
|
+
|
|
129
|
+
export default withInput(MyInput);
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Checkbox from '@material-ui/core/Checkbox';
|
|
3
|
+
import FormControlLabel from '@material-ui/core/FormControlLabel';
|
|
4
|
+
import { Grid, Typography, makeStyles } from '@material-ui/core';
|
|
5
|
+
import * as R from 'ramda';
|
|
6
|
+
import cx from 'classnames';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
|
|
9
|
+
var useStyles = makeStyles(function (theme) {
|
|
10
|
+
var _hideContent;
|
|
11
|
+
|
|
12
|
+
return {
|
|
13
|
+
hideContent: (_hideContent = {}, _hideContent[theme.breakpoints.down('sm')] = {
|
|
14
|
+
display: 'none'
|
|
15
|
+
}, _hideContent),
|
|
16
|
+
contentLabel: {
|
|
17
|
+
color: theme.palette.text.primary,
|
|
18
|
+
fontWeight: 'bold',
|
|
19
|
+
fontSize: '14px'
|
|
20
|
+
},
|
|
21
|
+
label: {
|
|
22
|
+
color: theme.palette.text.primary,
|
|
23
|
+
fontSize: '14px'
|
|
24
|
+
},
|
|
25
|
+
disabled: {
|
|
26
|
+
cursor: 'not-allowed',
|
|
27
|
+
color: theme.palette.text.disabled,
|
|
28
|
+
'&:hover': {
|
|
29
|
+
color: theme.palette.text.disabled
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
var Permissions = function Permissions(_ref) {
|
|
36
|
+
var data = _ref.data,
|
|
37
|
+
labels = _ref.labels,
|
|
38
|
+
onCheck = _ref.onCheck;
|
|
39
|
+
|
|
40
|
+
var classes = useStyles();
|
|
41
|
+
|
|
42
|
+
return React.createElement(
|
|
43
|
+
Grid,
|
|
44
|
+
{ container: true },
|
|
45
|
+
React.createElement(
|
|
46
|
+
Grid,
|
|
47
|
+
{ item: true, container: true, xs: 12 },
|
|
48
|
+
React.createElement(
|
|
49
|
+
Grid,
|
|
50
|
+
{ item: true, xs: 12, md: 4 },
|
|
51
|
+
React.createElement(
|
|
52
|
+
Typography,
|
|
53
|
+
{ variant: 'h6', className: classes.contentLabel, style: { paddingTop: 8 } },
|
|
54
|
+
R.prop('permission')(labels)
|
|
55
|
+
)
|
|
56
|
+
),
|
|
57
|
+
React.createElement(
|
|
58
|
+
Grid,
|
|
59
|
+
{ item: true, xs: 12, md: 8 },
|
|
60
|
+
React.createElement(
|
|
61
|
+
Typography,
|
|
62
|
+
{
|
|
63
|
+
variant: 'h6',
|
|
64
|
+
className: cx(classes.contentLabel, classes.hideContent),
|
|
65
|
+
style: { paddingTop: 8 }
|
|
66
|
+
},
|
|
67
|
+
R.prop('definition')(labels)
|
|
68
|
+
)
|
|
69
|
+
)
|
|
70
|
+
),
|
|
71
|
+
React.createElement(
|
|
72
|
+
Grid,
|
|
73
|
+
{ item: true, container: true, xs: 12 },
|
|
74
|
+
R.map(function (item) {
|
|
75
|
+
return React.createElement(
|
|
76
|
+
Grid,
|
|
77
|
+
{ item: true, container: true, xs: 12, key: item.id },
|
|
78
|
+
React.createElement(
|
|
79
|
+
Grid,
|
|
80
|
+
{ item: true, xs: 12, md: 4 },
|
|
81
|
+
React.createElement(FormControlLabel, {
|
|
82
|
+
control: React.createElement(Checkbox, { name: 'checkedB', color: 'primary' }),
|
|
83
|
+
label: React.createElement(
|
|
84
|
+
Typography,
|
|
85
|
+
{
|
|
86
|
+
variant: 'h6',
|
|
87
|
+
className: R.propOr(false, 'disabled')(item) ? classes.disabled : classes.label
|
|
88
|
+
},
|
|
89
|
+
R.prop('label')(item)
|
|
90
|
+
),
|
|
91
|
+
checked: !!item.isSelected,
|
|
92
|
+
disabled: R.propOr(false, 'disabled')(item),
|
|
93
|
+
onChange: function onChange() {
|
|
94
|
+
return onCheck(item.id);
|
|
95
|
+
}
|
|
96
|
+
})
|
|
97
|
+
),
|
|
98
|
+
React.createElement(
|
|
99
|
+
Grid,
|
|
100
|
+
{ item: true, xs: 12, md: 8 },
|
|
101
|
+
React.createElement(
|
|
102
|
+
Typography,
|
|
103
|
+
{
|
|
104
|
+
variant: 'h6',
|
|
105
|
+
className: cx(R.propOr(false, 'disabled')(item) ? classes.disabled : classes.label, classes.hideContent),
|
|
106
|
+
style: { paddingTop: 8 }
|
|
107
|
+
},
|
|
108
|
+
R.prop('definition')(item)
|
|
109
|
+
)
|
|
110
|
+
)
|
|
111
|
+
);
|
|
112
|
+
})(data)
|
|
113
|
+
)
|
|
114
|
+
);
|
|
115
|
+
};
|
|
116
|
+
Permissions.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
117
|
+
data: PropTypes.array,
|
|
118
|
+
labels: PropTypes.object,
|
|
119
|
+
setSelectedOptions: PropTypes.func,
|
|
120
|
+
onCheck: PropTypes.func
|
|
121
|
+
} : {};
|
|
122
|
+
export default Permissions;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { Box, Grid, Tabs, Tab, makeStyles, Typography } from '@material-ui/core';
|
|
4
|
+
import * as R from 'ramda';
|
|
5
|
+
import Permissions from './Permissions';
|
|
6
|
+
|
|
7
|
+
var useStyles = makeStyles(function (theme) {
|
|
8
|
+
return {
|
|
9
|
+
tabs: {
|
|
10
|
+
border: '1px solid black',
|
|
11
|
+
padding: theme.spacing(1, 2)
|
|
12
|
+
},
|
|
13
|
+
tab: {
|
|
14
|
+
backgroundColor: theme.palette.blue,
|
|
15
|
+
fontSize: '12px'
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
var PermissionsTabs = function PermissionsTabs(_ref) {
|
|
21
|
+
var data = _ref.data,
|
|
22
|
+
labels = _ref.labels,
|
|
23
|
+
onCheckPermission = _ref.onCheckPermission,
|
|
24
|
+
onCheckPermissionGroup = _ref.onCheckPermissionGroup;
|
|
25
|
+
|
|
26
|
+
var classes = useStyles();
|
|
27
|
+
|
|
28
|
+
var _useState = useState(0),
|
|
29
|
+
valueTabs = _useState[0],
|
|
30
|
+
setValueTabs = _useState[1];
|
|
31
|
+
|
|
32
|
+
var handleValueTabsChange = function handleValueTabsChange(_, newValue) {
|
|
33
|
+
return setValueTabs(newValue);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
var permissionsData = R.path(['options', 'data'], data);
|
|
37
|
+
var permissionGroupsData = R.path(['permissions', 'data'], data);
|
|
38
|
+
|
|
39
|
+
var selectedGroups = R.filter(R.prop('isSelected'), permissionGroupsData);
|
|
40
|
+
var selectedPermissionsInGroups = R.pipe(R.pluck('options'), R.unnest, R.uniq)(selectedGroups);
|
|
41
|
+
var selectedPermissions = R.pipe(R.filter(R.prop('isSelected')), R.pluck('id'))(permissionsData);
|
|
42
|
+
var nonGroupedSelectedPermissions = R.difference(selectedPermissions, selectedPermissionsInGroups);
|
|
43
|
+
|
|
44
|
+
var evolvedPermissionGroupsData = R.append({
|
|
45
|
+
id: 'customPermissions',
|
|
46
|
+
label: R.prop('customPermissions', labels),
|
|
47
|
+
definition: R.prop('customPermissionsDefinition', labels),
|
|
48
|
+
isSelected: !R.isEmpty(nonGroupedSelectedPermissions),
|
|
49
|
+
disabled: true
|
|
50
|
+
}, permissionGroupsData);
|
|
51
|
+
|
|
52
|
+
return React.createElement(
|
|
53
|
+
Grid,
|
|
54
|
+
null,
|
|
55
|
+
React.createElement(
|
|
56
|
+
Typography,
|
|
57
|
+
{
|
|
58
|
+
variant: 'h6',
|
|
59
|
+
className: classes.label,
|
|
60
|
+
style: { marginTop: 10, marginBottom: 10 }
|
|
61
|
+
},
|
|
62
|
+
R.prop('title')(labels)
|
|
63
|
+
),
|
|
64
|
+
React.createElement(
|
|
65
|
+
Grid,
|
|
66
|
+
{ className: classes.tabs },
|
|
67
|
+
React.createElement(
|
|
68
|
+
Tabs,
|
|
69
|
+
{
|
|
70
|
+
value: valueTabs,
|
|
71
|
+
indicatorColor: 'primary',
|
|
72
|
+
textColor: 'primary',
|
|
73
|
+
onChange: handleValueTabsChange,
|
|
74
|
+
'aria-label': R.prop('title')(labels),
|
|
75
|
+
className: classes.tab
|
|
76
|
+
},
|
|
77
|
+
React.createElement(Tab, { label: R.path(['permissions', 'label'], data) }),
|
|
78
|
+
React.createElement(Tab, { label: R.path(['options', 'label'], data) })
|
|
79
|
+
),
|
|
80
|
+
React.createElement(
|
|
81
|
+
Box,
|
|
82
|
+
null,
|
|
83
|
+
React.createElement(Permissions, {
|
|
84
|
+
data: valueTabs === 0 ? evolvedPermissionGroupsData : permissionsData,
|
|
85
|
+
labels: labels,
|
|
86
|
+
onCheck: valueTabs === 0 ? onCheckPermissionGroup : onCheckPermission
|
|
87
|
+
})
|
|
88
|
+
)
|
|
89
|
+
)
|
|
90
|
+
);
|
|
91
|
+
};
|
|
92
|
+
PermissionsTabs.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
93
|
+
data: PropTypes.object,
|
|
94
|
+
labels: PropTypes.object,
|
|
95
|
+
onCheckPermission: PropTypes.func,
|
|
96
|
+
onCheckPermissionGroup: PropTypes.func
|
|
97
|
+
} : {};
|
|
98
|
+
export default PermissionsTabs;
|