datastake-daf 0.6.754 → 0.6.756
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/dist/components/index.js +561 -525
- package/dist/hooks/index.js +11 -8
- package/dist/layouts/index.js +470 -448
- package/dist/pages/index.js +1276 -602
- package/dist/utils/index.js +470 -448
- package/package.json +1 -1
- package/src/@daf/core/components/Graphs/components/BaseGraph.jsx +4 -2
- package/src/@daf/core/components/Icon/configs/ClockPlus.js +14 -0
- package/src/@daf/core/components/Icon/configs/WaziDarkIcon.js +15 -0
- package/src/@daf/core/components/Icon/configs/index.js +4 -0
- package/src/@daf/core/components/Screens/BaseScreen/index.jsx +3 -3
- package/src/@daf/core/components/Screens/Users/columns.js +216 -0
- package/src/@daf/core/components/Screens/Users/config.js +174 -0
- package/src/@daf/core/components/Screens/Users/create.jsx +63 -0
- package/src/@daf/core/components/Screens/Users/index.jsx +173 -0
- package/src/@daf/core/components/TableScreen/TablePageWithTabs/index.jsx +4 -4
- package/src/@daf/hooks/useFilters.js +10 -8
- package/src/@daf/hooks/useWidgetFetch.js +3 -3
- package/src/@daf/pages/Dashboards/helper.js +3 -3
- package/src/@daf/pages/Documents/columns.js +2 -4
- package/src/@daf/pages/Events/Activities/index.jsx +1 -1
- package/src/@daf/pages/Events/columns.js +12 -14
- package/src/@daf/pages/Locations/MineSite/columns.js +16 -19
- package/src/@daf/pages/Locations/columns.js +2 -2
- package/src/@daf/pages/Stakeholders/Workers/columns.js +14 -4
- package/src/@daf/pages/Summary/Minesite/components/MineDetailsSection/index.js +1 -1
- package/src/@daf/pages/Summary/Minesite/index.jsx +1 -0
- package/src/@daf/pages/Summary/Operator/components/KeyInformation/config.js +7 -1
- package/src/@daf/pages/Summary/Operator/index.jsx +1 -0
- package/src/@daf/pages/Summary/components/InformationAvailability/index.js +1 -1
- package/src/@daf/pages/Summary/hook.js +5 -2
- package/src/pages.js +1 -1
- package/src/styles/components/_dataLink.scss +1 -0
- package/dist/style/datastake/mapbox-gl.css +0 -330
package/package.json
CHANGED
|
@@ -54,9 +54,10 @@ const BaseGraph = forwardRef(function BaseGraph(
|
|
|
54
54
|
|
|
55
55
|
requestAnimationFrame(() => {
|
|
56
56
|
fitView({
|
|
57
|
-
padding: 0.
|
|
57
|
+
padding: 0.4,
|
|
58
58
|
nodes: [...nodesToFit],
|
|
59
59
|
duration: withDuration ? 300 : undefined,
|
|
60
|
+
maxZoom: 0.8,
|
|
60
61
|
});
|
|
61
62
|
});
|
|
62
63
|
}, [JSON.stringify(nodesToFit), withDuration]);
|
|
@@ -82,8 +83,9 @@ const BaseGraph = forwardRef(function BaseGraph(
|
|
|
82
83
|
minZoom={minZoom}
|
|
83
84
|
maxZoom={maxZoom}
|
|
84
85
|
attributionPosition="top-left"
|
|
86
|
+
fitView={true} // zoom out on default
|
|
85
87
|
fitViewOptions={{
|
|
86
|
-
padding: 0.
|
|
88
|
+
padding: 0.2, //zoom out on default
|
|
87
89
|
duration: withDuration ? 300 : undefined,
|
|
88
90
|
}}
|
|
89
91
|
{...props}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const config = {
|
|
2
|
+
viewBox: "0 0 19 19",
|
|
3
|
+
children: (
|
|
4
|
+
<path
|
|
5
|
+
d="M17.3506 10.1375C17.3942 9.79224 17.4167 9.44041 17.4167 9.08333C17.4167 4.48096 13.6857 0.75 9.08333 0.75C4.48096 0.75 0.75 4.48096 0.75 9.08333C0.75 13.6857 4.48096 17.4167 9.08333 17.4167C9.44617 17.4167 9.80359 17.3935 10.1542 17.3485M9.08333 4.08333V9.08333L12.1986 10.641M14.9167 17.4167V12.4167M12.4167 14.9167H17.4167"
|
|
6
|
+
stroke="currentColor"
|
|
7
|
+
strokeWidth="1.5"
|
|
8
|
+
strokeLinecap="round"
|
|
9
|
+
strokeLinejoin="round"
|
|
10
|
+
/>
|
|
11
|
+
),
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default config;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const config = {
|
|
2
|
+
viewBox: '0 0 25 26',
|
|
3
|
+
children: (
|
|
4
|
+
<path
|
|
5
|
+
d="M12.5001 0C19.4037 2.39999e-07 25.0001 5.59644 25.0001 12.5C25.0001 19.0635 19.941 24.4456 13.5099 24.96C13.1457 24.9946 12.7787 25.0126 12.4103 25.0146H12.1056C5.42401 25.0146 0.00713129 19.5985 0.00695801 12.917C0.00242724 12.7787 0.000122101 12.6394 0.00012207 12.5C0.00012207 5.59644 5.59656 0 12.5001 0ZM12.1642 5.32715C8.53558 5.32715 5.65747 8.46702 5.65735 12.2588V13.4951C5.65735 17.287 8.5355 20.4268 12.1642 20.4268C15.7926 20.4264 18.671 17.2868 18.671 13.4951V12.2588C18.6709 8.46722 15.7925 5.32748 12.1642 5.32715ZM12.1642 6.42676C15.1149 6.42709 17.5703 9.00217 17.5704 12.2588V13.4951C17.5704 16.7518 15.115 19.3268 12.1642 19.3271C9.21313 19.3271 6.75696 16.7521 6.75696 13.4951V12.2588C6.75708 9.00197 9.21321 6.42676 12.1642 6.42676ZM11.7618 9.40918L8.86145 12.5166L8.51086 12.8926L8.86145 13.2676L11.7618 16.375L12.1642 16.8057L12.5665 16.375L15.4669 13.2676L15.8175 12.8926L15.4669 12.5166L12.5665 9.40918L12.1642 8.97852L11.7618 9.40918ZM13.798 13.4424L12.1632 15.1924L10.5294 13.4424H13.798ZM13.798 12.3418H10.5294L12.1632 10.5908L13.798 12.3418Z"
|
|
6
|
+
fill="currentColor"
|
|
7
|
+
/>
|
|
8
|
+
),
|
|
9
|
+
tag: ['logo']
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default config;
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
@@ -222,6 +222,8 @@ import Aid from "./Aid";
|
|
|
222
222
|
import Bear from "./Bear";
|
|
223
223
|
import Security from "./Security";
|
|
224
224
|
import Minus from "./Minus";
|
|
225
|
+
import ClockPlus from "./ClockPlus";
|
|
226
|
+
import WaziDarkIcon from "./WaziDarkIcon";
|
|
225
227
|
|
|
226
228
|
const config = {
|
|
227
229
|
AppAdmin,
|
|
@@ -448,6 +450,8 @@ const config = {
|
|
|
448
450
|
Bear,
|
|
449
451
|
Security,
|
|
450
452
|
Minus,
|
|
453
|
+
ClockPlus,
|
|
454
|
+
WaziDarkIcon,
|
|
451
455
|
};
|
|
452
456
|
|
|
453
457
|
export default config;
|
|
@@ -104,8 +104,8 @@ const BaseScreen = ({
|
|
|
104
104
|
});
|
|
105
105
|
|
|
106
106
|
useEffect(() => {
|
|
107
|
-
if (typeof data?.meta?.total === "number") {
|
|
108
|
-
setPagination((prev) => ({ ...prev, total: data?.meta?.total }));
|
|
107
|
+
if (typeof (data?.meta?.total || data?.totalItems) === "number") {
|
|
108
|
+
setPagination((prev) => ({ ...prev, total: (data?.meta?.total || data?.totalItems) }));
|
|
109
109
|
}
|
|
110
110
|
}, [data]);
|
|
111
111
|
|
|
@@ -161,7 +161,7 @@ const BaseScreen = ({
|
|
|
161
161
|
goNext={goNext}
|
|
162
162
|
canGoNext={canGoNext}
|
|
163
163
|
canGoPrev={canGoPrev}
|
|
164
|
-
totalItems={pagination.total}
|
|
164
|
+
totalItems={pagination.total || pagination.pageSize}
|
|
165
165
|
doTotalItems
|
|
166
166
|
onChangePagination={(val) => {
|
|
167
167
|
onTableChange({ ...pagination, current: 1, pageSize: val });
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Modal, Tag, Typography, message ,Tooltip} from "antd";
|
|
3
|
+
|
|
4
|
+
import { renderDateFormatted } from '../../../../../helpers/Forms.js';
|
|
5
|
+
import MoreMenu from '../../../../core/components/Table/MoreMenu/index.jsx';
|
|
6
|
+
const getLinkValue = (value, linkingObject) => {
|
|
7
|
+
if(linkingObject && linkingObject?.[value]) {
|
|
8
|
+
return linkingObject?.[value]?.name;
|
|
9
|
+
}
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const getColumns = ({t, goTo, user, removeUser = () => {},
|
|
14
|
+
resendInvite = () => {},
|
|
15
|
+
setUserToEdit = () => {},
|
|
16
|
+
userRoles = [],
|
|
17
|
+
company = {},
|
|
18
|
+
canCreate = false,
|
|
19
|
+
app}) => [
|
|
20
|
+
// {
|
|
21
|
+
// dataIndex: 'datastakeId',
|
|
22
|
+
// title: t('ID'),
|
|
23
|
+
// ellipsis: true,
|
|
24
|
+
// show: true,
|
|
25
|
+
// render: (v, all) => {
|
|
26
|
+
// if (all.empty) {
|
|
27
|
+
// return <div className="daf-default-cell" />
|
|
28
|
+
// }
|
|
29
|
+
|
|
30
|
+
// return <Tooltip title={v}>{v}</Tooltip>;
|
|
31
|
+
// },
|
|
32
|
+
// },
|
|
33
|
+
{
|
|
34
|
+
dataIndex: 'firstName',
|
|
35
|
+
title: t('Name'),
|
|
36
|
+
ellipsis: true,
|
|
37
|
+
show: true,
|
|
38
|
+
render: (v, all) => {
|
|
39
|
+
if (all.empty) {
|
|
40
|
+
return <div className="daf-default-cell" />
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return <Tooltip title={v}>{v}</Tooltip>;
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
dataIndex: 'lastName',
|
|
48
|
+
title: t('Last Name'),
|
|
49
|
+
ellipsis: true,
|
|
50
|
+
show: true,
|
|
51
|
+
render: (v, all) => {
|
|
52
|
+
if (all.empty) {
|
|
53
|
+
return <div className="daf-default-cell" />
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return <Tooltip title={v}>{v}</Tooltip>;
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
dataIndex: 'email',
|
|
61
|
+
title: t('Email'),
|
|
62
|
+
ellipsis: true,
|
|
63
|
+
show: true,
|
|
64
|
+
render: (v, all) => {
|
|
65
|
+
if (all.empty) {
|
|
66
|
+
return <div className="daf-default-cell" />
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return <Tooltip title={v}>{v}</Tooltip>;
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
title: t("Status"),
|
|
75
|
+
dataIndex: "status",
|
|
76
|
+
key: "status",
|
|
77
|
+
width: 150,
|
|
78
|
+
ellipsis: false,
|
|
79
|
+
show: true,
|
|
80
|
+
render: (status, users) => {
|
|
81
|
+
if (users.empty) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (status === "inactive") {
|
|
86
|
+
return (
|
|
87
|
+
<Tag color="red" style={{ width: 100, textAlign: "center" }}>
|
|
88
|
+
{t("Blocked")}
|
|
89
|
+
</Tag>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (status === "active") {
|
|
94
|
+
return (
|
|
95
|
+
<Tag color="green" style={{ width: 100, textAlign: "center" }}>
|
|
96
|
+
{t("Active")}
|
|
97
|
+
</Tag>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<Tag color="orange" style={{ width: 100, textAlign: "center" }}>
|
|
103
|
+
{t("Pending")}
|
|
104
|
+
</Tag>
|
|
105
|
+
);
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
title: t("Last Login"),
|
|
110
|
+
dataIndex: "lastLogin",
|
|
111
|
+
key: "lastLogin",
|
|
112
|
+
width: 125,
|
|
113
|
+
render: (date, all) => {
|
|
114
|
+
if (all.empty) {
|
|
115
|
+
return <div className="daf-default-cell" />;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const _date = date ? renderDateFormatted(date, "DD MMM YYYY", user?.language || 'en') : "-";
|
|
119
|
+
return <Tooltip title={_date}>{_date}</Tooltip>;
|
|
120
|
+
},
|
|
121
|
+
ellipsis: true,
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
title: t("User Role"),
|
|
125
|
+
dataIndex: "roleName",
|
|
126
|
+
key: "role",
|
|
127
|
+
show: true,
|
|
128
|
+
render: (val, all) => {
|
|
129
|
+
if (all.empty) {
|
|
130
|
+
return <div className="daf-default-cell" />;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Display role name if available, fallback to role ID
|
|
134
|
+
const displayValue = val || all.role;
|
|
135
|
+
return <Tooltip title={displayValue}>{displayValue}</Tooltip>;
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
title: t(""),
|
|
140
|
+
key: "actions",
|
|
141
|
+
width: 60,
|
|
142
|
+
show: removeUser || setUserToEdit,
|
|
143
|
+
render: (row, all) => {
|
|
144
|
+
if (all.empty) {
|
|
145
|
+
return <div className="daf-default-cell" />;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const _v = userRoles?.find((r) => r.value === all.role);
|
|
149
|
+
|
|
150
|
+
const items = [
|
|
151
|
+
removeUser
|
|
152
|
+
? {
|
|
153
|
+
key: "removeUser",
|
|
154
|
+
onClick: () => {
|
|
155
|
+
Modal.confirm({
|
|
156
|
+
title: t(
|
|
157
|
+
"Are you sure you want to remove this user from your organisation?",
|
|
158
|
+
),
|
|
159
|
+
onOk: () => removeUser(all.id),
|
|
160
|
+
cancelText: t("No"),
|
|
161
|
+
okText: "Yes",
|
|
162
|
+
closable: true,
|
|
163
|
+
});
|
|
164
|
+
},
|
|
165
|
+
label: t("Remove User"),
|
|
166
|
+
}
|
|
167
|
+
: null,
|
|
168
|
+
setUserToEdit ? {
|
|
169
|
+
key: "editPermission",
|
|
170
|
+
onClick: () => setUserToEdit(all),
|
|
171
|
+
disabled: all.isAdmin || _v?.isForAppAdmin,
|
|
172
|
+
label: t("Edit Permissions"),
|
|
173
|
+
}
|
|
174
|
+
: null,
|
|
175
|
+
all.invitationToken && canCreate
|
|
176
|
+
? {
|
|
177
|
+
key: "copyLink",
|
|
178
|
+
onClick: () => {
|
|
179
|
+
if (location.pathname.includes(`/${APP}`)) {
|
|
180
|
+
navigator.clipboard.writeText(
|
|
181
|
+
`${window.location.host}/${app}/r/${company.inviteToken}/${all.invitationToken}`,
|
|
182
|
+
);
|
|
183
|
+
} else {
|
|
184
|
+
navigator.clipboard.writeText(
|
|
185
|
+
`${window.location.host}/r/${company.inviteToken}/${all.invitationToken}`,
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
message.info({ content: t("Invitation link copied") });
|
|
189
|
+
},
|
|
190
|
+
label: t("Copy Invitation Link"),
|
|
191
|
+
}
|
|
192
|
+
: null,
|
|
193
|
+
all.invitationToken && canCreate
|
|
194
|
+
? {
|
|
195
|
+
key: "resendInvite",
|
|
196
|
+
onClick: () => {
|
|
197
|
+
Modal.confirm({
|
|
198
|
+
title: t(
|
|
199
|
+
"Are you sure you want to invite this user again? This user will receive a new notification",
|
|
200
|
+
),
|
|
201
|
+
onOk: () => resendInvite(all.id),
|
|
202
|
+
cancelText: t("No"),
|
|
203
|
+
okText: "Yes",
|
|
204
|
+
closable: true,
|
|
205
|
+
});
|
|
206
|
+
},
|
|
207
|
+
label: t("Resend Invite"),
|
|
208
|
+
}
|
|
209
|
+
: null,
|
|
210
|
+
];
|
|
211
|
+
|
|
212
|
+
return <MoreMenu items={items} />;
|
|
213
|
+
},
|
|
214
|
+
client: false,
|
|
215
|
+
},
|
|
216
|
+
].filter((column) => column.show !== false);
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
export const checkboxConfig = {
|
|
2
|
+
name: 'Name',
|
|
3
|
+
datastakeId: 'ID'
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export const getFiltersConfig = ({t}) => {
|
|
7
|
+
return {
|
|
8
|
+
email: {
|
|
9
|
+
type: 'text',
|
|
10
|
+
label: 'Email',
|
|
11
|
+
placeholder: (t) => `${t('Filter by')} ${t('Email').toLowerCase()}`,
|
|
12
|
+
style: { flex: 1 },
|
|
13
|
+
labelStyle: { flex: 1 },
|
|
14
|
+
getLabel: (option) => option.label,
|
|
15
|
+
getValue: (option) => option.value,
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
status: {
|
|
20
|
+
type: "select",
|
|
21
|
+
label: "Status",
|
|
22
|
+
placeholder: (t) => `${t("Filter by")} ${t("Status").toLowerCase()}`,
|
|
23
|
+
style: { flex: 1 },
|
|
24
|
+
labelStyle: { fley: 1 },
|
|
25
|
+
getLabel: (option) => option.label,
|
|
26
|
+
getValue: (option) => option.value,
|
|
27
|
+
},
|
|
28
|
+
timeframe: {
|
|
29
|
+
type: "timeframe",
|
|
30
|
+
label: "Timeframe",
|
|
31
|
+
placeholder: (t) => `${t("Filter by")} ${t("Timeframe").toLowerCase()}`,
|
|
32
|
+
style: { flex: 1 },
|
|
33
|
+
labelStyle: { flex: 1 },
|
|
34
|
+
},
|
|
35
|
+
userRole: {
|
|
36
|
+
type: "select",
|
|
37
|
+
label: "User Role",
|
|
38
|
+
placeholder: (t) => `${t("Filter by")} ${t("User Role").toLowerCase()}`,
|
|
39
|
+
style: { flex: 1 },
|
|
40
|
+
labelStyle: { flex: 1 },
|
|
41
|
+
},
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export const filtersConfig = {
|
|
46
|
+
name: '',
|
|
47
|
+
datastakeId: '',
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const getFilterOptions = (options, t) => {
|
|
51
|
+
const {
|
|
52
|
+
emailOptions = [],
|
|
53
|
+
statusOptions = [],
|
|
54
|
+
timeframeOptions = [],
|
|
55
|
+
userRoleOptions = [],
|
|
56
|
+
} = options || {};
|
|
57
|
+
console.log({options})
|
|
58
|
+
|
|
59
|
+
const _default = {
|
|
60
|
+
timeframe: timeframeOptions,
|
|
61
|
+
email: emailOptions,
|
|
62
|
+
status: statusOptions,
|
|
63
|
+
userRole: userRoleOptions,
|
|
64
|
+
status: [
|
|
65
|
+
{
|
|
66
|
+
value: "active",
|
|
67
|
+
label: "Active",
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
value: "pending",
|
|
71
|
+
label: "Pending",
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return _default;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export const getUserForm = ({ t, userRoles = [], APP }) => {
|
|
80
|
+
return {
|
|
81
|
+
user: {
|
|
82
|
+
position: 0,
|
|
83
|
+
firstName: {
|
|
84
|
+
group: "user",
|
|
85
|
+
section: "user",
|
|
86
|
+
moduleScope: {
|
|
87
|
+
cadd: ["scoping", "new", "linking-extra"],
|
|
88
|
+
pme: ["scoping", "new", "linking-extra"],
|
|
89
|
+
},
|
|
90
|
+
label: t("First Name"),
|
|
91
|
+
comment: false,
|
|
92
|
+
type: "text",
|
|
93
|
+
rules: [
|
|
94
|
+
{
|
|
95
|
+
required: true,
|
|
96
|
+
message: "This field is required",
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
mergeStrategy: "simple",
|
|
100
|
+
position: 1,
|
|
101
|
+
},
|
|
102
|
+
lastName: {
|
|
103
|
+
group: "user",
|
|
104
|
+
section: "user",
|
|
105
|
+
moduleScope: {
|
|
106
|
+
cadd: ["scoping", "new", "linking-extra"],
|
|
107
|
+
pme: ["scoping", "new", "linking-extra"],
|
|
108
|
+
},
|
|
109
|
+
label: t("Last Name"),
|
|
110
|
+
comment: false,
|
|
111
|
+
type: "text",
|
|
112
|
+
rules: [
|
|
113
|
+
{
|
|
114
|
+
required: true,
|
|
115
|
+
message: "This field is required",
|
|
116
|
+
},
|
|
117
|
+
],
|
|
118
|
+
mergeStrategy: "simple",
|
|
119
|
+
position: 2,
|
|
120
|
+
},
|
|
121
|
+
email: {
|
|
122
|
+
group: "user",
|
|
123
|
+
section: "user",
|
|
124
|
+
moduleScope: {
|
|
125
|
+
cadd: ["scoping", "new", "linking-extra"],
|
|
126
|
+
pme: ["scoping", "new", "linking-extra"],
|
|
127
|
+
},
|
|
128
|
+
label: t("Email"),
|
|
129
|
+
comment: false,
|
|
130
|
+
type: "text",
|
|
131
|
+
rules: [
|
|
132
|
+
{
|
|
133
|
+
required: true,
|
|
134
|
+
message: "This field is required",
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
type: "email",
|
|
138
|
+
message: "errors::field must be email",
|
|
139
|
+
},
|
|
140
|
+
],
|
|
141
|
+
mergeStrategy: "simple",
|
|
142
|
+
position: 3,
|
|
143
|
+
},
|
|
144
|
+
role: {
|
|
145
|
+
group: "user",
|
|
146
|
+
section: "user",
|
|
147
|
+
moduleScope: {
|
|
148
|
+
cadd: ["scoping", "new", "linking", "linking-extra", "admin"],
|
|
149
|
+
pme: ["scoping", "new", "linking", "linking-extra", "admin"],
|
|
150
|
+
},
|
|
151
|
+
label: t("User Role"),
|
|
152
|
+
placeholder: t("User Role"),
|
|
153
|
+
comment: false,
|
|
154
|
+
type: "select",
|
|
155
|
+
options: userRoles
|
|
156
|
+
.filter((r) => r.canBeAssignedToSubUsers && r.app === APP)
|
|
157
|
+
.map((v) => ({
|
|
158
|
+
label: t(v.label),
|
|
159
|
+
value: v.value,
|
|
160
|
+
})),
|
|
161
|
+
optionsName: "userRoles",
|
|
162
|
+
// tooltip: <UserRolePopover t={t} />,
|
|
163
|
+
sortOptions: true,
|
|
164
|
+
rules: [
|
|
165
|
+
{
|
|
166
|
+
required: true,
|
|
167
|
+
message: "This field is required",
|
|
168
|
+
},
|
|
169
|
+
],
|
|
170
|
+
position: 4,
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
};
|
|
174
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React, { useMemo } from 'react'
|
|
2
|
+
import { getUserForm } from './config.js';
|
|
3
|
+
import DynamicForm from '../../../../core/components/DynamicForm/index.jsx';
|
|
4
|
+
|
|
5
|
+
const UsersCreate = ({
|
|
6
|
+
onSubmitted = () => {},
|
|
7
|
+
onCancel = () => {},
|
|
8
|
+
user = {},
|
|
9
|
+
APP,
|
|
10
|
+
query,
|
|
11
|
+
goTo = () => {},
|
|
12
|
+
t = () => {},
|
|
13
|
+
ajaxForms = {},
|
|
14
|
+
changeAjaxForms = () => {},
|
|
15
|
+
ajaxOptions = {},
|
|
16
|
+
changeAjaxOptions = () => {},
|
|
17
|
+
getAppHeader = () => {},
|
|
18
|
+
getApiBaseUrl = () => {},
|
|
19
|
+
userToEdit = null,
|
|
20
|
+
userRoles = [],
|
|
21
|
+
}) => {
|
|
22
|
+
const disabledInputs = useMemo(() => !userToEdit ? [] : ['firstName', 'lastName', 'email'], [userToEdit]);
|
|
23
|
+
const data = useMemo(() => ({ ...(userToEdit || {}), userRole: userToEdit?.role }), [userToEdit]);
|
|
24
|
+
const form = useMemo(() => getUserForm({ t, userRoles, APP }), [t, userRoles, APP]);
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<div className="daf-create-form">
|
|
28
|
+
<DynamicForm
|
|
29
|
+
form={form}
|
|
30
|
+
data={data}
|
|
31
|
+
showSaveAndNext={false}
|
|
32
|
+
module={APP}
|
|
33
|
+
onCancel={onCancel}
|
|
34
|
+
isCreate
|
|
35
|
+
t={t}
|
|
36
|
+
user={user}
|
|
37
|
+
ajaxForms={ajaxForms}
|
|
38
|
+
ajaxOptions={ajaxOptions}
|
|
39
|
+
getAppHeader={getAppHeader}
|
|
40
|
+
getApiBaseUrl={getApiBaseUrl}
|
|
41
|
+
changeAjaxOptions={changeAjaxOptions}
|
|
42
|
+
app={APP}
|
|
43
|
+
query={query}
|
|
44
|
+
goTo={goTo}
|
|
45
|
+
changeAjaxForms={changeAjaxForms}
|
|
46
|
+
disabledInputs={disabledInputs}
|
|
47
|
+
submit={(payload) => {
|
|
48
|
+
onSubmitted({
|
|
49
|
+
...payload,
|
|
50
|
+
apps: {
|
|
51
|
+
[APP]: {
|
|
52
|
+
...((userToEdit?.apps || {})[APP] || {}),
|
|
53
|
+
role: payload.role,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
}}
|
|
58
|
+
/>
|
|
59
|
+
</div>
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export default UsersCreate
|