datastake-daf 0.6.741 → 0.6.743
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/pages/index.js +1539 -126
- package/dist/services/index.js +1 -1
- package/package.json +1 -1
- package/src/@daf/pages/dashboards/AllInformation/Documents/columns.js +4 -3
- package/src/@daf/pages/dashboards/AllInformation/Documents/index.jsx +3 -1
- package/src/@daf/pages/dashboards/AllInformation/Events/columns.js +4 -3
- package/src/@daf/pages/dashboards/AllInformation/Events/index.jsx +3 -1
- package/src/@daf/pages/dashboards/AllInformation/Locations/columns.js +4 -3
- package/src/@daf/pages/dashboards/AllInformation/Locations/index.jsx +3 -1
- package/src/@daf/pages/dashboards/AllInformation/Stakeholders/columns.js +5 -2
- package/src/@daf/pages/dashboards/AllInformation/Stakeholders/index.jsx +4 -2
- package/src/@daf/pages/dashboards/DueDilligence/Activities/columns.js +221 -0
- package/src/@daf/pages/dashboards/DueDilligence/Activities/config.js +166 -0
- package/src/@daf/pages/dashboards/DueDilligence/Activities/create.jsx +104 -0
- package/src/@daf/pages/dashboards/DueDilligence/Activities/index.jsx +157 -0
- package/src/@daf/pages/dashboards/Operations/Operators/columns.js +17 -16
- package/src/@daf/pages/dashboards/Operations/Operators/config.js +0 -1
- package/src/@daf/pages/dashboards/Operations/Operators/index.jsx +3 -1
- package/src/@daf/pages/dashboards/Operations/Workers/columns.js +176 -0
- package/src/@daf/pages/dashboards/Operations/Workers/config.js +166 -0
- package/src/@daf/pages/dashboards/Operations/Workers/create.jsx +104 -0
- package/src/@daf/pages/dashboards/Operations/Workers/index.jsx +157 -0
- package/src/@daf/pages/pages/TablePageWithTabs/index.jsx +1 -1
- package/src/@daf/services/OperatorService.js +1 -1
- package/src/helpers/sourceAvatarConfig.js +37 -0
- package/src/pages.js +3 -0
package/dist/services/index.js
CHANGED
|
@@ -1502,7 +1502,7 @@ class OperatorService extends BaseService {
|
|
|
1502
1502
|
data: data
|
|
1503
1503
|
});
|
|
1504
1504
|
}
|
|
1505
|
-
getOptions(id = "
|
|
1505
|
+
getOptions(id = "positionSupplyChainOptions,subCategoriesOptions,categoriesOptions,countries") {
|
|
1506
1506
|
return this.apiGet({
|
|
1507
1507
|
isApp: true,
|
|
1508
1508
|
url: `/forms/options`,
|
package/package.json
CHANGED
|
@@ -4,6 +4,7 @@ import { findOptions } from '../../../../../helpers/StringHelper.js';
|
|
|
4
4
|
import { renderDateFormatted } from '../../../../../helpers/Forms.js';
|
|
5
5
|
import CustomIcon from '../../../../core/components/Icon/CustomIcon.jsx';
|
|
6
6
|
import AvatarGroup from '../../../../core/components/AvatarGroup/index.jsx';
|
|
7
|
+
import sourceAvatarConfig from '../../../../../helpers/sourceAvatarConfig.js';
|
|
7
8
|
|
|
8
9
|
const getLinkValue = (value, linkingObject) => {
|
|
9
10
|
if(linkingObject && linkingObject?.[value]) {
|
|
@@ -12,7 +13,7 @@ const getLinkValue = (value, linkingObject) => {
|
|
|
12
13
|
return null;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
|
-
export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink, theme, subject, data}) => [
|
|
16
|
+
export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink, theme, subject, data, applications}) => [
|
|
16
17
|
{
|
|
17
18
|
dataIndex: 'datastakeId',
|
|
18
19
|
title: t('ID'),
|
|
@@ -80,9 +81,9 @@ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink,
|
|
|
80
81
|
return <div className="daf-default-cell" />;
|
|
81
82
|
}
|
|
82
83
|
|
|
83
|
-
|
|
84
|
+
const sources = sourceAvatarConfig(val, user, applications);
|
|
84
85
|
|
|
85
|
-
return <AvatarGroup items={
|
|
86
|
+
return <AvatarGroup items={sources}></AvatarGroup>;
|
|
86
87
|
},
|
|
87
88
|
},
|
|
88
89
|
{
|
|
@@ -33,6 +33,7 @@ const DocumentsTable = ({
|
|
|
33
33
|
formValue = {},
|
|
34
34
|
form = {},
|
|
35
35
|
extendingFilters = {},
|
|
36
|
+
applications = [],
|
|
36
37
|
}) => {
|
|
37
38
|
const [selectOptions, setSelectOptions] = useState();
|
|
38
39
|
const [activeTab, setActiveTab] = useState();
|
|
@@ -47,7 +48,8 @@ const DocumentsTable = ({
|
|
|
47
48
|
theme,
|
|
48
49
|
subject: 'documents',
|
|
49
50
|
data,
|
|
50
|
-
|
|
51
|
+
applications,
|
|
52
|
+
}), [t, goTo, user, options, activeTab, getRedirectLink, theme, data, applications]);
|
|
51
53
|
|
|
52
54
|
const breadCrumbs = [];
|
|
53
55
|
|
|
@@ -4,6 +4,7 @@ import { findOptions } from '../../../../../helpers/StringHelper.js';
|
|
|
4
4
|
import { renderDateFormatted } from '../../../../../helpers/Forms.js';
|
|
5
5
|
import CustomIcon from '../../../../core/components/Icon/CustomIcon.jsx';
|
|
6
6
|
import AvatarGroup from '../../../../core/components/AvatarGroup/index.jsx';
|
|
7
|
+
import sourceAvatarConfig from '../../../../../helpers/sourceAvatarConfig.js';
|
|
7
8
|
|
|
8
9
|
const getLinkValue = (value, linkingObject) => {
|
|
9
10
|
if(linkingObject && linkingObject?.[value]) {
|
|
@@ -12,7 +13,7 @@ const getLinkValue = (value, linkingObject) => {
|
|
|
12
13
|
return null;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
|
-
export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink, theme, subject, data}) => [
|
|
16
|
+
export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink, theme, subject, data, applications}) => [
|
|
16
17
|
{
|
|
17
18
|
dataIndex: 'datastakeId',
|
|
18
19
|
title: t('ID'),
|
|
@@ -124,9 +125,9 @@ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink,
|
|
|
124
125
|
return <div className="daf-default-cell" />;
|
|
125
126
|
}
|
|
126
127
|
|
|
127
|
-
|
|
128
|
+
const sources = sourceAvatarConfig(val, user, applications);
|
|
128
129
|
|
|
129
|
-
return <AvatarGroup items={
|
|
130
|
+
return <AvatarGroup items={sources}></AvatarGroup>;
|
|
130
131
|
},
|
|
131
132
|
},
|
|
132
133
|
{
|
|
@@ -33,6 +33,7 @@ const EventsTable = ({
|
|
|
33
33
|
formValue = {},
|
|
34
34
|
form = {},
|
|
35
35
|
extendingFilters = {},
|
|
36
|
+
applications = [],
|
|
36
37
|
}) => {
|
|
37
38
|
const [selectOptions, setSelectOptions] = useState();
|
|
38
39
|
const [activeTab, setActiveTab] = useState();
|
|
@@ -47,7 +48,8 @@ const EventsTable = ({
|
|
|
47
48
|
theme,
|
|
48
49
|
subject: 'events',
|
|
49
50
|
data,
|
|
50
|
-
|
|
51
|
+
applications,
|
|
52
|
+
}), [t, goTo, user, options, activeTab, getRedirectLink, theme, data, applications]);
|
|
51
53
|
|
|
52
54
|
const breadCrumbs = [];
|
|
53
55
|
|
|
@@ -4,6 +4,7 @@ import { findOptions } from '../../../../../helpers/StringHelper.js';
|
|
|
4
4
|
import { renderDateFormatted } from '../../../../../helpers/Forms.js';
|
|
5
5
|
import CustomIcon from '../../../../core/components/Icon/CustomIcon.jsx';
|
|
6
6
|
import AvatarGroup from '../../../../core/components/AvatarGroup/index.jsx';
|
|
7
|
+
import sourceAvatarConfig from '../../../../../helpers/sourceAvatarConfig.js';
|
|
7
8
|
|
|
8
9
|
const getLinkValue = (value, linkingObject) => {
|
|
9
10
|
if(linkingObject && linkingObject?.[value]) {
|
|
@@ -12,7 +13,7 @@ const getLinkValue = (value, linkingObject) => {
|
|
|
12
13
|
return null;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
|
-
export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink, theme, subject, data}) => [
|
|
16
|
+
export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink, theme, subject, data, applications}) => [
|
|
16
17
|
{
|
|
17
18
|
dataIndex: 'datastakeId',
|
|
18
19
|
title: t('ID'),
|
|
@@ -124,9 +125,9 @@ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink,
|
|
|
124
125
|
return <div className="daf-default-cell" />;
|
|
125
126
|
}
|
|
126
127
|
|
|
127
|
-
|
|
128
|
+
const sources = sourceAvatarConfig(val, user, applications);
|
|
128
129
|
|
|
129
|
-
return <AvatarGroup items={
|
|
130
|
+
return <AvatarGroup items={sources}></AvatarGroup>;
|
|
130
131
|
},
|
|
131
132
|
},
|
|
132
133
|
{
|
|
@@ -32,6 +32,7 @@ const LocationsTable = ({
|
|
|
32
32
|
formData = {},
|
|
33
33
|
formValue = {},
|
|
34
34
|
form = {},
|
|
35
|
+
applications = [],
|
|
35
36
|
}) => {
|
|
36
37
|
const [selectOptions, setSelectOptions] = useState();
|
|
37
38
|
const [activeTab, setActiveTab] = useState();
|
|
@@ -46,7 +47,8 @@ const LocationsTable = ({
|
|
|
46
47
|
theme,
|
|
47
48
|
subject: 'locations',
|
|
48
49
|
data,
|
|
49
|
-
|
|
50
|
+
applications,
|
|
51
|
+
}), [t, goTo, user, options, activeTab, getRedirectLink, theme, data, applications]);
|
|
50
52
|
|
|
51
53
|
const breadCrumbs = [];
|
|
52
54
|
|
|
@@ -4,8 +4,9 @@ import { findOptions } from '../../../../../helpers/StringHelper.js';
|
|
|
4
4
|
import { renderDateFormatted } from '../../../../../helpers/Forms.js';
|
|
5
5
|
import CustomIcon from '../../../../core/components/Icon/CustomIcon.jsx';
|
|
6
6
|
import AvatarGroup from '../../../../core/components/AvatarGroup/index.jsx';
|
|
7
|
+
import sourceAvatarConfig from '../../../../../helpers/sourceAvatarConfig.js';
|
|
7
8
|
|
|
8
|
-
export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink, theme, subject}) => [
|
|
9
|
+
export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink, theme, subject, applications}) => [
|
|
9
10
|
{
|
|
10
11
|
dataIndex: 'datastakeId',
|
|
11
12
|
title: t('ID'),
|
|
@@ -105,7 +106,9 @@ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink,
|
|
|
105
106
|
return "--";
|
|
106
107
|
}
|
|
107
108
|
|
|
108
|
-
|
|
109
|
+
const sources = sourceAvatarConfig(val, user, applications);
|
|
110
|
+
|
|
111
|
+
return <AvatarGroup items={sources}></AvatarGroup>;
|
|
109
112
|
},
|
|
110
113
|
},
|
|
111
114
|
{
|
|
@@ -32,6 +32,7 @@ const StakeholdersTable = ({
|
|
|
32
32
|
formData = {},
|
|
33
33
|
formValue = {},
|
|
34
34
|
form = {},
|
|
35
|
+
applications = [],
|
|
35
36
|
}) => {
|
|
36
37
|
const [selectOptions, setSelectOptions] = useState();
|
|
37
38
|
const [activeTab, setActiveTab] = useState();
|
|
@@ -43,8 +44,9 @@ const StakeholdersTable = ({
|
|
|
43
44
|
activeTab,
|
|
44
45
|
getRedirectLink,
|
|
45
46
|
theme,
|
|
46
|
-
subject: 'stakeholders'
|
|
47
|
-
|
|
47
|
+
subject: 'stakeholders',
|
|
48
|
+
applications,
|
|
49
|
+
}), [t, goTo, user, options, activeTab, getRedirectLink, theme, applications]);
|
|
48
50
|
|
|
49
51
|
const breadCrumbs = [];
|
|
50
52
|
|
|
@@ -0,0 +1,221 @@
|
|
|
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.endsWith('s')
|
|
24
|
+
? subject.slice(0, -1)
|
|
25
|
+
: subject;
|
|
26
|
+
|
|
27
|
+
const key = `typeOfEvent is ${subjectSingular}`;
|
|
28
|
+
return eventCategoryObject[key] || null;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const renderStatusTag = ({ value, t = (s) => s }) => {
|
|
32
|
+
const width = 87;
|
|
33
|
+
|
|
34
|
+
switch (value) {
|
|
35
|
+
case "edited":
|
|
36
|
+
return (
|
|
37
|
+
<Tag color="yellow" style={{ width }} className="text-center">
|
|
38
|
+
{t("Edited")}
|
|
39
|
+
</Tag>
|
|
40
|
+
);
|
|
41
|
+
case "submitted":
|
|
42
|
+
return (
|
|
43
|
+
<Tag color="green" style={{ width }} className="text-center">
|
|
44
|
+
{t("Submitted")}
|
|
45
|
+
</Tag>
|
|
46
|
+
);
|
|
47
|
+
default:
|
|
48
|
+
return (
|
|
49
|
+
<Tag color="blue" style={{ width }} className="text-center">
|
|
50
|
+
{t("Private")}
|
|
51
|
+
</Tag>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink, theme, subject, data, applications}) => [
|
|
57
|
+
{
|
|
58
|
+
dataIndex: 'datastakeId',
|
|
59
|
+
title: t('ID'),
|
|
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: 'name',
|
|
72
|
+
title: t('Title'),
|
|
73
|
+
ellipsis: true,
|
|
74
|
+
show: true,
|
|
75
|
+
render: (v, all) => {
|
|
76
|
+
if (all.empty) {
|
|
77
|
+
return <div className="daf-default-cell" />
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return <Tooltip title={v}>{v}</Tooltip>;
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
title: t("Date"),
|
|
85
|
+
dataIndex: "date",
|
|
86
|
+
key: "date",
|
|
87
|
+
render: (date, all) => {
|
|
88
|
+
if (all.empty) {
|
|
89
|
+
return <div className="daf-default-cell" />;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const _date = date ? renderDateFormatted(date, "DD MMM YYYY", user?.language || 'en') : "-";
|
|
93
|
+
return <Tooltip title={_date}>{_date}</Tooltip>;
|
|
94
|
+
},
|
|
95
|
+
ellipsis: true,
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
dataIndex: 'mineSite',
|
|
99
|
+
title: t('Location'),
|
|
100
|
+
ellipsis: true,
|
|
101
|
+
show: true,
|
|
102
|
+
render: (v, all) => {
|
|
103
|
+
if (all.empty) {
|
|
104
|
+
return <div className="daf-default-cell" />
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// const country = findOptions(v, data?.options?.positionSupplyChainOptions);
|
|
108
|
+
const mineSite = all?.location?.name
|
|
109
|
+
|
|
110
|
+
return mineSite ? <Tooltip title={mineSite}>{mineSite}</Tooltip> : '-';
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
dataIndex: 'province',
|
|
115
|
+
title: t('Province'),
|
|
116
|
+
ellipsis: true,
|
|
117
|
+
show: true,
|
|
118
|
+
render: (v, all) => {
|
|
119
|
+
if (all.empty) {
|
|
120
|
+
return <div className="daf-default-cell" />
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const region = getLinkValue(all?.location?.administrativeLevel1, all?.location?.linking?.SCL);
|
|
124
|
+
|
|
125
|
+
return region ? <Tooltip title={region}>{region}</Tooltip> : '-';
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
dataIndex: 'territory',
|
|
130
|
+
title: t('Territory'),
|
|
131
|
+
ellipsis: true,
|
|
132
|
+
show: true,
|
|
133
|
+
render: (v, all) => {
|
|
134
|
+
if (all.empty) {
|
|
135
|
+
return <div className="daf-default-cell" />
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const district = getLinkValue(all?.location?.administrativeLevel2, all?.location?.linking?.SCL);
|
|
139
|
+
|
|
140
|
+
return district ? <Tooltip title={district}>{district}</Tooltip> : '-';
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
dataIndex: 'eventCategory',
|
|
145
|
+
title: t('Category'),
|
|
146
|
+
ellipsis: true,
|
|
147
|
+
show: true,
|
|
148
|
+
render: (v, all) => {
|
|
149
|
+
if (all.empty) {
|
|
150
|
+
return <div className="daf-default-cell" />
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const eventCategory = findOptions(v, data?.options?.eventCategoryOptions);
|
|
154
|
+
const categoryValue = getEventCategoryBySubject(eventCategory, subject);
|
|
155
|
+
|
|
156
|
+
return categoryValue ? <Tooltip title={categoryValue}>{categoryValue}</Tooltip> : '-';
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
title: t("Sources"),
|
|
161
|
+
dataIndex: "sources",
|
|
162
|
+
key: "sources",
|
|
163
|
+
show: activeTab !== "own",
|
|
164
|
+
render: (val, all) => {
|
|
165
|
+
if (all.empty) {
|
|
166
|
+
return <div className="daf-default-cell" />;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const sources = sourceAvatarConfig(val, user, applications);
|
|
170
|
+
|
|
171
|
+
return <AvatarGroup items={sources}></AvatarGroup>;
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
title: t("Status"),
|
|
176
|
+
dataIndex: "status",
|
|
177
|
+
key: "status",
|
|
178
|
+
show: activeTab === "own",
|
|
179
|
+
render: (val, all) => {
|
|
180
|
+
if (all.empty) {
|
|
181
|
+
return <div className="daf-default-cell" />
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const _val = all?.published || all?.status === "submitted" ? "submitted" : val;
|
|
185
|
+
|
|
186
|
+
return renderStatusTag({ value: _val, t });
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
title: t("Last Update"),
|
|
191
|
+
dataIndex: "updatedAt",
|
|
192
|
+
key: "updatedAt",
|
|
193
|
+
render: (date, all) => {
|
|
194
|
+
if (all.empty) {
|
|
195
|
+
return <div className="daf-default-cell" />;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const _date = date ? renderDateFormatted(date, "DD MMM YYYY", user?.language || 'en') : "-";
|
|
199
|
+
return <Tooltip title={_date}>{_date}</Tooltip>;
|
|
200
|
+
},
|
|
201
|
+
ellipsis: true,
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
id: 'actions',
|
|
205
|
+
title: "",
|
|
206
|
+
width: 60,
|
|
207
|
+
render: (_, all) => {
|
|
208
|
+
if (all.empty) {
|
|
209
|
+
return <div className="daf-default-cell" />;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const link = `/app/view/${subject}/${all.datastakeId}`;
|
|
213
|
+
|
|
214
|
+
return <div style={{ display: "flex", justifyContent: "center" }}>
|
|
215
|
+
<a href={getRedirectLink(link)}>
|
|
216
|
+
<CustomIcon name="Link" size={15} color={theme.baseGray70} />
|
|
217
|
+
</a>
|
|
218
|
+
</div>;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
].filter((column) => column.show !== false);
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
export const checkboxConfig = {
|
|
2
|
+
name: 'Name',
|
|
3
|
+
datastakeId: 'ID'
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export const getFiltersConfig = ({t}) => {
|
|
7
|
+
return {
|
|
8
|
+
country: {
|
|
9
|
+
type: 'select',
|
|
10
|
+
label: 'Country',
|
|
11
|
+
placeholder: (t) => `${t('Filter by')} ${t('Country').toLowerCase()}`,
|
|
12
|
+
style: { flex: 1 },
|
|
13
|
+
labelStyle: { flex: 1 },
|
|
14
|
+
getLabel: (option) => option.label,
|
|
15
|
+
getValue: (option) => option.value,
|
|
16
|
+
},
|
|
17
|
+
administrativeLevel1: {
|
|
18
|
+
type: 'ajaxSelect',
|
|
19
|
+
label: ({ t = (s) => s, options = {}, filters = {}, language = 'en' }) => {
|
|
20
|
+
const { administrativeLevel1 } = options;
|
|
21
|
+
|
|
22
|
+
if (administrativeLevel1) {
|
|
23
|
+
if (options.country) {
|
|
24
|
+
const _item = administrativeLevel1[filters.country];
|
|
25
|
+
if (_item) {
|
|
26
|
+
if (_item[language]) {
|
|
27
|
+
return _item[language]
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return t('Province');
|
|
34
|
+
},
|
|
35
|
+
placeholder: (t) => `${t('Filter by')} ${t('Province').toLowerCase()}`,
|
|
36
|
+
filters: (data) => ({
|
|
37
|
+
country: data.country,
|
|
38
|
+
level: 'level_1',
|
|
39
|
+
}),
|
|
40
|
+
show: (data) => !data.country,
|
|
41
|
+
disabled: (data) => !data.country,
|
|
42
|
+
mapper: { label: "name", value: "id" },
|
|
43
|
+
method: 'getOptions',
|
|
44
|
+
entity: 'AdministrativeLevel',
|
|
45
|
+
style: { flex: 1 },
|
|
46
|
+
labelStyle: { flex: 1 },
|
|
47
|
+
},
|
|
48
|
+
administrativeLevel2: {
|
|
49
|
+
type: 'ajaxSelect',
|
|
50
|
+
label: ({ t = (s) => s, options = {}, filters = {}, language = 'en' }) => {
|
|
51
|
+
const { administrativeLevel2 } = options;
|
|
52
|
+
|
|
53
|
+
if (administrativeLevel2) {
|
|
54
|
+
if (options.country) {
|
|
55
|
+
const _item = administrativeLevel2[filters.country];
|
|
56
|
+
if (_item) {
|
|
57
|
+
if (_item[language]) {
|
|
58
|
+
return _item[language]
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return t('Province');
|
|
65
|
+
},
|
|
66
|
+
show: (data) => !(data.country && data.administrativeLevel1),
|
|
67
|
+
placeholder: (t) => `${t('Filter by')} ${t('Territory').toLowerCase()}`,
|
|
68
|
+
filters: (data) => ({
|
|
69
|
+
country: data.country,
|
|
70
|
+
level: 'level_2',
|
|
71
|
+
administrativeLevel1: data.administrativeLevel1,
|
|
72
|
+
}),
|
|
73
|
+
disabled: (data) => !(data.country && data.administrativeLevel1),
|
|
74
|
+
mapper: { label: "name", value: "id" },
|
|
75
|
+
method: 'getOptions',
|
|
76
|
+
entity: 'AdministrativeLevel',
|
|
77
|
+
style: { flex: 1 },
|
|
78
|
+
labelStyle: { flex: 1 },
|
|
79
|
+
},
|
|
80
|
+
activity: {
|
|
81
|
+
type: 'select',
|
|
82
|
+
label: 'Activity',
|
|
83
|
+
placeholder: (t) => `${t('Filter by')} ${t('Activity').toLowerCase()}`,
|
|
84
|
+
style: { flex: 1 },
|
|
85
|
+
labelStyle: { flex: 1 },
|
|
86
|
+
getLabel: (option) => option.label,
|
|
87
|
+
getValue: (option) => option.value,
|
|
88
|
+
filterOptions: (val) => {
|
|
89
|
+
if (val) {
|
|
90
|
+
const { option, filters } = val
|
|
91
|
+
if (filters && option) {
|
|
92
|
+
const { filters: optionFilters } = option;
|
|
93
|
+
if (Array.isArray(optionFilters) && optionFilters.length) {
|
|
94
|
+
const { value, condition } = optionFilters[0];
|
|
95
|
+
if (condition === 'includes') {
|
|
96
|
+
return value.includes('corporation');
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return true;
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
positionInTheMineralSupplyChain: {
|
|
105
|
+
type: 'select',
|
|
106
|
+
label: 'Position',
|
|
107
|
+
placeholder: (t) => `${t('Filter by')} ${t('Position').toLowerCase()}`,
|
|
108
|
+
style: { flex: 1 },
|
|
109
|
+
labelStyle: { flex: 1 },
|
|
110
|
+
getLabel: (option) => option.label,
|
|
111
|
+
getValue: (option) => option.value,
|
|
112
|
+
},
|
|
113
|
+
status: {
|
|
114
|
+
type: "select",
|
|
115
|
+
label: "Status",
|
|
116
|
+
placeholder: (t) => `${t("Filter by")} ${t("Status").toLowerCase()}`,
|
|
117
|
+
style: { flex: 1 },
|
|
118
|
+
labelStyle: { fley: 1 },
|
|
119
|
+
getLabel: (option) => option.label,
|
|
120
|
+
getValue: (option) => option.value,
|
|
121
|
+
},
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export const filtersConfig = {
|
|
126
|
+
name: '',
|
|
127
|
+
datastakeId: '',
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export const getFilterOptions = (options, t) => {
|
|
131
|
+
const {
|
|
132
|
+
statusOptions = [],
|
|
133
|
+
categoryOptions = [],
|
|
134
|
+
countries = [],
|
|
135
|
+
subCategory = [],
|
|
136
|
+
activityAtSiteOptions = [],
|
|
137
|
+
stakeholderCategoryOptions,
|
|
138
|
+
stakeholderSubCategoriesOptions,
|
|
139
|
+
administrativeLevel1,
|
|
140
|
+
administrativeLevel2,
|
|
141
|
+
positionInMineralSupplyChainOptions,
|
|
142
|
+
subCategoriesOptions,
|
|
143
|
+
} = options || {};
|
|
144
|
+
|
|
145
|
+
const _default = {
|
|
146
|
+
status: [
|
|
147
|
+
{
|
|
148
|
+
value: "submitted",
|
|
149
|
+
label: "Submitted",
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
value: "private",
|
|
153
|
+
label: "Private",
|
|
154
|
+
},
|
|
155
|
+
],
|
|
156
|
+
category: stakeholderCategoryOptions || categoryOptions,
|
|
157
|
+
country: countries,
|
|
158
|
+
subCategory: subCategoriesOptions,
|
|
159
|
+
activity: activityAtSiteOptions,
|
|
160
|
+
administrativeLevel1,
|
|
161
|
+
administrativeLevel2,
|
|
162
|
+
positionInTheMineralSupplyChain: positionInMineralSupplyChainOptions,
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return _default;
|
|
166
|
+
}
|