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,226 @@
|
|
|
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 CustomIcon from '../../core/components/';
|
|
7
|
+
import AvatarGroup from '../../core/components/AvatarGroup/index.jsx';
|
|
8
|
+
import sourceAvatarConfig from '../../../helpers/sourceAvatarConfig.js';
|
|
9
|
+
import MoreTags from '../../core/components/Table/MoreTags/index.jsx';
|
|
10
|
+
|
|
11
|
+
const getLinkValue = (value, linkingObject) => {
|
|
12
|
+
if (linkingObject && linkingObject?.[value]) {
|
|
13
|
+
return linkingObject?.[value]?.name;
|
|
14
|
+
}
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const renderEventStatusTag = ({ value, t = (s) => s }) => {
|
|
19
|
+
const width = 87;
|
|
20
|
+
|
|
21
|
+
switch (value) {
|
|
22
|
+
case "edited":
|
|
23
|
+
return (
|
|
24
|
+
<Tag color="orange" style={{ width }} className="text-center">
|
|
25
|
+
{t("Edited")}
|
|
26
|
+
</Tag>
|
|
27
|
+
);
|
|
28
|
+
case "submitted":
|
|
29
|
+
return (
|
|
30
|
+
<Tag color="green" style={{ width }} className="text-center">
|
|
31
|
+
{t("Submitted")}
|
|
32
|
+
</Tag>
|
|
33
|
+
);
|
|
34
|
+
default:
|
|
35
|
+
return (
|
|
36
|
+
<Tag color="blue" style={{ width }} className="text-center">
|
|
37
|
+
{t("Private")}
|
|
38
|
+
</Tag>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const getColumns = ({ t, goTo, user, options, activeTab, getRedirectLink, theme, subject, data, applications }) => [
|
|
44
|
+
{
|
|
45
|
+
dataIndex: 'datastakeId',
|
|
46
|
+
title: t('ID'),
|
|
47
|
+
ellipsis: true,
|
|
48
|
+
show: true,
|
|
49
|
+
render: (v, all) => {
|
|
50
|
+
if (all.empty) {
|
|
51
|
+
return <div className="daf-default-cell" />
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return <Tooltip title={v}>{v}</Tooltip>;
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
dataIndex: 'name',
|
|
59
|
+
title: t('Title'),
|
|
60
|
+
ellipsis: true,
|
|
61
|
+
show: true,
|
|
62
|
+
render: (v, all) => {
|
|
63
|
+
if (all.empty) {
|
|
64
|
+
return <div className="daf-default-cell" />
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return <Tooltip title={v}>{v}</Tooltip>;
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
dataIndex: 'typeOfEvent',
|
|
72
|
+
title: t('Type'),
|
|
73
|
+
ellipsis: true,
|
|
74
|
+
show: true,
|
|
75
|
+
render: (v, all) => {
|
|
76
|
+
if (all.empty) {
|
|
77
|
+
return <div className="daf-default-cell" />
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const type = findOptions(v, data?.options?.eventsType);
|
|
81
|
+
|
|
82
|
+
return type ? <Tooltip title={type}>{type}</Tooltip> : '-';
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
dataIndex: 'keyStakeholder',
|
|
87
|
+
title: t('Key Stakeholder'),
|
|
88
|
+
ellipsis: true,
|
|
89
|
+
show: true,
|
|
90
|
+
render: (v, all) => {
|
|
91
|
+
if (all.empty) {
|
|
92
|
+
return <div className="daf-default-cell" />
|
|
93
|
+
}
|
|
94
|
+
const val = (all?.stakeholderKey || []).map((sk) => {
|
|
95
|
+
return sk?.name;
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
if (val?.length === 0) {
|
|
99
|
+
return "--";
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return <MoreTags values={val} />;
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
title: t("Date"),
|
|
107
|
+
dataIndex: "date",
|
|
108
|
+
key: "date",
|
|
109
|
+
testimonials: true,
|
|
110
|
+
incident: true,
|
|
111
|
+
correctiveActions: true,
|
|
112
|
+
show: true,
|
|
113
|
+
sorter: () => 0 + 0,
|
|
114
|
+
searchType: "date",
|
|
115
|
+
width: 125,
|
|
116
|
+
render: (date, all) => {
|
|
117
|
+
if (all.empty) {
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const title = date ? renderDateFormatted(date, "DD MMM YYYY") : "--";
|
|
122
|
+
return <Tooltip title={title}>{title}</Tooltip>;
|
|
123
|
+
},
|
|
124
|
+
ellipsis: true,
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
dataIndex: 'scope',
|
|
128
|
+
title: t('Scope'),
|
|
129
|
+
ellipsis: true,
|
|
130
|
+
show: true,
|
|
131
|
+
render: (value, all) => {
|
|
132
|
+
if (all.empty) {
|
|
133
|
+
return <div className="daf-default-cell" />;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (!value) {
|
|
137
|
+
return "--";
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Form the moment the intend of the if block is to be executed only in event table
|
|
141
|
+
if (typeof value === "string") {
|
|
142
|
+
if (all.navigationEventType === "other") {
|
|
143
|
+
return "--";
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const categoryOptions = (data?.options?.categoryOptions || []).map((c) => {
|
|
147
|
+
const searchTerm = `typeOfEvent is ${all.navigationEventType}`;
|
|
148
|
+
|
|
149
|
+
return {
|
|
150
|
+
value: c.value,
|
|
151
|
+
label: c.label[searchTerm],
|
|
152
|
+
};
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
const relaxantOptions = [
|
|
156
|
+
...categoryOptions,
|
|
157
|
+
...(data?.options?.eventsType || []),
|
|
158
|
+
...(data?.options?.testimonialsType || []),
|
|
159
|
+
];
|
|
160
|
+
|
|
161
|
+
const title = relaxantOptions.find((v) => v.value === value)?.label || "--";
|
|
162
|
+
|
|
163
|
+
return <Tooltip title={title}>{title}</Tooltip>;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const val = value.map((v, i) => ({ label: v.name, value: `${v.name}-${i}` }));
|
|
167
|
+
return val.length ? <MoreTags values={val} /> : "--";
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
title: t("Sources"),
|
|
172
|
+
dataIndex: "sources",
|
|
173
|
+
key: "sources",
|
|
174
|
+
show: activeTab !== "own",
|
|
175
|
+
render: (val, all) => {
|
|
176
|
+
if (all.empty) {
|
|
177
|
+
return <div className="daf-default-cell" />;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const sources = sourceAvatarConfig(val, user, applications);
|
|
181
|
+
|
|
182
|
+
return <AvatarGroup items={sources}></AvatarGroup>;
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
title: t("Status"),
|
|
187
|
+
dataIndex: "status",
|
|
188
|
+
key: "status",
|
|
189
|
+
show: activeTab === "own",
|
|
190
|
+
correctiveActions: activeTab === "own",
|
|
191
|
+
testimonials: activeTab === "own",
|
|
192
|
+
incident: activeTab === "own",
|
|
193
|
+
width: 120,
|
|
194
|
+
render: (value, all) => {
|
|
195
|
+
if (all.empty) {
|
|
196
|
+
return <div className="daf-default-cell" />;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
if (activeTab !== "own") {
|
|
200
|
+
return all?.authorId?.name;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const _val = all?.published || all?.status === "submitted" ? "submitted" : value;
|
|
204
|
+
return renderEventStatusTag({ value: _val, t });
|
|
205
|
+
},
|
|
206
|
+
ellipsis: true,
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
id: 'actions',
|
|
210
|
+
title: "",
|
|
211
|
+
width: 60,
|
|
212
|
+
render: (_, all) => {
|
|
213
|
+
if (all.empty) {
|
|
214
|
+
return <div className="daf-default-cell" />;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const link = `/app/view/${subject}/${all.datastakeId}`;
|
|
218
|
+
|
|
219
|
+
return <div style={{ display: "flex", justifyContent: "center" }}>
|
|
220
|
+
<a href={getRedirectLink(link)}>
|
|
221
|
+
<CustomIcon name="Link" size={15} color={theme.baseGray70} />
|
|
222
|
+
</a>
|
|
223
|
+
</div>;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
].filter((column) => column.show !== false);
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
export const checkboxConfig = {
|
|
2
|
+
name: 'Name',
|
|
3
|
+
datastakeId: 'ID'
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export const getFiltersConfig = ({t}) => {
|
|
7
|
+
return {
|
|
8
|
+
|
|
9
|
+
timeframe: {
|
|
10
|
+
type: "timeframe",
|
|
11
|
+
label: "Timeframe",
|
|
12
|
+
style: { flex: 1 },
|
|
13
|
+
},
|
|
14
|
+
country: {
|
|
15
|
+
type: 'select',
|
|
16
|
+
label: 'Country',
|
|
17
|
+
placeholder: (t) => `${t('Filter by')} ${t('Country').toLowerCase()}`,
|
|
18
|
+
style: { flex: 1 },
|
|
19
|
+
labelStyle: { flex: 1 },
|
|
20
|
+
getLabel: (option) => option.label,
|
|
21
|
+
getValue: (option) => option.value,
|
|
22
|
+
},
|
|
23
|
+
administrativeLevel1: {
|
|
24
|
+
type: 'ajaxSelect',
|
|
25
|
+
label: ({ t = (s) => s, options = {}, filters = {}, language = 'en' }) => {
|
|
26
|
+
const { administrativeLevel1 } = options;
|
|
27
|
+
|
|
28
|
+
if (administrativeLevel1) {
|
|
29
|
+
if (options.country) {
|
|
30
|
+
const _item = administrativeLevel1[filters.country];
|
|
31
|
+
if (_item) {
|
|
32
|
+
if (_item[language]) {
|
|
33
|
+
return _item[language]
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return t('Province');
|
|
40
|
+
},
|
|
41
|
+
placeholder: (t) => `${t('Filter by')} ${t('Province').toLowerCase()}`,
|
|
42
|
+
filters: (data) => ({
|
|
43
|
+
country: data.country,
|
|
44
|
+
level: 'level_1',
|
|
45
|
+
}),
|
|
46
|
+
show: (data) => !data.country,
|
|
47
|
+
disabled: (data) => !data.country,
|
|
48
|
+
mapper: { label: "name", value: "id" },
|
|
49
|
+
method: 'getOptions',
|
|
50
|
+
entity: 'AdministrativeLevel',
|
|
51
|
+
style: { flex: 1 },
|
|
52
|
+
labelStyle: { flex: 1 },
|
|
53
|
+
},
|
|
54
|
+
administrativeLevel2: {
|
|
55
|
+
type: 'ajaxSelect',
|
|
56
|
+
label: ({ t = (s) => s, options = {}, filters = {}, language = 'en' }) => {
|
|
57
|
+
const { administrativeLevel2 } = options;
|
|
58
|
+
|
|
59
|
+
if (administrativeLevel2) {
|
|
60
|
+
if (options.country) {
|
|
61
|
+
const _item = administrativeLevel2[filters.country];
|
|
62
|
+
if (_item) {
|
|
63
|
+
if (_item[language]) {
|
|
64
|
+
return _item[language]
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return t('Province');
|
|
71
|
+
},
|
|
72
|
+
show: (data) => !(data.country && data.administrativeLevel1),
|
|
73
|
+
placeholder: (t) => `${t('Filter by')} ${t('Territory').toLowerCase()}`,
|
|
74
|
+
filters: (data) => ({
|
|
75
|
+
country: data.country,
|
|
76
|
+
level: 'level_2',
|
|
77
|
+
administrativeLevel1: data.administrativeLevel1,
|
|
78
|
+
}),
|
|
79
|
+
disabled: (data) => !(data.country && data.administrativeLevel1),
|
|
80
|
+
mapper: { label: "name", value: "id" },
|
|
81
|
+
method: 'getOptions',
|
|
82
|
+
entity: 'AdministrativeLevel',
|
|
83
|
+
style: { flex: 1 },
|
|
84
|
+
labelStyle: { flex: 1 },
|
|
85
|
+
},
|
|
86
|
+
subCategory: {
|
|
87
|
+
type: 'select',
|
|
88
|
+
label: 'Category',
|
|
89
|
+
placeholder: (t) => `${t('Filter by')} ${t('Category').toLowerCase()}`,
|
|
90
|
+
style: { flex: 1 },
|
|
91
|
+
labelStyle: { flex: 1 },
|
|
92
|
+
getLabel: (option) => option.label,
|
|
93
|
+
getValue: (option) => option.value,
|
|
94
|
+
filterOptions: (val) => {
|
|
95
|
+
if (val) {
|
|
96
|
+
const { option, filters } = val
|
|
97
|
+
if (filters && option) {
|
|
98
|
+
const { filters: optionFilters } = option;
|
|
99
|
+
if (Array.isArray(optionFilters) && optionFilters.length) {
|
|
100
|
+
const { value, condition } = optionFilters[0];
|
|
101
|
+
if (condition === 'includes') {
|
|
102
|
+
return value.includes('corporation');
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return true;
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
positionInTheMineralSupplyChain: {
|
|
111
|
+
type: 'select',
|
|
112
|
+
label: 'Position',
|
|
113
|
+
placeholder: (t) => `${t('Filter by')} ${t('Position').toLowerCase()}`,
|
|
114
|
+
style: { flex: 1 },
|
|
115
|
+
labelStyle: { flex: 1 },
|
|
116
|
+
getLabel: (option) => option.label,
|
|
117
|
+
getValue: (option) => option.value,
|
|
118
|
+
},
|
|
119
|
+
status: {
|
|
120
|
+
type: "select",
|
|
121
|
+
label: "Status",
|
|
122
|
+
placeholder: (t) => `${t("Filter by")} ${t("Status").toLowerCase()}`,
|
|
123
|
+
style: { flex: 1 },
|
|
124
|
+
labelStyle: { fley: 1 },
|
|
125
|
+
getLabel: (option) => option.label,
|
|
126
|
+
getValue: (option) => option.value,
|
|
127
|
+
},
|
|
128
|
+
category:{
|
|
129
|
+
type: 'select',
|
|
130
|
+
label: 'Category',
|
|
131
|
+
placeholder: (t) => `${t('Filter by')} ${t('Category').toLowerCase()}`,
|
|
132
|
+
style: { flex: 1 },
|
|
133
|
+
labelStyle: { flex: 1 },
|
|
134
|
+
getLabel: (option) => option.label,
|
|
135
|
+
getValue: (option) => option.value,
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export const filtersConfig = {
|
|
141
|
+
name: '',
|
|
142
|
+
datastakeId: '',
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
export const getFilterOptions = (options, t) => {
|
|
146
|
+
const {
|
|
147
|
+
timeframe = [],
|
|
148
|
+
statusOptions = [],
|
|
149
|
+
categoryOptions = [],
|
|
150
|
+
countries = [],
|
|
151
|
+
subCategory = [],
|
|
152
|
+
subCategoriesOptions,
|
|
153
|
+
stakeholderCategoryOptions,
|
|
154
|
+
stakeholderSubCategoriesOptions,
|
|
155
|
+
administrativeLevel1,
|
|
156
|
+
administrativeLevel2,
|
|
157
|
+
category=[],
|
|
158
|
+
} = options || {};
|
|
159
|
+
console.log({options})
|
|
160
|
+
|
|
161
|
+
const _default = {
|
|
162
|
+
timeframe: timeframe,
|
|
163
|
+
country: countries,
|
|
164
|
+
|
|
165
|
+
category: stakeholderCategoryOptions || categoryOptions,
|
|
166
|
+
administrativeLevel1,
|
|
167
|
+
administrativeLevel2,
|
|
168
|
+
// subCategory: subCategoriesOptions,
|
|
169
|
+
category: category,
|
|
170
|
+
status: [
|
|
171
|
+
{
|
|
172
|
+
value: "submitted",
|
|
173
|
+
label: "Submitted",
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
value: "private",
|
|
177
|
+
label: "Private",
|
|
178
|
+
},
|
|
179
|
+
],
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return _default;
|
|
183
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
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 EventsCreate = ({
|
|
7
|
-
namespace = '
|
|
7
|
+
namespace = 'event',
|
|
8
8
|
view = 'scoping',
|
|
9
9
|
edit = false,
|
|
10
10
|
formData = {},
|
|
@@ -39,7 +39,7 @@ const EventsCreate = ({
|
|
|
39
39
|
useEffect(() => {
|
|
40
40
|
if (Object.keys(form).length === 0 && !formData[`${APP}-${view}`]) {
|
|
41
41
|
if (!edit) {
|
|
42
|
-
getData({ namespace, module: APP, view, scope: '
|
|
42
|
+
getData({ namespace, module: APP, view, scope: 'create' });
|
|
43
43
|
} else {
|
|
44
44
|
form = formConfig;
|
|
45
45
|
data = formValue;
|
|
@@ -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 EventsCreate from './create.jsx';
|
|
7
|
-
import { displayMessage } from '
|
|
7
|
+
import { displayMessage } from '../../../helpers/messages.js';
|
|
8
8
|
|
|
9
9
|
const EventsTable = ({
|
|
10
10
|
t = () => {},
|
|
@@ -34,9 +34,10 @@ const EventsTable = ({
|
|
|
34
34
|
form = {},
|
|
35
35
|
extendingFilters = {},
|
|
36
36
|
applications = [],
|
|
37
|
+
subjectClear = () => {},
|
|
37
38
|
}) => {
|
|
38
39
|
const [selectOptions, setSelectOptions] = useState();
|
|
39
|
-
const [activeTab, setActiveTab] = useState();
|
|
40
|
+
const [activeTab, setActiveTab] = useState("own");
|
|
40
41
|
|
|
41
42
|
const columns = useMemo(() => getColumns({
|
|
42
43
|
t,
|
|
@@ -63,7 +64,6 @@ const EventsTable = ({
|
|
|
63
64
|
}, [otherParams, extendingFilters])
|
|
64
65
|
|
|
65
66
|
useEffect(() => {
|
|
66
|
-
console.log("fetching data")
|
|
67
67
|
getData({
|
|
68
68
|
pagination: paginationQuery,
|
|
69
69
|
...(Object.keys(filters).length > 0 && { filters: filters }),
|
|
@@ -73,11 +73,8 @@ const EventsTable = ({
|
|
|
73
73
|
[sortBy || "updatedAt"]: sortDir ? (sortDir === "ascend" ? 1 : -1) : -1,
|
|
74
74
|
}
|
|
75
75
|
}, 'events')
|
|
76
|
-
console.log("data fetched")
|
|
77
76
|
}, [location.search, activeTab, JSON.stringify(extendingFilters)]);
|
|
78
77
|
|
|
79
|
-
console.log({data})
|
|
80
|
-
|
|
81
78
|
const selectFiltersConfig = useMemo(() => {
|
|
82
79
|
return getFiltersConfig({t});
|
|
83
80
|
}, [t]);
|
|
@@ -93,6 +90,13 @@ const EventsTable = ({
|
|
|
93
90
|
setActiveTab(value);
|
|
94
91
|
}, []);
|
|
95
92
|
|
|
93
|
+
useEffect(
|
|
94
|
+
() => () => {
|
|
95
|
+
subjectClear();
|
|
96
|
+
},
|
|
97
|
+
[],
|
|
98
|
+
);
|
|
99
|
+
|
|
96
100
|
return (
|
|
97
101
|
<TablePageWithTabs
|
|
98
102
|
t={t}
|
|
@@ -101,7 +105,7 @@ const EventsTable = ({
|
|
|
101
105
|
location={location}
|
|
102
106
|
loading={loading}
|
|
103
107
|
goTo={goTo}
|
|
104
|
-
defaultActiveTab={"
|
|
108
|
+
defaultActiveTab={"own"}
|
|
105
109
|
columns={columns}
|
|
106
110
|
data={data}
|
|
107
111
|
checkboxConfig={checkboxConfig}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Tooltip } from 'antd';
|
|
3
|
-
import { findOptions } from '
|
|
4
|
-
import { renderDateFormatted } from '
|
|
5
|
-
import CustomIcon from '
|
|
6
|
-
import AvatarGroup from '
|
|
7
|
-
import sourceAvatarConfig from '../../../../../helpers/sourceAvatarConfig.js';
|
|
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';
|
|
8
7
|
|
|
9
8
|
const getLinkValue = (value, linkingObject) => {
|
|
10
9
|
if(linkingObject && linkingObject?.[value]) {
|
|
@@ -13,7 +12,7 @@ const getLinkValue = (value, linkingObject) => {
|
|
|
13
12
|
return null;
|
|
14
13
|
}
|
|
15
14
|
|
|
16
|
-
export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink, theme, subject, data
|
|
15
|
+
export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink, theme, subject, data}) => [
|
|
17
16
|
{
|
|
18
17
|
dataIndex: 'datastakeId',
|
|
19
18
|
title: t('ID'),
|
|
@@ -39,10 +38,10 @@ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink,
|
|
|
39
38
|
|
|
40
39
|
return <Tooltip title={v}>{v}</Tooltip>;
|
|
41
40
|
},
|
|
42
|
-
},
|
|
41
|
+
},
|
|
43
42
|
{
|
|
44
|
-
dataIndex: '
|
|
45
|
-
title: t('
|
|
43
|
+
dataIndex: 'province',
|
|
44
|
+
title: t('Province'),
|
|
46
45
|
ellipsis: true,
|
|
47
46
|
show: true,
|
|
48
47
|
render: (v, all) => {
|
|
@@ -50,14 +49,16 @@ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink,
|
|
|
50
49
|
return <div className="daf-default-cell" />
|
|
51
50
|
}
|
|
52
51
|
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
return
|
|
52
|
+
const region = getLinkValue(all?.location?.administrativeLevel1, all?.location?.linking?.SCL);
|
|
53
|
+
|
|
54
|
+
return region ? <Tooltip title={region}>{region}</Tooltip> : '-';
|
|
56
55
|
},
|
|
57
|
-
},
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
|
|
58
59
|
{
|
|
59
|
-
dataIndex: '
|
|
60
|
-
title: t('
|
|
60
|
+
dataIndex: 'territory',
|
|
61
|
+
title: t('Territory'),
|
|
61
62
|
ellipsis: true,
|
|
62
63
|
show: true,
|
|
63
64
|
render: (v, all) => {
|
|
@@ -65,14 +66,29 @@ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink,
|
|
|
65
66
|
return <div className="daf-default-cell" />
|
|
66
67
|
}
|
|
67
68
|
|
|
68
|
-
const
|
|
69
|
+
const district = getLinkValue(all?.location?.administrativeLevel2, all?.location?.linking?.SCL);
|
|
69
70
|
|
|
70
|
-
return
|
|
71
|
+
return district ? <Tooltip title={district}>{district}</Tooltip> : '-';
|
|
71
72
|
},
|
|
72
|
-
},
|
|
73
|
+
},
|
|
73
74
|
{
|
|
74
|
-
|
|
75
|
-
|
|
75
|
+
title: t("Products"),
|
|
76
|
+
dataIndex: "products",
|
|
77
|
+
key: "products",
|
|
78
|
+
show: activeTab !== "own",
|
|
79
|
+
render: (val, all) => {
|
|
80
|
+
if (all.empty) {
|
|
81
|
+
return <div className="daf-default-cell" />;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
console.log({val, all})
|
|
85
|
+
|
|
86
|
+
return <AvatarGroup items={val}></AvatarGroup>;
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
, {
|
|
90
|
+
dataIndex: 'operator',
|
|
91
|
+
title: t('Operator'),
|
|
76
92
|
ellipsis: true,
|
|
77
93
|
show: true,
|
|
78
94
|
render: (v, all) => {
|
|
@@ -80,30 +96,15 @@ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink,
|
|
|
80
96
|
return <div className="daf-default-cell" />
|
|
81
97
|
}
|
|
82
98
|
|
|
83
|
-
const
|
|
99
|
+
const operator = getLinkValue(all?.operator, all?.linking?.SCL);
|
|
84
100
|
|
|
85
|
-
return
|
|
101
|
+
return operator ? <Tooltip title={operator}>{operator}</Tooltip> : '-';
|
|
86
102
|
},
|
|
87
|
-
},
|
|
103
|
+
},
|
|
88
104
|
{
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
width: 125,
|
|
93
|
-
render: (date, all) => {
|
|
94
|
-
if (all.empty) {
|
|
95
|
-
return <div className="daf-default-cell" />;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
const _date = date ? renderDateFormatted(date, "DD MMM YYYY", user?.language || 'en') : "-";
|
|
99
|
-
return <Tooltip title={_date}>{_date}</Tooltip>;
|
|
100
|
-
},
|
|
101
|
-
ellipsis: true,
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
title: t("End Date"),
|
|
105
|
-
dataIndex: "endDate",
|
|
106
|
-
key: "endDate",
|
|
105
|
+
title: t("Last Update"),
|
|
106
|
+
dataIndex: "updatedAt",
|
|
107
|
+
key: "updatedAt",
|
|
107
108
|
width: 125,
|
|
108
109
|
render: (date, all) => {
|
|
109
110
|
if (all.empty) {
|
|
@@ -116,18 +117,16 @@ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink,
|
|
|
116
117
|
ellipsis: true,
|
|
117
118
|
},
|
|
118
119
|
{
|
|
119
|
-
title: t("
|
|
120
|
-
dataIndex:
|
|
121
|
-
|
|
122
|
-
show: activeTab
|
|
123
|
-
render: (
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
return <AvatarGroup items={sources}></AvatarGroup>;
|
|
120
|
+
title: t("Status"),
|
|
121
|
+
dataIndex: 'status',
|
|
122
|
+
ellipsis: true,
|
|
123
|
+
show: activeTab == "own",
|
|
124
|
+
render: (v, all) => {
|
|
125
|
+
if (all.empty) {
|
|
126
|
+
return <div className="daf-default-cell" />
|
|
127
|
+
}
|
|
128
|
+
const status = findOptions(v, data?.options?.statusOptions);
|
|
129
|
+
return status ? <Tooltip title={status}>{status}</Tooltip> : '-';
|
|
131
130
|
},
|
|
132
131
|
},
|
|
133
132
|
{
|