@onehat/ui 0.3.333 → 0.3.334
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/package.json +1 -1
- package/src/Components/Grid/Grid.js +67 -56
- package/src/Components/Hoc/Secondary/withSecondaryEditor.js +1 -1
- package/src/Components/Hoc/withData.js +1 -4
- package/src/Components/Hoc/withEditor.js +1 -1
- package/src/Components/Hoc/withPermissions.js +87 -0
- package/src/Components/Hoc/withPresetButtons.js +56 -27
- package/src/Components/Tree/Tree.js +39 -32
- package/src/Constants/Commands.js +8 -0
- package/src/Components/WaitModal.js +0 -31
package/package.json
CHANGED
|
@@ -32,18 +32,19 @@ import withComponent from '../Hoc/withComponent.js';
|
|
|
32
32
|
import withData from '../Hoc/withData.js';
|
|
33
33
|
import { withDropTarget } from '../Hoc/withDnd.js';
|
|
34
34
|
import withEvents from '../Hoc/withEvents.js';
|
|
35
|
-
import withSideEditor from '../Hoc/withSideEditor.js';
|
|
36
35
|
import withFilters from '../Hoc/withFilters.js';
|
|
36
|
+
import withInlineEditor from '../Hoc/withInlineEditor.js';
|
|
37
|
+
import withPermissions from '../Hoc/withPermissions.js';
|
|
37
38
|
import withPresetButtons from '../Hoc/withPresetButtons.js';
|
|
38
39
|
import withMultiSelection from '../Hoc/withMultiSelection.js';
|
|
39
40
|
import withSelection from '../Hoc/withSelection.js';
|
|
41
|
+
import withSideEditor from '../Hoc/withSideEditor.js';
|
|
40
42
|
import withWindowedEditor from '../Hoc/withWindowedEditor.js';
|
|
41
|
-
import withInlineEditor from '../Hoc/withInlineEditor.js';
|
|
42
43
|
import getSaved from '../../Functions/getSaved.js';
|
|
43
44
|
import setSaved from '../../Functions/setSaved.js';
|
|
44
45
|
import getIconButtonFromConfig from '../../Functions/getIconButtonFromConfig.js';
|
|
45
|
-
import nbToRgb from '../../Functions/nbToRgb.js';
|
|
46
46
|
import testProps from '../../Functions/testProps.js';
|
|
47
|
+
import nbToRgb from '../../Functions/nbToRgb.js';
|
|
47
48
|
import Loading from '../Messages/Loading.js';
|
|
48
49
|
import isSerializable from '../../Functions/isSerializable.js';
|
|
49
50
|
import inArray from '../../Functions/inArray.js';
|
|
@@ -1146,16 +1147,18 @@ export const Grid = withComponent(
|
|
|
1146
1147
|
withAlert(
|
|
1147
1148
|
withEvents(
|
|
1148
1149
|
withData(
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1150
|
+
withPermissions(
|
|
1151
|
+
withDropTarget(
|
|
1152
|
+
withMultiSelection(
|
|
1153
|
+
withSelection(
|
|
1154
|
+
withFilters(
|
|
1155
|
+
withPresetButtons(
|
|
1156
|
+
withContextMenu(
|
|
1157
|
+
GridComponent
|
|
1158
|
+
)
|
|
1159
|
+
),
|
|
1160
|
+
true // isGrid
|
|
1161
|
+
)
|
|
1159
1162
|
)
|
|
1160
1163
|
)
|
|
1161
1164
|
)
|
|
@@ -1169,17 +1172,19 @@ export const SideGridEditor = withComponent(
|
|
|
1169
1172
|
withAlert(
|
|
1170
1173
|
withEvents(
|
|
1171
1174
|
withData(
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1175
|
+
withPermissions(
|
|
1176
|
+
withDropTarget(
|
|
1177
|
+
withMultiSelection(
|
|
1178
|
+
withSelection(
|
|
1179
|
+
withSideEditor(
|
|
1180
|
+
withFilters(
|
|
1181
|
+
withPresetButtons(
|
|
1182
|
+
withContextMenu(
|
|
1183
|
+
GridComponent
|
|
1184
|
+
)
|
|
1185
|
+
),
|
|
1186
|
+
true // isGrid
|
|
1187
|
+
)
|
|
1183
1188
|
)
|
|
1184
1189
|
)
|
|
1185
1190
|
)
|
|
@@ -1194,16 +1199,18 @@ export const WindowedGridEditor = withComponent(
|
|
|
1194
1199
|
withAlert(
|
|
1195
1200
|
withEvents(
|
|
1196
1201
|
withData(
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1202
|
+
withPermissions(
|
|
1203
|
+
withDropTarget(
|
|
1204
|
+
withMultiSelection(
|
|
1205
|
+
withSelection(
|
|
1206
|
+
withWindowedEditor(
|
|
1207
|
+
withFilters(
|
|
1208
|
+
withPresetButtons(
|
|
1209
|
+
withContextMenu(
|
|
1210
|
+
GridComponent
|
|
1211
|
+
),
|
|
1212
|
+
true // isGrid
|
|
1213
|
+
)
|
|
1207
1214
|
)
|
|
1208
1215
|
)
|
|
1209
1216
|
)
|
|
@@ -1219,17 +1226,19 @@ export const InlineGridEditor = withComponent(
|
|
|
1219
1226
|
withAlert(
|
|
1220
1227
|
withEvents(
|
|
1221
1228
|
withData(
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1229
|
+
withPermissions(
|
|
1230
|
+
withDropTarget(
|
|
1231
|
+
withMultiSelection(
|
|
1232
|
+
withSelection(
|
|
1233
|
+
withInlineEditor(
|
|
1234
|
+
withFilters(
|
|
1235
|
+
withPresetButtons(
|
|
1236
|
+
withContextMenu(
|
|
1237
|
+
GridComponent
|
|
1238
|
+
)
|
|
1239
|
+
),
|
|
1240
|
+
true // isGrid
|
|
1241
|
+
)
|
|
1233
1242
|
)
|
|
1234
1243
|
)
|
|
1235
1244
|
)
|
|
@@ -1244,17 +1253,19 @@ export const InlineGridEditor = withComponent(
|
|
|
1244
1253
|
// withAlert(
|
|
1245
1254
|
// withEvents(
|
|
1246
1255
|
// withData(
|
|
1247
|
-
//
|
|
1248
|
-
//
|
|
1249
|
-
//
|
|
1250
|
-
//
|
|
1251
|
-
//
|
|
1252
|
-
//
|
|
1253
|
-
//
|
|
1254
|
-
//
|
|
1255
|
-
//
|
|
1256
|
-
//
|
|
1257
|
-
//
|
|
1256
|
+
// withPermissions(
|
|
1257
|
+
// withDropTarget(
|
|
1258
|
+
// withMultiSelection(
|
|
1259
|
+
// withSelection(
|
|
1260
|
+
// withInlineSideEditor(
|
|
1261
|
+
// withFilters(
|
|
1262
|
+
// withPresetButtons(
|
|
1263
|
+
// withContextMenu(
|
|
1264
|
+
// GridComponent
|
|
1265
|
+
// )
|
|
1266
|
+
// ),
|
|
1267
|
+
// true // isGrid
|
|
1268
|
+
// )
|
|
1258
1269
|
// )
|
|
1259
1270
|
// )
|
|
1260
1271
|
// )
|
|
@@ -22,7 +22,7 @@ export default function withSecondaryEditor(WrappedComponent, isTree = false) {
|
|
|
22
22
|
|
|
23
23
|
let [secondaryEditorMode, secondarySetEditorMode] = useState(EDITOR_MODE__VIEW); // Can change below, so use 'let'
|
|
24
24
|
const {
|
|
25
|
-
secondaryUserCanEdit = true,
|
|
25
|
+
secondaryUserCanEdit = true, // not permissions, but capability
|
|
26
26
|
secondaryUserCanView = true,
|
|
27
27
|
secondaryCanEditorViewOnly = false, // whether the editor can *ever* change state out of 'View' mode
|
|
28
28
|
secondaryDisableAdd = false,
|
|
@@ -38,7 +38,6 @@ export default function withData(WrappedComponent) {
|
|
|
38
38
|
// withComponent
|
|
39
39
|
self,
|
|
40
40
|
} = props,
|
|
41
|
-
propsToPass = _.omit(props, ['model']), // passing 'model' would mess things up if withData gets called twice (e.g. withData(...withData(...)) ), as we'd be trying to recreate Repository twice
|
|
42
41
|
localIdIx = idIx || (fields && idField ? fields.indexOf(idField) : null),
|
|
43
42
|
localDisplayIx = displayIx || (fields && displayField ? fields?.indexOf(displayField) : null),
|
|
44
43
|
[LocalRepository, setLocalRepository] = useState(Repository || null), // simply pass on Repository if it's already supplied
|
|
@@ -106,11 +105,9 @@ export default function withData(WrappedComponent) {
|
|
|
106
105
|
}
|
|
107
106
|
|
|
108
107
|
return <WrappedComponent
|
|
109
|
-
{...
|
|
108
|
+
{...props}
|
|
110
109
|
disableWithData={false}
|
|
111
110
|
Repository={LocalRepository}
|
|
112
|
-
model={model}
|
|
113
|
-
data={data}
|
|
114
111
|
fields={fields}
|
|
115
112
|
idField={idField}
|
|
116
113
|
displayField={displayField}
|
|
@@ -20,7 +20,7 @@ export default function withEditor(WrappedComponent, isTree = false) {
|
|
|
20
20
|
|
|
21
21
|
let [editorMode, setEditorMode] = useState(EDITOR_MODE__VIEW); // Can change below, so use 'let'
|
|
22
22
|
const {
|
|
23
|
-
userCanEdit = true,
|
|
23
|
+
userCanEdit = true, // not permissions, but capability
|
|
24
24
|
userCanView = true,
|
|
25
25
|
canEditorViewOnly = false, // whether the editor can *ever* change state out of 'View' mode
|
|
26
26
|
disableAdd = false,
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import Inflector from 'inflector-js';
|
|
2
|
+
import inArray from '../../Functions/inArray.js';
|
|
3
|
+
import {
|
|
4
|
+
ADD,
|
|
5
|
+
EDIT,
|
|
6
|
+
DELETE,
|
|
7
|
+
VIEW,
|
|
8
|
+
COPY,
|
|
9
|
+
DUPLICATE,
|
|
10
|
+
PRINT,
|
|
11
|
+
UPLOAD_DOWNLOAD,
|
|
12
|
+
} from '../../Constants/Commands.js';
|
|
13
|
+
import UiGlobals from '../../UiGlobals.js';
|
|
14
|
+
import _ from 'lodash';
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
export default function withPermissions(WrappedComponent) {
|
|
18
|
+
return (props) => {
|
|
19
|
+
|
|
20
|
+
if (!props.usePermissions) {
|
|
21
|
+
return <WrappedComponent {...props} />;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const {
|
|
25
|
+
// withData
|
|
26
|
+
Repository,
|
|
27
|
+
} = props,
|
|
28
|
+
model = Repository.schema.name,
|
|
29
|
+
checkPermission = (permission) => {
|
|
30
|
+
const
|
|
31
|
+
reduxState = UiGlobals.redux?.getState(),
|
|
32
|
+
permissions = reduxState?.app?.permissions;
|
|
33
|
+
if (!permissions) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
return inArray(permission, permissions);
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Check if user has permission to perform an action
|
|
41
|
+
*
|
|
42
|
+
* Example usages:
|
|
43
|
+
* canUser('view') // check if user can perform 'view' action on the default model
|
|
44
|
+
* canUser('add', 'PmEvents') // check if user can perform 'add' action on a specific model
|
|
45
|
+
* canUser('do_something_else) // check if user has a custom permission
|
|
46
|
+
*
|
|
47
|
+
* @param {string} permission - The permission to check for.
|
|
48
|
+
* @param {string} modelToCheck - The model to check for the permission on.
|
|
49
|
+
* @returns {boolean} - Whether user has permission
|
|
50
|
+
*/
|
|
51
|
+
canUser = (permission, modelToCheck = null) => {
|
|
52
|
+
|
|
53
|
+
// in certain cases, shift permissions to standard CRUD operations
|
|
54
|
+
switch(permission) {
|
|
55
|
+
case COPY:
|
|
56
|
+
case DUPLICATE:
|
|
57
|
+
permission = ADD;
|
|
58
|
+
break;
|
|
59
|
+
case PRINT:
|
|
60
|
+
permission = VIEW;
|
|
61
|
+
break;
|
|
62
|
+
case UPLOAD_DOWNLOAD:
|
|
63
|
+
permission = EDIT;
|
|
64
|
+
break;
|
|
65
|
+
default:
|
|
66
|
+
// do nothing
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// standard CRUD permissions
|
|
71
|
+
if (inArray(permission, [VIEW, ADD, EDIT, DELETE])) {
|
|
72
|
+
if (!modelToCheck) {
|
|
73
|
+
modelToCheck = model; // use default model if none supplied
|
|
74
|
+
}
|
|
75
|
+
modelToCheck = Inflector.underscore(modelToCheck); // 'PmEvents' -> 'pm_events'
|
|
76
|
+
permission += '_' + modelToCheck; // e.g. 'view_pm_events'
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return checkPermission(permission);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
return <WrappedComponent
|
|
83
|
+
{...props}
|
|
84
|
+
canUser={canUser}
|
|
85
|
+
/>;
|
|
86
|
+
};
|
|
87
|
+
}
|
|
@@ -2,6 +2,16 @@ import React, { useState, useEffect, } from 'react';
|
|
|
2
2
|
import {
|
|
3
3
|
Modal,
|
|
4
4
|
} from 'native-base';
|
|
5
|
+
import {
|
|
6
|
+
ADD,
|
|
7
|
+
EDIT,
|
|
8
|
+
DELETE,
|
|
9
|
+
VIEW,
|
|
10
|
+
COPY,
|
|
11
|
+
DUPLICATE,
|
|
12
|
+
PRINT,
|
|
13
|
+
UPLOAD_DOWNLOAD,
|
|
14
|
+
} from '../../constants/Commands.js';
|
|
5
15
|
import Clipboard from '../Icons/Clipboard.js';
|
|
6
16
|
import Duplicate from '../Icons/Duplicate.js';
|
|
7
17
|
import Edit from '../Icons/Edit.js';
|
|
@@ -18,14 +28,14 @@ import _ from 'lodash';
|
|
|
18
28
|
// and a toolbar button that match in text label, icon, and handler.
|
|
19
29
|
|
|
20
30
|
const presetButtons = [
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
//
|
|
28
|
-
|
|
31
|
+
ADD,
|
|
32
|
+
EDIT,
|
|
33
|
+
DELETE,
|
|
34
|
+
VIEW,
|
|
35
|
+
COPY,
|
|
36
|
+
DUPLICATE,
|
|
37
|
+
// PRINT,
|
|
38
|
+
UPLOAD_DOWNLOAD,
|
|
29
39
|
];
|
|
30
40
|
|
|
31
41
|
export default function withPresetButtons(WrappedComponent, isGrid = false) {
|
|
@@ -71,8 +81,11 @@ export default function withPresetButtons(WrappedComponent, isGrid = false) {
|
|
|
71
81
|
// withData
|
|
72
82
|
Repository,
|
|
73
83
|
|
|
84
|
+
// withPermissions
|
|
85
|
+
canUser,
|
|
86
|
+
|
|
74
87
|
// withEditor
|
|
75
|
-
userCanEdit = true,
|
|
88
|
+
userCanEdit = true, // not permissions, but capability
|
|
76
89
|
userCanView = true,
|
|
77
90
|
onAdd,
|
|
78
91
|
onEdit,
|
|
@@ -101,44 +114,60 @@ export default function withPresetButtons(WrappedComponent, isGrid = false) {
|
|
|
101
114
|
isTypeDisabledCompletely = (type) => {
|
|
102
115
|
let isDisabled = false;
|
|
103
116
|
switch(type) {
|
|
104
|
-
case
|
|
117
|
+
case ADD:
|
|
105
118
|
if (disableAdd || canEditorViewOnly) {
|
|
106
119
|
isDisabled = true;
|
|
120
|
+
} else if (canUser && !canUser(ADD)) { // check Permissions
|
|
121
|
+
isDisabled = true;
|
|
107
122
|
}
|
|
108
123
|
break;
|
|
109
|
-
case
|
|
124
|
+
case EDIT:
|
|
110
125
|
if (disableEdit || canEditorViewOnly || isSideEditor) {
|
|
111
126
|
isDisabled = true;
|
|
127
|
+
} else if (canUser && !canUser(EDIT)) { // check Permissions
|
|
128
|
+
isDisabled = true;
|
|
112
129
|
}
|
|
113
130
|
break;
|
|
114
|
-
case
|
|
131
|
+
case DELETE:
|
|
115
132
|
if (disableDelete || canEditorViewOnly) {
|
|
116
133
|
isDisabled = true;
|
|
134
|
+
} else if (canUser && !canUser(DELETE)) { // check Permissions
|
|
135
|
+
isDisabled = true;
|
|
117
136
|
}
|
|
118
137
|
break;
|
|
119
|
-
case
|
|
138
|
+
case VIEW:
|
|
120
139
|
if (disableView || isSideEditor) {
|
|
121
140
|
isDisabled = true;
|
|
141
|
+
} else if (canUser && !canUser(VIEW)) { // check Permissions
|
|
142
|
+
isDisabled = true;
|
|
122
143
|
}
|
|
123
144
|
break;
|
|
124
|
-
case
|
|
145
|
+
case COPY:
|
|
125
146
|
if (disableCopy) {
|
|
126
147
|
isDisabled = true;
|
|
148
|
+
} else if (canUser && !canUser(COPY)) { // check Permissions
|
|
149
|
+
isDisabled = true;
|
|
127
150
|
}
|
|
128
151
|
break;
|
|
129
|
-
case
|
|
152
|
+
case DUPLICATE:
|
|
130
153
|
if (disableDuplicate || canEditorViewOnly) {
|
|
131
154
|
isDisabled = true;
|
|
155
|
+
} else if (canUser && !canUser(DUPLICATE)) { // check Permissions
|
|
156
|
+
isDisabled = true;
|
|
132
157
|
}
|
|
133
158
|
break;
|
|
134
|
-
case
|
|
159
|
+
case PRINT:
|
|
135
160
|
if (disablePrint) {
|
|
136
161
|
isDisabled = true;
|
|
162
|
+
} else if (canUser && !canUser(PRINT)) { // check Permissions
|
|
163
|
+
isDisabled = true;
|
|
137
164
|
}
|
|
138
165
|
break;
|
|
139
|
-
case
|
|
166
|
+
case UPLOAD_DOWNLOAD:
|
|
140
167
|
if (!useUploadDownload) {
|
|
141
168
|
isDisabled = true;
|
|
169
|
+
} else if (canUser && !canUser(UPLOAD_DOWNLOAD)) { // check Permissions
|
|
170
|
+
isDisabled = true;
|
|
142
171
|
}
|
|
143
172
|
break;
|
|
144
173
|
default:
|
|
@@ -152,7 +181,7 @@ export default function withPresetButtons(WrappedComponent, isGrid = false) {
|
|
|
152
181
|
icon = null,
|
|
153
182
|
isDisabled = false;
|
|
154
183
|
switch(type) {
|
|
155
|
-
case
|
|
184
|
+
case ADD:
|
|
156
185
|
key = 'addBtn';
|
|
157
186
|
text = 'Add';
|
|
158
187
|
handler = onAdd;
|
|
@@ -164,7 +193,7 @@ export default function withPresetButtons(WrappedComponent, isGrid = false) {
|
|
|
164
193
|
isDisabled = true;
|
|
165
194
|
}
|
|
166
195
|
break;
|
|
167
|
-
case
|
|
196
|
+
case EDIT:
|
|
168
197
|
key = 'editBtn';
|
|
169
198
|
text = 'Edit';
|
|
170
199
|
handler = onEdit;
|
|
@@ -179,7 +208,7 @@ export default function withPresetButtons(WrappedComponent, isGrid = false) {
|
|
|
179
208
|
isDisabled = true;
|
|
180
209
|
}
|
|
181
210
|
break;
|
|
182
|
-
case
|
|
211
|
+
case DELETE:
|
|
183
212
|
key = 'deleteBtn';
|
|
184
213
|
text = 'Delete';
|
|
185
214
|
handler = onDelete;
|
|
@@ -200,7 +229,7 @@ export default function withPresetButtons(WrappedComponent, isGrid = false) {
|
|
|
200
229
|
}
|
|
201
230
|
}
|
|
202
231
|
break;
|
|
203
|
-
case
|
|
232
|
+
case VIEW:
|
|
204
233
|
key = 'viewBtn';
|
|
205
234
|
text = 'View';
|
|
206
235
|
handler = onView;
|
|
@@ -213,7 +242,7 @@ export default function withPresetButtons(WrappedComponent, isGrid = false) {
|
|
|
213
242
|
isDisabled = true;
|
|
214
243
|
}
|
|
215
244
|
break;
|
|
216
|
-
case
|
|
245
|
+
case COPY:
|
|
217
246
|
key = 'copyBtn';
|
|
218
247
|
text = 'Copy to Clipboard';
|
|
219
248
|
handler = onCopyToClipboard;
|
|
@@ -226,7 +255,7 @@ export default function withPresetButtons(WrappedComponent, isGrid = false) {
|
|
|
226
255
|
isDisabled = true;
|
|
227
256
|
}
|
|
228
257
|
break;
|
|
229
|
-
case
|
|
258
|
+
case DUPLICATE:
|
|
230
259
|
key = 'duplicateBtn';
|
|
231
260
|
text = 'Duplicate';
|
|
232
261
|
handler = onDuplicate;
|
|
@@ -242,12 +271,12 @@ export default function withPresetButtons(WrappedComponent, isGrid = false) {
|
|
|
242
271
|
isDisabled = true;
|
|
243
272
|
}
|
|
244
273
|
break;
|
|
245
|
-
// case
|
|
274
|
+
// case PRINT:
|
|
246
275
|
// text = 'Print';
|
|
247
276
|
// handler = onPrint;
|
|
248
277
|
// icon = <Print />;
|
|
249
278
|
// break;
|
|
250
|
-
case
|
|
279
|
+
case UPLOAD_DOWNLOAD:
|
|
251
280
|
key = 'uploadDownloadBtn';
|
|
252
281
|
text = 'Upload/Download';
|
|
253
282
|
handler = onUploadDownload;
|
|
@@ -274,8 +303,8 @@ export default function withPresetButtons(WrappedComponent, isGrid = false) {
|
|
|
274
303
|
if (isTypeDisabledCompletely(type)) { // i.e. not just temporarily disabled because of selection
|
|
275
304
|
return;
|
|
276
305
|
}
|
|
277
|
-
if ((!userCanEdit && inArray(type, [
|
|
278
|
-
(!userCanView && type ===
|
|
306
|
+
if ((!userCanEdit && inArray(type, [ADD, EDIT, DELETE, DUPLICATE,])) ||
|
|
307
|
+
(!userCanView && type === VIEW)) {
|
|
279
308
|
return;
|
|
280
309
|
}
|
|
281
310
|
|
|
@@ -31,8 +31,9 @@ import withData from '../Hoc/withData.js';
|
|
|
31
31
|
import withEvents from '../Hoc/withEvents.js';
|
|
32
32
|
import withSideEditor from '../Hoc/withSideEditor.js';
|
|
33
33
|
import withFilters from '../Hoc/withFilters.js';
|
|
34
|
-
import withPresetButtons from '../Hoc/withPresetButtons.js';
|
|
35
34
|
import withMultiSelection from '../Hoc/withMultiSelection.js';
|
|
35
|
+
import withPresetButtons from '../Hoc/withPresetButtons.js';
|
|
36
|
+
import withPermissions from '../Hoc/withPermissions.js';
|
|
36
37
|
import withSelection from '../Hoc/withSelection.js';
|
|
37
38
|
import withWindowedEditor from '../Hoc/withWindowedEditor.js';
|
|
38
39
|
import getIconButtonFromConfig from '../../Functions/getIconButtonFromConfig.js';
|
|
@@ -1320,15 +1321,17 @@ export const Tree = withComponent(
|
|
|
1320
1321
|
withAlert(
|
|
1321
1322
|
withEvents(
|
|
1322
1323
|
withData(
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1324
|
+
withPermissions(
|
|
1325
|
+
// withMultiSelection(
|
|
1326
|
+
withSelection(
|
|
1327
|
+
withFilters(
|
|
1328
|
+
withContextMenu(
|
|
1329
|
+
TreeComponent
|
|
1330
|
+
)
|
|
1328
1331
|
)
|
|
1329
1332
|
)
|
|
1330
|
-
)
|
|
1331
|
-
|
|
1333
|
+
// )
|
|
1334
|
+
)
|
|
1332
1335
|
)
|
|
1333
1336
|
)
|
|
1334
1337
|
)
|
|
@@ -1338,20 +1341,22 @@ export const SideTreeEditor = withComponent(
|
|
|
1338
1341
|
withAlert(
|
|
1339
1342
|
withEvents(
|
|
1340
1343
|
withData(
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1344
|
+
withPermissions(
|
|
1345
|
+
// withMultiSelection(
|
|
1346
|
+
withSelection(
|
|
1347
|
+
withSideEditor(
|
|
1348
|
+
withFilters(
|
|
1349
|
+
withPresetButtons(
|
|
1350
|
+
withContextMenu(
|
|
1351
|
+
TreeComponent
|
|
1352
|
+
)
|
|
1348
1353
|
)
|
|
1349
|
-
)
|
|
1350
|
-
|
|
1351
|
-
|
|
1354
|
+
),
|
|
1355
|
+
true // isTree
|
|
1356
|
+
)
|
|
1352
1357
|
)
|
|
1353
|
-
)
|
|
1354
|
-
|
|
1358
|
+
// )
|
|
1359
|
+
)
|
|
1355
1360
|
)
|
|
1356
1361
|
)
|
|
1357
1362
|
)
|
|
@@ -1361,20 +1366,22 @@ export const WindowedTreeEditor = withComponent(
|
|
|
1361
1366
|
withAlert(
|
|
1362
1367
|
withEvents(
|
|
1363
1368
|
withData(
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1369
|
+
withPermissions(
|
|
1370
|
+
// withMultiSelection(
|
|
1371
|
+
withSelection(
|
|
1372
|
+
withWindowedEditor(
|
|
1373
|
+
withFilters(
|
|
1374
|
+
withPresetButtons(
|
|
1375
|
+
withContextMenu(
|
|
1376
|
+
TreeComponent
|
|
1377
|
+
)
|
|
1371
1378
|
)
|
|
1372
|
-
)
|
|
1373
|
-
|
|
1374
|
-
|
|
1379
|
+
),
|
|
1380
|
+
true // isTree
|
|
1381
|
+
)
|
|
1375
1382
|
)
|
|
1376
|
-
)
|
|
1377
|
-
|
|
1383
|
+
// )
|
|
1384
|
+
)
|
|
1378
1385
|
)
|
|
1379
1386
|
)
|
|
1380
1387
|
)
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const ADD = 'add';
|
|
2
|
+
export const EDIT = 'edit';
|
|
3
|
+
export const DELETE = 'delete';
|
|
4
|
+
export const VIEW = 'view';
|
|
5
|
+
export const COPY = 'copy';
|
|
6
|
+
export const DUPLICATE = 'duplicate';
|
|
7
|
+
export const PRINT = 'print';
|
|
8
|
+
export const UPLOAD_DOWNLOAD = 'uploadDownload';
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Modal,
|
|
3
|
-
Row,
|
|
4
|
-
Text,
|
|
5
|
-
} from 'native-base';
|
|
6
|
-
import withRedux from '../Data/hoc/withRedux';
|
|
7
|
-
import Loading from './Loading';
|
|
8
|
-
import _ from 'lodash';
|
|
9
|
-
|
|
10
|
-
export function WaitModal(props) {
|
|
11
|
-
const {
|
|
12
|
-
textMessage = 'Please wait...',
|
|
13
|
-
waitStack,
|
|
14
|
-
} = props;
|
|
15
|
-
|
|
16
|
-
return <Modal {...props} _backdrop={{ bg: "#000" }}>
|
|
17
|
-
<Modal.Content maxWidth="400px">
|
|
18
|
-
<Modal.Body>
|
|
19
|
-
<Row justifyContent="center" alignItems="center">
|
|
20
|
-
<Loading minHeight="auto" h={5} w={5} mr={2} />
|
|
21
|
-
<Text color="#000">{textMessage}</Text>
|
|
22
|
-
{/* {!!waitStack ? <Text color="#000">{_.keys(waitStack).join(', ')}</Text> : null} */}
|
|
23
|
-
</Row>
|
|
24
|
-
</Modal.Body>
|
|
25
|
-
</Modal.Content>
|
|
26
|
-
</Modal>;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export default withRedux(WaitModal, [
|
|
30
|
-
'waitStack',
|
|
31
|
-
]);
|