datastake-daf 0.6.782 → 0.6.784
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 +400 -328
- package/dist/hooks/index.js +3 -1
- package/dist/pages/index.js +3035 -685
- package/dist/utils/index.js +22 -0
- package/package.json +1 -1
- package/src/@daf/core/components/Charts/BarChart/index.jsx +1 -1
- package/src/@daf/core/components/Dashboard/Map/ChainIcon/Markers/StakeholderMarker.js +9 -76
- package/src/@daf/core/components/Dashboard/Map/ChainIcon/index.js +116 -8
- package/src/@daf/core/components/Dashboard/Map/ChainIcon/utils.js +73 -17
- package/src/@daf/core/components/Dashboard/Map/helper.js +1 -0
- package/src/@daf/core/components/Dashboard/Map/hook.js +64 -29
- package/src/@daf/core/components/Dashboard/Map/style.js +20 -5
- package/src/@daf/core/components/Screens/BaseScreen/index.jsx +1 -0
- package/src/@daf/core/components/Select/MultiSelect/index.jsx +4 -2
- package/src/@daf/core/components/Select/MultiSelect/style.js +15 -0
- package/src/@daf/hooks/useGetQueryParams.js +3 -1
- package/src/@daf/pages/Dashboards/UserDashboard/components/ContributionsGraph/hook.js +6 -7
- package/src/@daf/pages/Dashboards/UserDashboard/components/ContributionsGraph/index.jsx +1 -1
- package/src/@daf/pages/Documents/config.js +5 -5
- package/src/@daf/pages/Events/Activities/columns.js +5 -0
- package/src/@daf/pages/Events/Activities/config.js +21 -17
- package/src/@daf/pages/Events/Incidents/columns.js +5 -0
- package/src/@daf/pages/Events/Incidents/config.js +14 -11
- package/src/@daf/pages/Events/columns.js +6 -0
- package/src/@daf/pages/Events/config.js +0 -16
- package/src/@daf/pages/Locations/MineSite/columns.js +5 -1
- package/src/@daf/pages/Locations/MineSite/config.js +21 -24
- package/src/@daf/pages/Partners/columns.js +3 -1
- package/src/@daf/pages/Partners/config.js +13 -9
- package/src/@daf/pages/Partners/create.jsx +5 -2
- package/src/@daf/pages/Partners/edit.jsx +4 -2
- package/src/@daf/pages/Stakeholders/Operators/columns.js +6 -0
- package/src/@daf/pages/Stakeholders/Operators/config.js +8 -8
- package/src/@daf/pages/Stakeholders/Workers/columns.js +19 -13
- package/src/@daf/pages/Stakeholders/Workers/config.js +8 -23
- package/src/@daf/pages/Summary/Minesite/index.jsx +6 -4
- package/src/@daf/pages/Summary/Operator/components/TradeRelationships/index.js +2 -0
- package/src/@daf/pages/Summary/Operator/index.jsx +6 -3
- package/src/@daf/pages/TablePage/index.jsx +8 -2
- package/src/@daf/pages/Template/components/LinkingTemplate/columns.js +95 -0
- package/src/@daf/pages/Template/components/LinkingTemplate/config.js +88 -0
- package/src/@daf/pages/Template/components/LinkingTemplate/index.jsx +121 -0
- package/src/@daf/pages/Template/index.jsx +10 -0
- package/src/@daf/pages/View/hooks/useCallToGetData.js +73 -0
- package/src/@daf/pages/View/hooks/usePrepareForm.js +86 -0
- package/src/@daf/pages/View/hooks/useSubmitSubject.js +40 -0
- package/src/@daf/pages/View/hooks/useViewActions.js +83 -0
- package/src/@daf/pages/View/hooks/useViewPermissions.js +74 -0
- package/src/@daf/pages/View/hooks/useViewUrlParams.js +93 -0
- package/src/@daf/pages/View/index.jsx +326 -0
- package/src/@daf/utils/object.js +3 -1
- package/src/constants/locales/en/translation.js +3 -0
- package/src/constants/locales/fr/translation.js +3 -0
- package/src/constants/locales/sp/translation.js +3 -0
- package/src/pages.js +4 -1
- package/src/utils.js +1 -1
- package/dist/style/datastake/mapbox-gl.css +0 -330
- package/src/@daf/hooks/useViewFormUrlParams.js +0 -84
|
@@ -14,6 +14,8 @@ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink,
|
|
|
14
14
|
title: t('ID'),
|
|
15
15
|
ellipsis: true,
|
|
16
16
|
show: true,
|
|
17
|
+
key: "datastakeId",
|
|
18
|
+
sorter: () => 0 + 0,
|
|
17
19
|
render: (v, all) => {
|
|
18
20
|
if (all.empty) {
|
|
19
21
|
return <div className="daf-default-cell" />
|
|
@@ -27,6 +29,8 @@ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink,
|
|
|
27
29
|
title: t('Name'),
|
|
28
30
|
ellipsis: true,
|
|
29
31
|
show: true,
|
|
32
|
+
key: "name",
|
|
33
|
+
sorter: () => 0 + 0,
|
|
30
34
|
render: (v, all) => {
|
|
31
35
|
if (all.empty) {
|
|
32
36
|
return <div className="daf-default-cell" />
|
|
@@ -55,6 +59,8 @@ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink,
|
|
|
55
59
|
title: t('Legal Form'),
|
|
56
60
|
ellipsis: true,
|
|
57
61
|
show: true,
|
|
62
|
+
key: "subCategory",
|
|
63
|
+
sorter: () => 0 + 0,
|
|
58
64
|
render: (v, all) => {
|
|
59
65
|
if (all.empty) {
|
|
60
66
|
return <div className="daf-default-cell" />
|
|
@@ -3,7 +3,7 @@ export const getFiltersConfig = ({t}) => {
|
|
|
3
3
|
country: {
|
|
4
4
|
type: 'select',
|
|
5
5
|
label: 'Country',
|
|
6
|
-
placeholder: (
|
|
6
|
+
placeholder: () => `${t('Filter by')} ${t('Country').toLowerCase()}`,
|
|
7
7
|
style: { flex: 1 },
|
|
8
8
|
labelStyle: { flex: 1 },
|
|
9
9
|
getLabel: (option) => option.label,
|
|
@@ -27,7 +27,7 @@ export const getFiltersConfig = ({t}) => {
|
|
|
27
27
|
|
|
28
28
|
return t('Province');
|
|
29
29
|
},
|
|
30
|
-
placeholder: (
|
|
30
|
+
placeholder: () => `${t('Filter by')} ${t('Province').toLowerCase()}`,
|
|
31
31
|
filters: (data) => ({
|
|
32
32
|
country: data.country,
|
|
33
33
|
level: 'level_1',
|
|
@@ -59,7 +59,7 @@ export const getFiltersConfig = ({t}) => {
|
|
|
59
59
|
return t('Province');
|
|
60
60
|
},
|
|
61
61
|
show: (data) => !(data.country && data.administrativeLevel1),
|
|
62
|
-
placeholder: (
|
|
62
|
+
placeholder: () => `${t('Filter by')} ${t('Territory').toLowerCase()}`,
|
|
63
63
|
filters: (data) => ({
|
|
64
64
|
country: data.country,
|
|
65
65
|
level: 'level_2',
|
|
@@ -75,7 +75,7 @@ export const getFiltersConfig = ({t}) => {
|
|
|
75
75
|
subCategory: {
|
|
76
76
|
type: 'select',
|
|
77
77
|
label: 'Sub Category',
|
|
78
|
-
placeholder: (
|
|
78
|
+
placeholder: () => `${t('Filter by')} ${t('Sub Category').toLowerCase()}`,
|
|
79
79
|
style: { flex: 1 },
|
|
80
80
|
labelStyle: { flex: 1 },
|
|
81
81
|
getLabel: (option) => option.label,
|
|
@@ -99,7 +99,7 @@ export const getFiltersConfig = ({t}) => {
|
|
|
99
99
|
positionInTheMineralSupplyChain: {
|
|
100
100
|
type: 'select',
|
|
101
101
|
label: 'Position',
|
|
102
|
-
placeholder: (
|
|
102
|
+
placeholder: () => `${t('Filter by')} ${t('Position').toLowerCase()}`,
|
|
103
103
|
style: { flex: 1 },
|
|
104
104
|
labelStyle: { flex: 1 },
|
|
105
105
|
getLabel: (option) => option.label,
|
|
@@ -108,7 +108,7 @@ export const getFiltersConfig = ({t}) => {
|
|
|
108
108
|
status: {
|
|
109
109
|
type: "select",
|
|
110
110
|
label: "Status",
|
|
111
|
-
placeholder: (
|
|
111
|
+
placeholder: () => `${t("Filter by")} ${t("Status").toLowerCase()}`,
|
|
112
112
|
style: { flex: 1 },
|
|
113
113
|
labelStyle: { fley: 1 },
|
|
114
114
|
getLabel: (option) => option.label,
|
|
@@ -139,11 +139,11 @@ export const getFilterOptions = (options, t) => {
|
|
|
139
139
|
status: [
|
|
140
140
|
{
|
|
141
141
|
value: "submitted",
|
|
142
|
-
label: "Submitted",
|
|
142
|
+
label: t("Submitted"),
|
|
143
143
|
},
|
|
144
144
|
{
|
|
145
145
|
value: "private",
|
|
146
|
-
label: "Private",
|
|
146
|
+
label: t("Private"),
|
|
147
147
|
},
|
|
148
148
|
],
|
|
149
149
|
}
|
|
@@ -8,24 +8,28 @@ import sourceAvatarConfig from '../../../../helpers/sourceAvatarConfig.js';
|
|
|
8
8
|
import { renderStatusTag } from '../../../utils/tags.js';
|
|
9
9
|
|
|
10
10
|
export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink, theme, subject, data, applications}) => [
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
{
|
|
12
|
+
dataIndex: 'datastakeId',
|
|
13
|
+
title: t('Title'),
|
|
14
|
+
ellipsis: true,
|
|
15
|
+
show: true,
|
|
16
|
+
key: "datastakeId",
|
|
17
|
+
sorter: () => 0 + 0,
|
|
18
|
+
render: (v, all) => {
|
|
19
|
+
if (all.empty) {
|
|
20
|
+
return <div className="daf-default-cell" />
|
|
21
|
+
}
|
|
20
22
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
return <Tooltip title={v}>{v}</Tooltip>;
|
|
24
|
+
},
|
|
25
|
+
},
|
|
24
26
|
{
|
|
25
27
|
dataIndex: 'name',
|
|
26
28
|
title: t('Name'),
|
|
27
29
|
ellipsis: true,
|
|
28
30
|
show: true,
|
|
31
|
+
key: "name",
|
|
32
|
+
sorter: () => 0 + 0,
|
|
29
33
|
render: (v, all) => {
|
|
30
34
|
if (all.empty) {
|
|
31
35
|
return <div className="daf-default-cell" />
|
|
@@ -36,9 +40,11 @@ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink,
|
|
|
36
40
|
},
|
|
37
41
|
{
|
|
38
42
|
dataIndex: 'mineSite',
|
|
39
|
-
title: t('
|
|
43
|
+
title: t('Site'),
|
|
40
44
|
ellipsis: true,
|
|
41
45
|
show: true,
|
|
46
|
+
key: "mineSite",
|
|
47
|
+
sorter: () => 0 + 0,
|
|
42
48
|
render: (v, all) => {
|
|
43
49
|
if (all.empty) {
|
|
44
50
|
return <div className="daf-default-cell" />
|
|
@@ -3,7 +3,7 @@ export const getFiltersConfig = ({t}) => {
|
|
|
3
3
|
country: {
|
|
4
4
|
type: 'select',
|
|
5
5
|
label: 'Country',
|
|
6
|
-
placeholder: (
|
|
6
|
+
placeholder: () => `${t('Filter by')} ${t('Country').toLowerCase()}`,
|
|
7
7
|
style: { flex: 1 },
|
|
8
8
|
labelStyle: { flex: 1 },
|
|
9
9
|
getLabel: (option) => option.label,
|
|
@@ -27,7 +27,7 @@ export const getFiltersConfig = ({t}) => {
|
|
|
27
27
|
|
|
28
28
|
return t('Province');
|
|
29
29
|
},
|
|
30
|
-
placeholder: (
|
|
30
|
+
placeholder: () => `${t('Filter by')} ${t('Province').toLowerCase()}`,
|
|
31
31
|
filters: (data) => ({
|
|
32
32
|
country: data.country,
|
|
33
33
|
level: 'level_1',
|
|
@@ -59,7 +59,7 @@ export const getFiltersConfig = ({t}) => {
|
|
|
59
59
|
return t('Province');
|
|
60
60
|
},
|
|
61
61
|
show: (data) => !(data.country && data.administrativeLevel1),
|
|
62
|
-
placeholder: (
|
|
62
|
+
placeholder: () => `${t('Filter by')} ${t('Territory').toLowerCase()}`,
|
|
63
63
|
filters: (data) => ({
|
|
64
64
|
country: data.country,
|
|
65
65
|
level: 'level_2',
|
|
@@ -75,31 +75,16 @@ export const getFiltersConfig = ({t}) => {
|
|
|
75
75
|
activity: {
|
|
76
76
|
type: 'select',
|
|
77
77
|
label: 'Activity',
|
|
78
|
-
placeholder: (
|
|
78
|
+
placeholder: () => `${t('Filter by')} ${t('Activity').toLowerCase()}`,
|
|
79
79
|
style: { flex: 1 },
|
|
80
80
|
labelStyle: { flex: 1 },
|
|
81
81
|
getLabel: (option) => option.label,
|
|
82
82
|
getValue: (option) => option.value,
|
|
83
|
-
filterOptions: (val) => {
|
|
84
|
-
if (val) {
|
|
85
|
-
const { option, filters } = val
|
|
86
|
-
if (filters && option) {
|
|
87
|
-
const { filters: optionFilters } = option;
|
|
88
|
-
if (Array.isArray(optionFilters) && optionFilters.length) {
|
|
89
|
-
const { value, condition } = optionFilters[0];
|
|
90
|
-
if (condition === 'includes') {
|
|
91
|
-
return value.includes('corporation');
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
return true;
|
|
97
|
-
},
|
|
98
83
|
},
|
|
99
84
|
positionInTheMineralSupplyChain: {
|
|
100
85
|
type: 'select',
|
|
101
86
|
label: 'Position',
|
|
102
|
-
placeholder: (
|
|
87
|
+
placeholder: () => `${t('Filter by')} ${t('Position').toLowerCase()}`,
|
|
103
88
|
style: { flex: 1 },
|
|
104
89
|
labelStyle: { flex: 1 },
|
|
105
90
|
getLabel: (option) => option.label,
|
|
@@ -108,7 +93,7 @@ export const getFiltersConfig = ({t}) => {
|
|
|
108
93
|
status: {
|
|
109
94
|
type: "select",
|
|
110
95
|
label: "Status",
|
|
111
|
-
placeholder: (
|
|
96
|
+
placeholder: () => `${t("Filter by")} ${t("Status").toLowerCase()}`,
|
|
112
97
|
style: { flex: 1 },
|
|
113
98
|
labelStyle: { fley: 1 },
|
|
114
99
|
getLabel: (option) => option.label,
|
|
@@ -136,11 +121,11 @@ export const getFilterOptions = (options, t) => {
|
|
|
136
121
|
status: [
|
|
137
122
|
{
|
|
138
123
|
value: "submitted",
|
|
139
|
-
label: "Submitted",
|
|
124
|
+
label: t("Submitted"),
|
|
140
125
|
},
|
|
141
126
|
{
|
|
142
127
|
value: "private",
|
|
143
|
-
label: "Private",
|
|
128
|
+
label: t("Private"),
|
|
144
129
|
},
|
|
145
130
|
],
|
|
146
131
|
category: stakeholderCategoryOptions || categoryOptions,
|
|
@@ -68,13 +68,12 @@ const MineSummary = ({
|
|
|
68
68
|
<DashboardLayout
|
|
69
69
|
header={
|
|
70
70
|
<Header
|
|
71
|
-
title={hasSelect ? t("Mine Review") : (singleItemData?.name || ""
|
|
71
|
+
title={hasSelect ? t("Mine Review") : (`${singleItemData?.name || ""} ${singleItemData?.name ? t("Summary") : ""}`)}
|
|
72
72
|
className="with-border-header h-w-btn-header no-px-body"
|
|
73
73
|
goBackTo={!hasSelect && goBack}
|
|
74
|
-
loading={loading}
|
|
75
74
|
breadcrumbs={breadcrumbs}
|
|
76
75
|
addedHeaderFirst
|
|
77
|
-
actionButtons={[
|
|
76
|
+
actionButtons={hasSelect ? [] :[
|
|
78
77
|
{
|
|
79
78
|
tooltip: t("Details"),
|
|
80
79
|
icon: "FileEdit",
|
|
@@ -90,7 +89,7 @@ const MineSummary = ({
|
|
|
90
89
|
},
|
|
91
90
|
]}
|
|
92
91
|
addedHeader={
|
|
93
|
-
<div className="flex flex-row gap-4"
|
|
92
|
+
<div className="flex flex-row gap-4">
|
|
94
93
|
<Multiselect
|
|
95
94
|
options={[...sourceOptions]}
|
|
96
95
|
isAvatarGroup
|
|
@@ -109,6 +108,9 @@ const MineSummary = ({
|
|
|
109
108
|
/>
|
|
110
109
|
</div>
|
|
111
110
|
}
|
|
111
|
+
onDownload={() => {
|
|
112
|
+
console.log("onDownload");
|
|
113
|
+
}}
|
|
112
114
|
/>
|
|
113
115
|
}
|
|
114
116
|
>
|
|
@@ -69,12 +69,12 @@ const OperatorSummary = ({
|
|
|
69
69
|
<DashboardLayout
|
|
70
70
|
header={
|
|
71
71
|
<Header
|
|
72
|
-
title={hasSelect ? t("Operator Review") : (singleItemData?.name || ""
|
|
72
|
+
title={hasSelect ? t("Operator Review") : (`${singleItemData?.name || ""} ${singleItemData?.name ? t("Summary") : ""}`)}
|
|
73
73
|
className="with-border-header h-w-btn-header no-px-body"
|
|
74
74
|
goBackTo={!hasSelect && goBack}
|
|
75
75
|
breadcrumbs={breadcrumbs}
|
|
76
76
|
addedHeaderFirst
|
|
77
|
-
actionButtons={[
|
|
77
|
+
actionButtons={hasSelect ? [] :[
|
|
78
78
|
{
|
|
79
79
|
tooltip: t("Details"),
|
|
80
80
|
icon: "FileEdit",
|
|
@@ -90,7 +90,7 @@ const OperatorSummary = ({
|
|
|
90
90
|
},
|
|
91
91
|
]}
|
|
92
92
|
addedHeader={
|
|
93
|
-
<div className="flex flex-row gap-4"
|
|
93
|
+
<div className="flex flex-row gap-4">
|
|
94
94
|
<Multiselect
|
|
95
95
|
options={[...sourceOptions]}
|
|
96
96
|
isAvatarGroup
|
|
@@ -109,6 +109,9 @@ const OperatorSummary = ({
|
|
|
109
109
|
/>
|
|
110
110
|
</div>
|
|
111
111
|
}
|
|
112
|
+
onDownload={() => {
|
|
113
|
+
console.log("onDownload");
|
|
114
|
+
}}
|
|
112
115
|
/>
|
|
113
116
|
}
|
|
114
117
|
>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
2
|
import TablePageWithTabs from '../../core/components/Screens/TableScreen/TablePageWithTabs/index.jsx';
|
|
3
3
|
import Create from './create.jsx';
|
|
4
4
|
import { displayMessage } from '../../../helpers/messages.js';
|
|
@@ -40,6 +40,12 @@ const TablePage = ({
|
|
|
40
40
|
breadcrumbs = [],
|
|
41
41
|
onDownload,
|
|
42
42
|
}) => {
|
|
43
|
+
const _options = useMemo(() => {
|
|
44
|
+
return {
|
|
45
|
+
...options,
|
|
46
|
+
...data?.options,
|
|
47
|
+
}
|
|
48
|
+
},[options, data?.options])
|
|
43
49
|
|
|
44
50
|
const {
|
|
45
51
|
activeTab,
|
|
@@ -56,7 +62,7 @@ const TablePage = ({
|
|
|
56
62
|
location,
|
|
57
63
|
getData,
|
|
58
64
|
extendingFilters,
|
|
59
|
-
options,
|
|
65
|
+
options: _options,
|
|
60
66
|
t,
|
|
61
67
|
goTo,
|
|
62
68
|
user,
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { renderType } from './config.js';
|
|
2
|
+
import { renderDateFormatted } from '../../../../../helpers/Forms.js';
|
|
3
|
+
import CustomIcon from '../../../../core/components/Icon/CustomIcon.jsx';
|
|
4
|
+
|
|
5
|
+
export const getColumns = ({ t, redirect = () => "", mod, mode = "app", options }) => [
|
|
6
|
+
{
|
|
7
|
+
title: "ID",
|
|
8
|
+
dataIndex: "datastakeId",
|
|
9
|
+
key: "datastakeId",
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
title: t("Type"),
|
|
13
|
+
dataIndex: "type",
|
|
14
|
+
key: "type",
|
|
15
|
+
render: (type, all) => renderType({ item: all, t, type }),
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
title: t("Name"),
|
|
19
|
+
dataIndex: "name",
|
|
20
|
+
key: "name",
|
|
21
|
+
render: (name, all) => {
|
|
22
|
+
if (all.empty) {
|
|
23
|
+
return <div className="daf-default-cell" />;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (all?.form === "products") {
|
|
27
|
+
const { minerals } = options;
|
|
28
|
+
const mineral = minerals.find(
|
|
29
|
+
(mineral) => mineral.value === all?.typeOfProduct,
|
|
30
|
+
)?.label;
|
|
31
|
+
return mineral || "--";
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return name || "--";
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
title: t("Last Update"),
|
|
39
|
+
dataIndex: "updatedAt",
|
|
40
|
+
key: "updateAt",
|
|
41
|
+
render: (updatedAt, all) => {
|
|
42
|
+
if (all.empty) {
|
|
43
|
+
return <div className="daf-default-cell" />;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<div className="daf-default-cell">
|
|
48
|
+
{renderDateFormatted(updatedAt, "DD MMM YYYY")}
|
|
49
|
+
</div>
|
|
50
|
+
);
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
title: "",
|
|
55
|
+
dataIndex: "actions",
|
|
56
|
+
width: 50,
|
|
57
|
+
key: "actions",
|
|
58
|
+
render: (_, all) => {
|
|
59
|
+
if (all.empty) {
|
|
60
|
+
return <div className="daf-default-cell" />;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return mode === "proxy" ? (
|
|
64
|
+
<a
|
|
65
|
+
onClick={() =>
|
|
66
|
+
redirect({
|
|
67
|
+
id: all.datastakeId,
|
|
68
|
+
type: all.type,
|
|
69
|
+
mod,
|
|
70
|
+
mode,
|
|
71
|
+
item: all,
|
|
72
|
+
})
|
|
73
|
+
}
|
|
74
|
+
href="#"
|
|
75
|
+
>
|
|
76
|
+
<CustomIcon name="LinkNewTab" width={14} height={14} color="#6C737F" />
|
|
77
|
+
</a>
|
|
78
|
+
) : (
|
|
79
|
+
<a
|
|
80
|
+
href={redirect({
|
|
81
|
+
id: all.datastakeId,
|
|
82
|
+
type: all.type,
|
|
83
|
+
mod,
|
|
84
|
+
mode,
|
|
85
|
+
item: all,
|
|
86
|
+
})}
|
|
87
|
+
target="_blank"
|
|
88
|
+
rel="noreferrer"
|
|
89
|
+
>
|
|
90
|
+
<CustomIcon name="LinkNewTab" width={14} height={14} color="#6C737F" />
|
|
91
|
+
</a>
|
|
92
|
+
);
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
];
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { capitalizeAll } from '../../../../../helpers/StringHelper.js';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export const decapitalize = string =>
|
|
6
|
+
string && string.charAt(0).toLowerCase() + string.slice(1);
|
|
7
|
+
|
|
8
|
+
const formatRedirectString = (stringItem) => {
|
|
9
|
+
let string;
|
|
10
|
+
if (stringItem.includes("nashiriki")) {
|
|
11
|
+
string = decapitalize(stringItem?.replaceAll("nashiriki", ""));
|
|
12
|
+
} else {
|
|
13
|
+
string = stringItem;
|
|
14
|
+
}
|
|
15
|
+
return string;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const getLanguage = (lng = "") => {
|
|
19
|
+
if (lng.includes("en")) {
|
|
20
|
+
return "en";
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (lng.includes("fr")) {
|
|
24
|
+
return "fr";
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const redirect = ({ id, item }) => {
|
|
29
|
+
const viewMode = "view";
|
|
30
|
+
let type = "testimonials";
|
|
31
|
+
|
|
32
|
+
if (item.category === "mineSite") {
|
|
33
|
+
type = "scl";
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (item.stakeholderType === "operator") {
|
|
37
|
+
type = "operators";
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (item.stakeholderType === "worker") {
|
|
41
|
+
type = "workers";
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (item.form) {
|
|
45
|
+
type = `${formatRedirectString(item.form)}s`;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
let url = `/${viewMode}/${type}/${id}`;
|
|
49
|
+
|
|
50
|
+
return `/app${url}`;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export const renderType = ({ item = {}, t = (s) => s }) => {
|
|
54
|
+
if (item.empty) {
|
|
55
|
+
return <div className="daf-default-cell" />;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (item.category === "mineSite") {
|
|
59
|
+
return t("Mine Site");
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (item.stakeholderType === "operator") {
|
|
63
|
+
return t("Operator");
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (item.stakeholderType === "worker") {
|
|
67
|
+
return t("Worker");
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (item.form) {
|
|
71
|
+
return t(capitalizeAll(item.form));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return "--";
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export const namespaceMap = {
|
|
78
|
+
locations: "location",
|
|
79
|
+
documents: "document",
|
|
80
|
+
stakeholders: "stakeholder",
|
|
81
|
+
events: "event",
|
|
82
|
+
incidents: "event",
|
|
83
|
+
correctiveActions: "event",
|
|
84
|
+
"production-sites": "location",
|
|
85
|
+
operators: "stakeholder",
|
|
86
|
+
workers: "stakeholder",
|
|
87
|
+
activities: "event",
|
|
88
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import React, { useEffect, useMemo } from 'react';
|
|
2
|
+
import { useFilters } from '../../../../hooks/useFilters.js';
|
|
3
|
+
import { getColumns } from './columns.js';
|
|
4
|
+
import { redirect, namespaceMap } from './config.js';
|
|
5
|
+
import LinkedSubjectsService from '../../../../services/LinkedSubjects.js';
|
|
6
|
+
import { formatClassname } from '../../../../../helpers/ClassesHelper.js';
|
|
7
|
+
import Table from '../../../../core/components/Table/index.jsx';
|
|
8
|
+
import Pagination from '../../../../core/components/Table/Pagination/index.jsx';
|
|
9
|
+
|
|
10
|
+
const emptyObject = {};
|
|
11
|
+
|
|
12
|
+
const LinkingTemplate = ({
|
|
13
|
+
conf,
|
|
14
|
+
namespace
|
|
15
|
+
}) => {
|
|
16
|
+
const view = useMemo(() => conf?.location?.pathname?.split(`/app/${conf.mod}/`)[1], [conf]);
|
|
17
|
+
|
|
18
|
+
const {
|
|
19
|
+
pagination,
|
|
20
|
+
onTableChange,
|
|
21
|
+
totalPages,
|
|
22
|
+
canGoNext,
|
|
23
|
+
canGoPrev,
|
|
24
|
+
setPagination,
|
|
25
|
+
goPrev,
|
|
26
|
+
goNext,
|
|
27
|
+
} = useFilters({
|
|
28
|
+
module: conf.mod,
|
|
29
|
+
view,
|
|
30
|
+
selectFiltersConfig: emptyObject,
|
|
31
|
+
filtersConfig: emptyObject,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const columns = useMemo(() => getColumns({
|
|
35
|
+
t: conf.t,
|
|
36
|
+
redirect,
|
|
37
|
+
mod: conf.mod,
|
|
38
|
+
language: conf.user?.language,
|
|
39
|
+
mode: conf.mode,
|
|
40
|
+
options: conf.options,
|
|
41
|
+
}), [conf]);
|
|
42
|
+
|
|
43
|
+
const id = conf.allData.id;
|
|
44
|
+
|
|
45
|
+
const dataSource = conf?.linkingTemplateContextData?.[id];
|
|
46
|
+
|
|
47
|
+
const _namespace = namespaceMap[namespace];
|
|
48
|
+
|
|
49
|
+
const changeData = async () => {
|
|
50
|
+
try {
|
|
51
|
+
const _data = await LinkedSubjectsService.getLinkedSubjects({ namespace: _namespace, id, mod: conf.mod });
|
|
52
|
+
const data = (_data?.data || []).map((d, i) => ({ ...d, key: `${d.id}-${i}` }));
|
|
53
|
+
conf?.addData(id, data);
|
|
54
|
+
setPagination((prev) => ({
|
|
55
|
+
...prev,
|
|
56
|
+
current: 1,
|
|
57
|
+
total: data.length ? data.length : 1,
|
|
58
|
+
}));
|
|
59
|
+
} catch (err) {
|
|
60
|
+
console.log(err);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const _dataSource = useMemo(() => {
|
|
65
|
+
const startIndex = pagination.pageSize * (pagination.current - 1);
|
|
66
|
+
const endIndex = Math.min(startIndex + pagination.pageSize, dataSource?.length || 0);
|
|
67
|
+
return [...(dataSource || [])].slice(startIndex, endIndex);
|
|
68
|
+
}, [pagination, dataSource]);
|
|
69
|
+
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
if (!dataSource) {
|
|
72
|
+
changeData();
|
|
73
|
+
} else {
|
|
74
|
+
setPagination((prev) => ({
|
|
75
|
+
...prev,
|
|
76
|
+
current: 1,
|
|
77
|
+
total: dataSource.length ? dataSource.length : 1,
|
|
78
|
+
}));
|
|
79
|
+
}
|
|
80
|
+
}, []);
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
return ( <div className={formatClassname(["content", "documents-layout"])} style={{}}>
|
|
84
|
+
<div className="view-header" style={{ flexDirection: "column", paddingTop: 0 }}>
|
|
85
|
+
<div className="daf-table-wrapper pagination-no-padding">
|
|
86
|
+
<Table
|
|
87
|
+
className="mt-0 p-0"
|
|
88
|
+
columns={columns}
|
|
89
|
+
hideOnLoading={false}
|
|
90
|
+
data={_dataSource}
|
|
91
|
+
doEmptyRows
|
|
92
|
+
loading={!dataSource}
|
|
93
|
+
rowKey="key"
|
|
94
|
+
pagination={pagination}
|
|
95
|
+
size="small"
|
|
96
|
+
/>
|
|
97
|
+
|
|
98
|
+
<Pagination
|
|
99
|
+
t={conf?.t}
|
|
100
|
+
isMobile={conf?.isMobile}
|
|
101
|
+
page={pagination.current}
|
|
102
|
+
totalPages={totalPages}
|
|
103
|
+
goPrev={goPrev}
|
|
104
|
+
goNext={goNext}
|
|
105
|
+
canGoNext={canGoNext}
|
|
106
|
+
canGoPrev={canGoPrev}
|
|
107
|
+
totalItems={pagination.total}
|
|
108
|
+
doTotalItems
|
|
109
|
+
onChangePagination={(val) => {
|
|
110
|
+
onTableChange({ ...pagination, current: 1, pageSize: val });
|
|
111
|
+
}}
|
|
112
|
+
perPage={pagination.pageSize}
|
|
113
|
+
arrowIcons
|
|
114
|
+
/>
|
|
115
|
+
</div>
|
|
116
|
+
</div>
|
|
117
|
+
</div>
|
|
118
|
+
)
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
export default LinkingTemplate;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/* eslint-disable react/prop-types */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import LinkingTemplate from './components/LinkingTemplate/index.jsx';
|
|
4
|
+
|
|
5
|
+
export function Template({
|
|
6
|
+
conf,
|
|
7
|
+
namespace,
|
|
8
|
+
}) {
|
|
9
|
+
return <LinkingTemplate conf={conf} namespace={namespace} />
|
|
10
|
+
}
|