datastake-daf 0.6.743 → 0.6.745
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 +549 -893
- package/dist/context/index.js +0 -3
- package/dist/hooks/index.js +19 -4658
- package/dist/layouts/index.js +573 -916
- package/dist/pages/index.js +2630 -1243
- package/dist/services/index.js +3 -9
- package/dist/utils/index.js +466 -808
- package/package.json +3 -1
- package/rollup.config.js +7 -2
- package/src/@daf/core/components/DynamicForm/components/ajaxModal.js +1 -1
- package/src/@daf/core/components/EditForm/components/Comment/index.js +1 -1
- package/src/@daf/core/components/EditForm/components/DataLink/ajaxSelectDataLink.js +1 -1
- package/src/@daf/core/components/EditForm/components/DataLink/flat.js +1 -1
- package/src/@daf/core/components/EditForm/components/DataLink/index.js +1 -1
- package/src/@daf/core/components/EditForm/components/DataLinkGroup/index.js +1 -1
- package/src/@daf/core/components/EditForm/components/Repeatable/index.js +1 -1
- package/src/@daf/core/components/EditForm/components/ajaxSelect.js +1 -1
- package/src/@daf/core/components/EditForm/components/geolocation.js +1 -0
- package/src/@daf/core/components/EditForm/helper.js +0 -4
- package/src/@daf/core/components/Screens/Admin/AdminModals/CombineAccount/index.jsx +1 -1
- package/src/@daf/core/components/Screens/Admin/AdminModals/CombineLocation/index.jsx +1 -1
- package/src/@daf/core/components/Screens/Admin/AdminModals/CombineSubjects/index.jsx +1 -1
- package/src/@daf/layouts/AppLayout/index.jsx +5 -4
- package/src/@daf/layouts/AuthLayout/components/Select/style.js +1 -1
- package/src/@daf/layouts/AuthLayout/style.js +1 -1
- package/src/@daf/pages/Documents/columns.js +102 -0
- package/src/@daf/pages/{dashboards/AllInformation/Documents → Documents}/create.jsx +7 -6
- package/src/@daf/pages/{dashboards/AllInformation/Documents → Documents}/index.jsx +20 -27
- package/src/@daf/pages/Events/Activities/columns.js +222 -0
- package/src/@daf/pages/{dashboards/DueDilligence → Events}/Activities/create.jsx +2 -2
- package/src/@daf/pages/{dashboards/DueDilligence → Events}/Activities/index.jsx +6 -6
- package/src/@daf/pages/{dashboards/DueDilligence/Activities → Events/Incidents}/columns.js +5 -5
- package/src/@daf/pages/Events/Incidents/create.jsx +104 -0
- package/src/@daf/pages/Events/Incidents/index.jsx +157 -0
- package/src/@daf/pages/Events/Incidents2/columns.js +176 -0
- package/src/@daf/pages/Events/Incidents2/config.js +170 -0
- package/src/@daf/pages/Events/Incidents2/create.jsx +104 -0
- package/src/@daf/pages/Events/Incidents2/index.jsx +156 -0
- package/src/@daf/pages/Events/columns.js +226 -0
- package/src/@daf/pages/Events/config.js +183 -0
- package/src/@daf/pages/{dashboards/AllInformation/Events → Events}/create.jsx +4 -4
- package/src/@daf/pages/{dashboards/AllInformation/Events → Events}/index.jsx +13 -9
- package/src/@daf/pages/{dashboards/AllInformation/Events → Locations/MineSite}/columns.js +52 -53
- package/src/@daf/pages/Locations/MineSite/config.js +165 -0
- package/src/@daf/pages/Locations/MineSite/create.jsx +104 -0
- package/src/@daf/pages/Locations/MineSite/index.jsx +155 -0
- package/src/@daf/pages/{dashboards/AllInformation/Locations → Locations}/columns.js +5 -5
- package/src/@daf/pages/{dashboards/AllInformation/Locations → Locations}/create.jsx +3 -3
- package/src/@daf/pages/{dashboards/AllInformation/Locations → Locations}/index.jsx +13 -5
- package/src/@daf/pages/{dashboards/Operations → Stakeholders}/Operators/columns.js +5 -5
- package/src/@daf/pages/{dashboards/Operations → Stakeholders}/Operators/create.jsx +2 -2
- package/src/@daf/pages/{dashboards/Operations → Stakeholders}/Operators/index.jsx +5 -5
- package/src/@daf/pages/{dashboards/Operations → Stakeholders}/Workers/columns.js +6 -6
- package/src/@daf/pages/Stakeholders/Workers/config.js +166 -0
- package/src/@daf/pages/{dashboards/Operations → Stakeholders}/Workers/create.jsx +2 -2
- package/src/@daf/pages/{dashboards/Operations → Stakeholders}/Workers/index.jsx +5 -5
- package/src/@daf/pages/{dashboards/AllInformation/Stakeholders → Stakeholders}/columns.js +5 -5
- package/src/@daf/pages/{dashboards/AllInformation/Stakeholders → Stakeholders}/create.jsx +3 -3
- package/src/@daf/pages/{dashboards/AllInformation/Stakeholders → Stakeholders}/index.jsx +14 -6
- package/src/@daf/pages/dashboards/SupplyChain/components/ChartsContainer/components/Identification/index.js +0 -2
- package/src/@daf/pages/dashboards/UserDashboard/components/KeyIndicators/config.js +2 -2
- package/src/@daf/pages/dashboards/UserDashboard/components/MineSites/index.jsx +1 -5
- package/src/@daf/pages/dashboards/UserDashboard/config.js +2 -2
- package/src/@daf/pages/pages/TablePageWithTabs/index.jsx +2 -2
- package/src/@daf/services/AuthenticationService.js +0 -1
- package/src/@daf/services/LinkedSubjects.js +3 -4
- package/src/pages.js +10 -7
- package/build/favicon.ico +0 -0
- package/build/logo192.png +0 -0
- package/build/logo512.png +0 -0
- package/build/manifest.json +0 -25
- package/build/robots.txt +0 -3
- package/src/@daf/pages/dashboards/AllInformation/Documents/columns.js +0 -107
- package/src/@daf/pages/dashboards/AllInformation/Stakeholders/config.js +0 -31
- /package/src/@daf/pages/{dashboards/AllInformation/Documents → Documents}/config.js +0 -0
- /package/src/@daf/pages/{dashboards/DueDilligence → Events}/Activities/config.js +0 -0
- /package/src/@daf/pages/{dashboards/Operations/Workers → Events/Incidents}/config.js +0 -0
- /package/src/@daf/pages/{dashboards/AllInformation/Events → Locations}/config.js +0 -0
- /package/src/@daf/pages/{dashboards/Operations → Stakeholders}/Operators/config.js +0 -0
- /package/src/@daf/pages/{dashboards/AllInformation/Locations → Stakeholders}/config.js +0 -0
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Tooltip, Tag } from 'antd';
|
|
3
|
+
import { findOptions } from '../../../../helpers/StringHelper.js';
|
|
4
|
+
import { renderDateFormatted } from '../../../../helpers/Forms.js';
|
|
5
|
+
import CustomIcon from '../../../core/components/Icon/CustomIcon.jsx';
|
|
6
|
+
import AvatarGroup from '../../../core/components/AvatarGroup/index.jsx';
|
|
7
|
+
import sourceAvatarConfig from '../../../../helpers/sourceAvatarConfig.js';
|
|
8
|
+
|
|
9
|
+
const getLinkValue = (value, linkingObject) => {
|
|
10
|
+
if(linkingObject && linkingObject?.[value]) {
|
|
11
|
+
return linkingObject?.[value]?.name;
|
|
12
|
+
}
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const getEventCategoryBySubject = (eventCategoryObject, subject) => {
|
|
17
|
+
if (!eventCategoryObject || typeof eventCategoryObject !== 'object') {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const subjectSingular = subject.endsWith('ies')
|
|
22
|
+
? subject.slice(0, -3) + 'y'
|
|
23
|
+
: subject;
|
|
24
|
+
|
|
25
|
+
const key = `typeOfEvent is ${subjectSingular}`;
|
|
26
|
+
return eventCategoryObject[key] || null;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const renderStatusTag = ({ value, t = (s) => s }) => {
|
|
30
|
+
const width = 87;
|
|
31
|
+
|
|
32
|
+
switch (value) {
|
|
33
|
+
case "edited":
|
|
34
|
+
return (
|
|
35
|
+
<Tag color="yellow" style={{ width }} className="text-center">
|
|
36
|
+
{t("Edited")}
|
|
37
|
+
</Tag>
|
|
38
|
+
);
|
|
39
|
+
case "submitted":
|
|
40
|
+
return (
|
|
41
|
+
<Tag color="green" style={{ width }} className="text-center">
|
|
42
|
+
{t("Submitted")}
|
|
43
|
+
</Tag>
|
|
44
|
+
);
|
|
45
|
+
default:
|
|
46
|
+
return (
|
|
47
|
+
<Tag color="blue" style={{ width }} className="text-center">
|
|
48
|
+
{t("Private")}
|
|
49
|
+
</Tag>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink, theme, subject, data, applications}) => [
|
|
55
|
+
{
|
|
56
|
+
dataIndex: 'datastakeId',
|
|
57
|
+
title: t('ID'),
|
|
58
|
+
ellipsis: true,
|
|
59
|
+
show: true,
|
|
60
|
+
render: (v, all) => {
|
|
61
|
+
if (all.empty) {
|
|
62
|
+
return <div className="daf-default-cell" />
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return <Tooltip title={v}>{v}</Tooltip>;
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
dataIndex: 'name',
|
|
70
|
+
title: t('Title'),
|
|
71
|
+
ellipsis: true,
|
|
72
|
+
show: true,
|
|
73
|
+
render: (v, all) => {
|
|
74
|
+
if (all.empty) {
|
|
75
|
+
return <div className="daf-default-cell" />
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return <Tooltip title={v}>{v}</Tooltip>;
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
title: t("Date"),
|
|
83
|
+
dataIndex: "date",
|
|
84
|
+
key: "date",
|
|
85
|
+
render: (date, all) => {
|
|
86
|
+
if (all.empty) {
|
|
87
|
+
return <div className="daf-default-cell" />;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const _date = date ? renderDateFormatted(date, "DD MMM YYYY", user?.language || 'en') : "-";
|
|
91
|
+
return <Tooltip title={_date}>{_date}</Tooltip>;
|
|
92
|
+
},
|
|
93
|
+
ellipsis: true,
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
dataIndex: 'mineSite',
|
|
97
|
+
title: t('Location'),
|
|
98
|
+
ellipsis: true,
|
|
99
|
+
show: true,
|
|
100
|
+
render: (v, all) => {
|
|
101
|
+
if (all.empty) {
|
|
102
|
+
return <div className="daf-default-cell" />
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// const country = findOptions(v, data?.options?.positionSupplyChainOptions);
|
|
106
|
+
const mineSite = all?.location?.name
|
|
107
|
+
|
|
108
|
+
return mineSite ? <Tooltip title={mineSite}>{mineSite}</Tooltip> : '-';
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
dataIndex: 'province',
|
|
113
|
+
title: t('Province'),
|
|
114
|
+
ellipsis: true,
|
|
115
|
+
show: true,
|
|
116
|
+
render: (v, all) => {
|
|
117
|
+
if (all.empty) {
|
|
118
|
+
return <div className="daf-default-cell" />
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const region = getLinkValue(all?.location?.administrativeLevel1, all?.location?.linking?.SCL);
|
|
122
|
+
|
|
123
|
+
return region ? <Tooltip title={region}>{region}</Tooltip> : '-';
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
dataIndex: 'territory',
|
|
128
|
+
title: t('Territory'),
|
|
129
|
+
ellipsis: true,
|
|
130
|
+
show: true,
|
|
131
|
+
render: (v, all) => {
|
|
132
|
+
if (all.empty) {
|
|
133
|
+
return <div className="daf-default-cell" />
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const district = getLinkValue(all?.location?.administrativeLevel2, all?.location?.linking?.SCL);
|
|
137
|
+
|
|
138
|
+
return district ? <Tooltip title={district}>{district}</Tooltip> : '-';
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
dataIndex: 'eventCategory',
|
|
143
|
+
title: t('Category'),
|
|
144
|
+
ellipsis: true,
|
|
145
|
+
show: true,
|
|
146
|
+
render: (v, all) => {
|
|
147
|
+
if (all.empty) {
|
|
148
|
+
return <div className="daf-default-cell" />
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const eventCategory = findOptions(v, data?.options?.eventCategoryOptions);
|
|
152
|
+
const categoryValue = getEventCategoryBySubject(eventCategory, subject);
|
|
153
|
+
console.log({categoryValue})
|
|
154
|
+
console.log({eventCategory})
|
|
155
|
+
console.log({subject})
|
|
156
|
+
|
|
157
|
+
return categoryValue ? <Tooltip title={categoryValue}>{categoryValue}</Tooltip> : '-';
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
title: t("Sources"),
|
|
162
|
+
dataIndex: "sources",
|
|
163
|
+
key: "sources",
|
|
164
|
+
show: activeTab !== "own",
|
|
165
|
+
render: (val, all) => {
|
|
166
|
+
if (all.empty) {
|
|
167
|
+
return <div className="daf-default-cell" />;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const sources = sourceAvatarConfig(val, user, applications);
|
|
171
|
+
|
|
172
|
+
return <AvatarGroup items={sources}></AvatarGroup>;
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
title: t("Status"),
|
|
177
|
+
dataIndex: "status",
|
|
178
|
+
key: "status",
|
|
179
|
+
show: activeTab === "own",
|
|
180
|
+
render: (val, all) => {
|
|
181
|
+
if (all.empty) {
|
|
182
|
+
return <div className="daf-default-cell" />
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const _val = all?.published || all?.status === "submitted" ? "submitted" : val;
|
|
186
|
+
|
|
187
|
+
return renderStatusTag({ value: _val, t });
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
title: t("Last Update"),
|
|
192
|
+
dataIndex: "updatedAt",
|
|
193
|
+
key: "updatedAt",
|
|
194
|
+
render: (date, all) => {
|
|
195
|
+
if (all.empty) {
|
|
196
|
+
return <div className="daf-default-cell" />;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const _date = date ? renderDateFormatted(date, "DD MMM YYYY", user?.language || 'en') : "-";
|
|
200
|
+
return <Tooltip title={_date}>{_date}</Tooltip>;
|
|
201
|
+
},
|
|
202
|
+
ellipsis: true,
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
id: 'actions',
|
|
206
|
+
title: "",
|
|
207
|
+
width: 60,
|
|
208
|
+
render: (_, all) => {
|
|
209
|
+
if (all.empty) {
|
|
210
|
+
return <div className="daf-default-cell" />;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const link = `/app/view/${subject}/${all.datastakeId}`;
|
|
214
|
+
|
|
215
|
+
return <div style={{ display: "flex", justifyContent: "center" }}>
|
|
216
|
+
<a href={getRedirectLink(link)}>
|
|
217
|
+
<CustomIcon name="Link" size={15} color={theme.baseGray70} />
|
|
218
|
+
</a>
|
|
219
|
+
</div>;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
].filter((column) => column.show !== false);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useEffect} from 'react'
|
|
2
2
|
import { message } from 'antd';
|
|
3
|
-
import { MessageTypes } from '
|
|
4
|
-
import DynamicForm from '
|
|
3
|
+
import { MessageTypes } from '../../../../helpers/messages.js';
|
|
4
|
+
import DynamicForm from '../../../core/components/DynamicForm/index.jsx';
|
|
5
5
|
|
|
6
6
|
const StakeholdersCreate = ({
|
|
7
7
|
namespace = "corrective-actions",
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React, { useMemo, useState, useEffect, useCallback } from 'react'
|
|
2
|
-
import TablePageWithTabs from '
|
|
2
|
+
import TablePageWithTabs from '../../pages/TablePageWithTabs/index.jsx'
|
|
3
3
|
import { getColumns } from './columns.js';
|
|
4
4
|
import { checkboxConfig, getFiltersConfig, filtersConfig, getFilterOptions } from './config.js';
|
|
5
|
-
import { useGetQueryParams } from '
|
|
5
|
+
import { useGetQueryParams } from '../../../hooks/useGetQueryParams.js';
|
|
6
6
|
import StakeholdersCreate from './create.jsx';
|
|
7
|
-
import { displayMessage } from '
|
|
7
|
+
import { displayMessage } from '../../../../helpers/messages.js';
|
|
8
8
|
|
|
9
9
|
const ActivitiesTable = ({
|
|
10
10
|
t = () => {},
|
|
@@ -37,7 +37,7 @@ const ActivitiesTable = ({
|
|
|
37
37
|
applications = [],
|
|
38
38
|
}) => {
|
|
39
39
|
const [selectOptions, setSelectOptions] = useState();
|
|
40
|
-
const [activeTab, setActiveTab] = useState();
|
|
40
|
+
const [activeTab, setActiveTab] = useState("own");
|
|
41
41
|
|
|
42
42
|
const columns = useMemo(() => getColumns({
|
|
43
43
|
t,
|
|
@@ -47,7 +47,7 @@ const ActivitiesTable = ({
|
|
|
47
47
|
activeTab,
|
|
48
48
|
getRedirectLink,
|
|
49
49
|
theme,
|
|
50
|
-
subject: '
|
|
50
|
+
subject: 'correctiveActions',
|
|
51
51
|
data,
|
|
52
52
|
applications,
|
|
53
53
|
}), [t, goTo, user, options, activeTab, getRedirectLink, theme, data, applications]);
|
|
@@ -99,7 +99,7 @@ const ActivitiesTable = ({
|
|
|
99
99
|
location={location}
|
|
100
100
|
loading={loading}
|
|
101
101
|
goTo={goTo}
|
|
102
|
-
defaultActiveTab={"
|
|
102
|
+
defaultActiveTab={"own"}
|
|
103
103
|
columns={columns}
|
|
104
104
|
data={data}
|
|
105
105
|
checkboxConfig={checkboxConfig}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Tooltip, Tag } from 'antd';
|
|
3
|
-
import { findOptions } from '
|
|
4
|
-
import { renderDateFormatted } from '
|
|
5
|
-
import CustomIcon from '
|
|
6
|
-
import AvatarGroup from '
|
|
7
|
-
import sourceAvatarConfig from '
|
|
3
|
+
import { findOptions } from '../../../../helpers/StringHelper.js';
|
|
4
|
+
import { renderDateFormatted } from '../../../../helpers/Forms.js';
|
|
5
|
+
import CustomIcon from '../../../core/components/Icon/CustomIcon.jsx';
|
|
6
|
+
import AvatarGroup from '../../../core/components/AvatarGroup/index.jsx';
|
|
7
|
+
import sourceAvatarConfig from '../../../../helpers/sourceAvatarConfig.js';
|
|
8
8
|
|
|
9
9
|
const getLinkValue = (value, linkingObject) => {
|
|
10
10
|
if(linkingObject && linkingObject?.[value]) {
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import React, { useEffect} from 'react'
|
|
2
|
+
import { message } from 'antd';
|
|
3
|
+
import { MessageTypes } from '../../../../helpers/messages.js';
|
|
4
|
+
import DynamicForm from '../../../core/components/DynamicForm/index.jsx';
|
|
5
|
+
|
|
6
|
+
const StakeholdersCreate = ({
|
|
7
|
+
namespace = "incident",
|
|
8
|
+
view = "incident",
|
|
9
|
+
edit = false,
|
|
10
|
+
formData = {},
|
|
11
|
+
loading = false,
|
|
12
|
+
onSubmitted = () => {},
|
|
13
|
+
onCancel = () => {},
|
|
14
|
+
getData = () => {},
|
|
15
|
+
saveData = () => {},
|
|
16
|
+
form: formConfig = {},
|
|
17
|
+
formValue = {},
|
|
18
|
+
defaultData = {},
|
|
19
|
+
user = {},
|
|
20
|
+
APP,
|
|
21
|
+
query,
|
|
22
|
+
goTo = () => {},
|
|
23
|
+
t = () => {},
|
|
24
|
+
ajaxForms = {},
|
|
25
|
+
changeAjaxForms = () => {},
|
|
26
|
+
ajaxOptions = {},
|
|
27
|
+
changeAjaxOptions = () => {},
|
|
28
|
+
getAppHeader = () => {},
|
|
29
|
+
getApiBaseUrl = () => {},
|
|
30
|
+
}) => {
|
|
31
|
+
let {
|
|
32
|
+
form = {},
|
|
33
|
+
data = defaultData || {},
|
|
34
|
+
} = !edit ? (formData[`${APP}-${view}`] || {}) : {
|
|
35
|
+
form: formConfig,
|
|
36
|
+
data: formValue
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (Object.keys(form).length === 0 && !formData[`${APP}-${view}`]) {
|
|
41
|
+
if (!edit) {
|
|
42
|
+
getData({ namespace, module: APP, view, scope: 'createIncident' });
|
|
43
|
+
} else {
|
|
44
|
+
form = formConfig;
|
|
45
|
+
data = formValue;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}, [edit, user?.language]);
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<div className="daf-create-form">
|
|
52
|
+
<DynamicForm
|
|
53
|
+
form={form}
|
|
54
|
+
data={{...defaultData, ...data}}
|
|
55
|
+
showSaveAndNext={false}
|
|
56
|
+
module={APP}
|
|
57
|
+
onCancel={onCancel}
|
|
58
|
+
isCreate
|
|
59
|
+
t={t}
|
|
60
|
+
excludedKeys={["title"]}
|
|
61
|
+
user={user}
|
|
62
|
+
ajaxForms={ajaxForms}
|
|
63
|
+
ajaxOptions={ajaxOptions}
|
|
64
|
+
getAppHeader={getAppHeader}
|
|
65
|
+
getApiBaseUrl={getApiBaseUrl}
|
|
66
|
+
changeAjaxOptions={changeAjaxOptions}
|
|
67
|
+
app={APP}
|
|
68
|
+
query={query}
|
|
69
|
+
goTo={goTo}
|
|
70
|
+
changeAjaxForms={changeAjaxForms}
|
|
71
|
+
submit={(payload, setSelectedFormNext) => {
|
|
72
|
+
const payloadData = { ...payload, module: APP, namespace };
|
|
73
|
+
|
|
74
|
+
const newPayload = {
|
|
75
|
+
...defaultData,
|
|
76
|
+
...payloadData,
|
|
77
|
+
form: 'worker'
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const callback = (type, m, data) => {
|
|
81
|
+
if (setSelectedFormNext) {
|
|
82
|
+
setSelectedFormNext();
|
|
83
|
+
}
|
|
84
|
+
if (type === MessageTypes.SUCCESS) {
|
|
85
|
+
if (onSubmitted) onSubmitted(type, m, data);
|
|
86
|
+
} else {
|
|
87
|
+
message.error(m);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
saveData(
|
|
92
|
+
!data && !data.id ? newPayload : Object.assign(newPayload, { id: data.id }),
|
|
93
|
+
callback,
|
|
94
|
+
);
|
|
95
|
+
}}
|
|
96
|
+
isFormDisabled={() => {
|
|
97
|
+
return !data || !data.typeOfEvent;
|
|
98
|
+
}}
|
|
99
|
+
/>
|
|
100
|
+
</div>
|
|
101
|
+
)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export default StakeholdersCreate
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import React, { useMemo, useState, useEffect, useCallback } from 'react'
|
|
2
|
+
import TablePageWithTabs from '../../pages/TablePageWithTabs/index.jsx'
|
|
3
|
+
import { getColumns } from './columns.js';
|
|
4
|
+
import { checkboxConfig, getFiltersConfig, filtersConfig, getFilterOptions } from './config.js';
|
|
5
|
+
import { useGetQueryParams } from '../../../hooks/useGetQueryParams.js';
|
|
6
|
+
import StakeholdersCreate from './create.jsx';
|
|
7
|
+
import { displayMessage } from '../../../../helpers/messages.js';
|
|
8
|
+
|
|
9
|
+
const IncidentsTable = ({
|
|
10
|
+
t = () => {},
|
|
11
|
+
goTo = () => {},
|
|
12
|
+
user = {},
|
|
13
|
+
options = {},
|
|
14
|
+
getRedirectLink = () => {},
|
|
15
|
+
theme = {},
|
|
16
|
+
loading = false,
|
|
17
|
+
data = {},
|
|
18
|
+
isMobile,
|
|
19
|
+
APP,
|
|
20
|
+
location,
|
|
21
|
+
getData = () => {},
|
|
22
|
+
getApiBaseUrl = () => {},
|
|
23
|
+
getAppHeader = () => {},
|
|
24
|
+
getFormData = () => {},
|
|
25
|
+
saveFormData = () => {},
|
|
26
|
+
formLoading = false,
|
|
27
|
+
query = {},
|
|
28
|
+
ajaxForms = {},
|
|
29
|
+
changeAjaxForms = () => {},
|
|
30
|
+
ajaxOptions = {},
|
|
31
|
+
changeAjaxOptions = () => {},
|
|
32
|
+
formData = {},
|
|
33
|
+
formValue = {},
|
|
34
|
+
form = {},
|
|
35
|
+
extendingFilters = {},
|
|
36
|
+
createDefaultValues = {},
|
|
37
|
+
applications = [],
|
|
38
|
+
}) => {
|
|
39
|
+
const [selectOptions, setSelectOptions] = useState();
|
|
40
|
+
const [activeTab, setActiveTab] = useState("own");
|
|
41
|
+
|
|
42
|
+
const columns = useMemo(() => getColumns({
|
|
43
|
+
t,
|
|
44
|
+
goTo,
|
|
45
|
+
user,
|
|
46
|
+
options,
|
|
47
|
+
activeTab,
|
|
48
|
+
getRedirectLink,
|
|
49
|
+
theme,
|
|
50
|
+
subject: 'incidents',
|
|
51
|
+
data,
|
|
52
|
+
applications,
|
|
53
|
+
}), [t, goTo, user, options, activeTab, getRedirectLink, theme, data, applications]);
|
|
54
|
+
|
|
55
|
+
const breadCrumbs = [];
|
|
56
|
+
|
|
57
|
+
const { paginationQuery, searchParams, otherParams, sortBy, sortDir } = useGetQueryParams({location});
|
|
58
|
+
|
|
59
|
+
const filters = useMemo(() => {
|
|
60
|
+
return {
|
|
61
|
+
...otherParams,
|
|
62
|
+
...extendingFilters
|
|
63
|
+
}
|
|
64
|
+
}, [otherParams, extendingFilters])
|
|
65
|
+
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
getData({
|
|
68
|
+
pagination: paginationQuery,
|
|
69
|
+
...(Object.keys(searchParams).length > 0 && { search: searchParams }),
|
|
70
|
+
...otherParams,
|
|
71
|
+
tab: activeTab,
|
|
72
|
+
sortBy: {
|
|
73
|
+
[sortBy || "updatedAt"]: sortDir ? (sortDir === "ascend" ? 1 : -1) : -1,
|
|
74
|
+
},
|
|
75
|
+
...extendingFilters
|
|
76
|
+
}, 'incidents')
|
|
77
|
+
}, [location.search, activeTab, JSON.stringify(extendingFilters)]);
|
|
78
|
+
|
|
79
|
+
const selectFiltersConfig = useMemo(() => {
|
|
80
|
+
return getFiltersConfig({t});
|
|
81
|
+
}, [t]);
|
|
82
|
+
|
|
83
|
+
useEffect(() => {
|
|
84
|
+
setSelectOptions((prev) => ({
|
|
85
|
+
...prev,
|
|
86
|
+
...getFilterOptions(options, t),
|
|
87
|
+
}))
|
|
88
|
+
}, [options, t])
|
|
89
|
+
|
|
90
|
+
const handleActiveTabChange = useCallback((value) => {
|
|
91
|
+
setActiveTab(value);
|
|
92
|
+
}, []);
|
|
93
|
+
|
|
94
|
+
return (
|
|
95
|
+
<TablePageWithTabs
|
|
96
|
+
t={t}
|
|
97
|
+
title={t("Incidents")}
|
|
98
|
+
breadCrumbs={breadCrumbs}
|
|
99
|
+
location={location}
|
|
100
|
+
loading={loading}
|
|
101
|
+
goTo={goTo}
|
|
102
|
+
defaultActiveTab={"own"}
|
|
103
|
+
columns={columns}
|
|
104
|
+
data={data}
|
|
105
|
+
checkboxConfig={checkboxConfig}
|
|
106
|
+
APP={APP}
|
|
107
|
+
getApiBaseUrl={getApiBaseUrl}
|
|
108
|
+
selectOptions={selectOptions}
|
|
109
|
+
selectFiltersConfig={selectFiltersConfig}
|
|
110
|
+
getRedirectLink={getRedirectLink}
|
|
111
|
+
filtersConfig={filtersConfig}
|
|
112
|
+
isMobile={isMobile}
|
|
113
|
+
view="incidents"
|
|
114
|
+
getActiveTab={handleActiveTabChange}
|
|
115
|
+
onDownload={() => {
|
|
116
|
+
console.log("download");
|
|
117
|
+
}}
|
|
118
|
+
drawerTitle={t("Create Incidents")}
|
|
119
|
+
>
|
|
120
|
+
{({onDrawerClose}) => (
|
|
121
|
+
<StakeholdersCreate
|
|
122
|
+
defaultData={createDefaultValues}
|
|
123
|
+
t={t}
|
|
124
|
+
goTo={goTo}
|
|
125
|
+
user={user}
|
|
126
|
+
APP={APP}
|
|
127
|
+
getApiBaseUrl={getApiBaseUrl}
|
|
128
|
+
getAppHeader={getAppHeader}
|
|
129
|
+
getData={getFormData}
|
|
130
|
+
saveData={saveFormData}
|
|
131
|
+
loading={formLoading}
|
|
132
|
+
onSubmitted={(type, m, data) => {
|
|
133
|
+
if (data.datastakeId) {
|
|
134
|
+
displayMessage(
|
|
135
|
+
type,
|
|
136
|
+
t("affirmations::subject-created-successfully") || m,
|
|
137
|
+
);
|
|
138
|
+
// goTo(`/app/edit/stakeholders/${data.datastakeId}`);
|
|
139
|
+
goTo(`/app/edit/incidents/${data.datastakeId}`)
|
|
140
|
+
}
|
|
141
|
+
}}
|
|
142
|
+
onCancel={onDrawerClose}
|
|
143
|
+
query={query}
|
|
144
|
+
ajaxForms={ajaxForms}
|
|
145
|
+
changeAjaxForms={changeAjaxForms}
|
|
146
|
+
ajaxOptions={ajaxOptions}
|
|
147
|
+
changeAjaxOptions={changeAjaxOptions}
|
|
148
|
+
formData={formData}
|
|
149
|
+
formValue={formValue}
|
|
150
|
+
form={form}
|
|
151
|
+
/>
|
|
152
|
+
)}
|
|
153
|
+
</TablePageWithTabs>
|
|
154
|
+
)
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export default IncidentsTable
|