datastake-daf 0.6.767 → 0.6.769
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 +1007 -730
- package/dist/layouts/index.js +495 -459
- package/dist/pages/index.js +7914 -6836
- package/dist/style/datastake/mapbox-gl.css +330 -0
- package/dist/utils/index.js +481 -457
- package/package.json +1 -1
- package/src/@daf/core/components/Charts/ColumnChart/index.jsx +10 -0
- package/src/@daf/core/components/Charts/LineChart/index.jsx +14 -0
- package/src/@daf/core/components/Dashboard/Map/ChainIcon/Markers/StakeholderMarker.js +5 -2
- package/src/@daf/core/components/Dashboard/Map/ChainIcon/index.js +67 -27
- package/src/@daf/core/components/Dashboard/Map/hook.js +26 -32
- package/src/@daf/core/components/Dashboard/Widget/ActivityIndicators/index.jsx +2 -0
- package/src/@daf/core/components/Dashboard/Widget/StatCard/StatCard.stories.js +226 -0
- package/src/@daf/core/components/Dashboard/Widget/StatCard/index.js +103 -0
- package/src/@daf/core/components/Dashboard/Widget/StatCard/style.js +83 -0
- package/src/@daf/core/components/Icon/configs/Down.js +8 -0
- package/src/@daf/core/components/Icon/configs/Up.js +8 -0
- package/src/@daf/core/components/Icon/configs/index.js +4 -0
- package/src/@daf/core/components/Icon/configs/partnerIcon.js +1 -1
- package/src/@daf/core/components/Screens/BaseScreen/index.jsx +1 -1
- package/src/@daf/core/components/Screens/TableScreen/TablePageWithTabs/index.jsx +1 -1
- package/src/@daf/core/components/Sidenav/Menu.jsx +4 -4
- package/src/@daf/core/components/UI/MissingTagButton/index.jsx +36 -0
- package/src/@daf/pages/Dashboards/SupplyChain/components/SupplyChainMap/index.js +0 -2
- package/src/@daf/pages/Documents/config.js +0 -10
- package/src/@daf/pages/Documents/index.jsx +51 -108
- package/src/@daf/pages/Events/Activities/config.js +1 -11
- package/src/@daf/pages/Events/Activities/index.jsx +47 -105
- package/src/@daf/pages/Events/Incidents/config.js +1 -11
- package/src/@daf/pages/Events/Incidents/index.jsx +47 -105
- package/src/@daf/pages/Events/config.js +18 -34
- package/src/@daf/pages/Events/index.jsx +49 -111
- package/src/@daf/pages/Locations/MineSite/config.js +0 -10
- package/src/@daf/pages/Locations/MineSite/index.jsx +47 -105
- package/src/@daf/pages/Locations/config.js +4 -16
- package/src/@daf/pages/Locations/index.jsx +53 -110
- package/src/@daf/pages/Stakeholders/Operators/config.js +0 -10
- package/src/@daf/pages/Stakeholders/Operators/index.jsx +47 -105
- package/src/@daf/pages/Stakeholders/Workers/config.js +0 -10
- package/src/@daf/pages/Stakeholders/Workers/index.jsx +47 -105
- package/src/@daf/pages/Stakeholders/config.js +3 -15
- package/src/@daf/pages/Stakeholders/index.jsx +53 -109
- package/src/@daf/pages/Summary/Activities/PlantingCycle/components/AssociatedInformation/index.jsx +43 -0
- package/src/@daf/pages/Summary/Activities/PlantingCycle/components/CommunityParticipation/CommunityStats/helper.js +60 -0
- package/src/@daf/pages/Summary/Activities/PlantingCycle/components/CommunityParticipation/CommunityStats/index.jsx +36 -0
- package/src/@daf/pages/Summary/Activities/PlantingCycle/components/CommunityParticipation/GenderDistribution/helper.js +117 -0
- package/src/@daf/pages/Summary/Activities/PlantingCycle/components/CommunityParticipation/GenderDistribution/index.jsx +49 -0
- package/src/@daf/pages/Summary/Activities/PlantingCycle/components/CommunityParticipation/JobsTimeline/index.jsx +212 -0
- package/src/@daf/pages/Summary/Activities/PlantingCycle/components/CommunityParticipation/index.jsx +72 -0
- package/src/@daf/pages/Summary/Activities/PlantingCycle/components/CycleIndicators/CyclePartners/helper.js +91 -0
- package/src/@daf/pages/Summary/Activities/PlantingCycle/components/CycleIndicators/CyclePartners/index.jsx +50 -0
- package/src/@daf/pages/Summary/Activities/PlantingCycle/components/CycleIndicators/HealthAndSafety/helper.js +134 -0
- package/src/@daf/pages/Summary/Activities/PlantingCycle/components/CycleIndicators/HealthAndSafety/index.jsx +49 -0
- package/src/@daf/pages/Summary/Activities/PlantingCycle/components/CycleIndicators/index.jsx +112 -0
- package/src/@daf/pages/Summary/Activities/PlantingCycle/components/CycleOutcomes/index.jsx +498 -0
- package/src/@daf/pages/Summary/Activities/PlantingCycle/components/KeyInformation/index.jsx +49 -0
- package/src/@daf/pages/Summary/Activities/PlantingCycle/components/PlantingLocations/index.jsx +120 -0
- package/src/@daf/pages/Summary/Activities/PlantingCycle/config.js +5 -10
- package/src/@daf/pages/Summary/Activities/PlantingCycle/helper.js +218 -0
- package/src/@daf/pages/Summary/Activities/PlantingCycle/index.jsx +22 -32
- package/src/@daf/pages/Summary/Activities/Restoration/components/ActivityImagery/index.jsx +29 -0
- package/src/@daf/pages/Summary/Activities/Restoration/components/ActivityLocation/index.jsx +94 -0
- package/src/@daf/pages/Summary/Activities/Restoration/components/WorkersDistribution/index.jsx +49 -0
- package/src/@daf/pages/Summary/Activities/Restoration/index.jsx +16 -138
- package/src/@daf/pages/TablePage/config.js +78 -0
- package/src/@daf/{core/components/Screens/TableScreen/TableWithTabsAndCreate → pages/TablePage}/create.jsx +6 -5
- package/src/@daf/pages/TablePage/hook.js +123 -0
- package/src/@daf/pages/TablePage/index.jsx +142 -0
- package/src/index.js +2 -0
- package/src/@daf/core/components/Screens/TableScreen/TableWithTabsAndCreate/index.jsx +0 -115
- package/src/@daf/pages/Documents/create.jsx +0 -105
- package/src/@daf/pages/Events/Activities/create.jsx +0 -104
- package/src/@daf/pages/Events/Incidents/create.jsx +0 -104
- package/src/@daf/pages/Events/create.jsx +0 -104
- package/src/@daf/pages/Locations/MineSite/create.jsx +0 -104
- package/src/@daf/pages/Locations/create.jsx +0 -104
- package/src/@daf/pages/Stakeholders/Operators/create.jsx +0 -104
- package/src/@daf/pages/Stakeholders/Workers/create.jsx +0 -104
- package/src/@daf/pages/Stakeholders/create.jsx +0 -105
|
@@ -1,34 +1,20 @@
|
|
|
1
|
-
import { useMemo
|
|
2
|
-
import { DashboardLayout, Header,
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { DashboardLayout, Header, KeyIndicators, ActivityIndicators } from '../../../../../../src/index.js'
|
|
3
3
|
import { getKeyIndicatorsRowConfig } from './config';
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import CustomIcon from '../../../../../../src/@daf/core/components/Icon/CustomIcon.jsx';
|
|
4
|
+
import { getActivityIndicatorsConfig } from './helper';
|
|
5
|
+
import ActivityLocation from './components/ActivityLocation/index.jsx';
|
|
6
|
+
import ActivityImagery from './components/ActivityImagery/index.jsx';
|
|
7
|
+
import WorkersDistribution from './components/WorkersDistribution/index.jsx';
|
|
9
8
|
|
|
10
9
|
const RestorationActivitySummary = ({ activityData, supportText, onDownload, downloadDisabled, actionButtons, breadcrumbs, goBackTo, loading, t = () => { } }) => {
|
|
11
|
-
const { isCollapsed, isNestedSidebarCollapsed } = useResizeContext();
|
|
12
10
|
const keyIndicatorsConfig = useMemo(() => getKeyIndicatorsRowConfig({ t, data: activityData }), [t, activityData]);
|
|
13
|
-
const images = useMemo(() => getActivityImages(activityData), [activityData]);
|
|
14
|
-
const genderDistributionData = useMemo(() => getGenderDistributionData(activityData), [activityData]);
|
|
15
|
-
const isEmpty = useMemo(() => isGenderDistributionEmpty(genderDistributionData), [genderDistributionData]);
|
|
16
|
-
const pieData = useMemo(() => calculateGenderPieData(genderDistributionData), [genderDistributionData]);
|
|
17
11
|
|
|
18
|
-
const getTooltipChildren = useCallback(
|
|
19
|
-
(item) => getGenderTooltipChildren(item, isEmpty, genderDistributionData, t, renderTooltipJsx),
|
|
20
|
-
[t, isEmpty, genderDistributionData],
|
|
21
|
-
);
|
|
22
|
-
|
|
23
12
|
// Activity Indicators Config - mapped from activityData
|
|
24
|
-
const activityIndicatorsConfig = useMemo(() =>
|
|
13
|
+
const activityIndicatorsConfig = useMemo(() =>
|
|
25
14
|
getActivityIndicatorsConfig(activityData, t),
|
|
26
15
|
[activityData, t]
|
|
27
16
|
);
|
|
28
17
|
|
|
29
|
-
// Map Data - transformed from activityData
|
|
30
|
-
const mapData = useMemo(() => getMapDataFromActivity(activityData, t), [activityData, t]);
|
|
31
|
-
|
|
32
18
|
return (
|
|
33
19
|
<DashboardLayout
|
|
34
20
|
header={
|
|
@@ -48,126 +34,18 @@ const RestorationActivitySummary = ({ activityData, supportText, onDownload, dow
|
|
|
48
34
|
<KeyIndicators title={t("Key Information")} config={keyIndicatorsConfig} loading={loading} />
|
|
49
35
|
</section>
|
|
50
36
|
|
|
51
|
-
<
|
|
52
|
-
<Widget
|
|
53
|
-
title={t("Activity Location")}
|
|
54
|
-
className="no-px h-w-btn-header no-pt-body no-p-body no-pb-body"
|
|
55
|
-
style={{ height: '100%', display: 'flex', flexDirection: 'column' }}
|
|
56
|
-
>
|
|
57
|
-
<div style={{ flex: 1, minHeight: 0 }}>
|
|
58
|
-
<MineSiteMap
|
|
59
|
-
loading={loading}
|
|
60
|
-
t={t}
|
|
61
|
-
isSatellite={true}
|
|
62
|
-
app={"straatos"}
|
|
63
|
-
type={'location-territory'}
|
|
64
|
-
showSider={false}
|
|
65
|
-
user={null}
|
|
66
|
-
data={mapData}
|
|
67
|
-
maxZoom={18}
|
|
68
|
-
primaryLink={true}
|
|
69
|
-
style={{ height: '100%', width: '100%' }}
|
|
70
|
-
renderTooltipForLocation={(data) => {
|
|
71
|
-
const coordinates = data.gps?.latitude && data.gps?.longitude
|
|
72
|
-
? convertDMS(data.gps.latitude, data.gps.longitude)
|
|
73
|
-
: null;
|
|
74
|
-
|
|
75
|
-
if (!coordinates) {
|
|
76
|
-
return [];
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const isActivityEnd = data.name === t("Activity End") || data.id?.includes('-departure');
|
|
80
|
-
const iconColor = isActivityEnd ? "#FF7A45" : "#016C6E";
|
|
81
|
-
|
|
82
|
-
return [
|
|
83
|
-
{
|
|
84
|
-
label: t("Coordinates"),
|
|
85
|
-
|
|
86
|
-
value: (
|
|
87
|
-
<div style={{ display: 'flex', alignItems: 'center', gap: '6px', flexWrap: 'nowrap' }}>
|
|
88
|
-
{/* Latitude icon (vertical) */}
|
|
89
|
-
<div style={{ display: 'flex', alignItems: 'center' }}>
|
|
90
|
-
<CustomIcon
|
|
91
|
-
name="SpacingHeight"
|
|
92
|
-
width={14}
|
|
93
|
-
height={14}
|
|
94
|
-
color={iconColor}
|
|
95
|
-
/>
|
|
96
|
-
<span style={{ fontWeight: 600, marginLeft: '4px' }}>{coordinates[0]}</span>
|
|
97
|
-
</div>
|
|
98
|
-
{/* Longitude icon (horizontal) */}
|
|
99
|
-
<div style={{ display: 'flex', alignItems: 'center' }}>
|
|
100
|
-
<CustomIcon
|
|
101
|
-
name="SpacingWidth"
|
|
102
|
-
width={14}
|
|
103
|
-
height={14}
|
|
104
|
-
color={iconColor}
|
|
105
|
-
/>
|
|
106
|
-
<span style={{ fontWeight: 600, marginLeft: '4px' }}>{coordinates[1]}</span>
|
|
107
|
-
</div>
|
|
108
|
-
</div>
|
|
109
|
-
),
|
|
110
|
-
},
|
|
111
|
-
];
|
|
112
|
-
}}
|
|
113
|
-
renderTooltipForTerritory={(data) => {
|
|
114
|
-
return [
|
|
115
|
-
{
|
|
116
|
-
label: t("Plot Name"),
|
|
117
|
-
value: data.plotName || data.name || "--",
|
|
118
|
-
},
|
|
119
|
-
];
|
|
120
|
-
}}
|
|
121
|
-
link={true}
|
|
122
|
-
/>
|
|
123
|
-
</div>
|
|
124
|
-
</Widget>
|
|
125
|
-
</section>
|
|
37
|
+
<ActivityLocation activityData={activityData} loading={loading} t={t} />
|
|
126
38
|
|
|
127
|
-
<
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
/>
|
|
134
|
-
</section>
|
|
39
|
+
<ActivityIndicators
|
|
40
|
+
config={activityIndicatorsConfig}
|
|
41
|
+
loading={loading}
|
|
42
|
+
title={t("Activity Indicators")}
|
|
43
|
+
className="small-content"
|
|
44
|
+
/>
|
|
135
45
|
|
|
136
46
|
<section>
|
|
137
|
-
<
|
|
138
|
-
|
|
139
|
-
loading={loading}
|
|
140
|
-
images={images}
|
|
141
|
-
title={t("straatos::activity-imagery")}
|
|
142
|
-
key={`${isCollapsed}-${isNestedSidebarCollapsed}`}
|
|
143
|
-
customArrows={true}
|
|
144
|
-
activeDotColor="#003435"
|
|
145
|
-
/>
|
|
146
|
-
</div>
|
|
147
|
-
<Widget
|
|
148
|
-
loading={loading}
|
|
149
|
-
title={<div>{t("Workers Distribution")}</div>}
|
|
150
|
-
className="with-border-header h-w-btn-header "
|
|
151
|
-
>
|
|
152
|
-
<div
|
|
153
|
-
style={{
|
|
154
|
-
marginTop: "auto",
|
|
155
|
-
marginBottom: "auto",
|
|
156
|
-
}}
|
|
157
|
-
>
|
|
158
|
-
<PieChart
|
|
159
|
-
mouseXOffset={10}
|
|
160
|
-
mouseYOffset={10}
|
|
161
|
-
changeOpacityOnHover={false}
|
|
162
|
-
data={pieData}
|
|
163
|
-
doConstraints={false}
|
|
164
|
-
isPie
|
|
165
|
-
t={t}
|
|
166
|
-
isEmpty={isEmpty}
|
|
167
|
-
getTooltipChildren={getTooltipChildren}
|
|
168
|
-
/>
|
|
169
|
-
</div>
|
|
170
|
-
</Widget>
|
|
47
|
+
<ActivityImagery activityData={activityData} loading={loading} t={t} />
|
|
48
|
+
<WorkersDistribution activityData={activityData} loading={loading} t={t} />
|
|
171
49
|
</section>
|
|
172
50
|
</DashboardLayout>
|
|
173
51
|
)
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { getFiltersConfig as getFiltersConfigStakeholders, getFilterOptions as getFilterOptionsStakeholders } from '../Stakeholders/config';
|
|
2
|
+
import { getFiltersConfig as getFiltersConfigOperators, getFilterOptions as getFilterOptionsOperators } from '../Stakeholders/Operators/config';
|
|
3
|
+
import { getFiltersConfig as getFiltersConfigWorkers, getFilterOptions as getFilterOptionsWorkers } from '../Stakeholders/Workers/config';
|
|
4
|
+
|
|
5
|
+
import { getFiltersConfig as getFiltersConfigEvents, getFilterOptions as getFilterOptionsEvents } from '../Events/config';
|
|
6
|
+
import { getFiltersConfig as getFiltersConfigActivities, getFilterOptions as getFilterOptionsActivities } from '../Events/Activities/config';
|
|
7
|
+
import { getFiltersConfig as getFiltersConfigIncidents, getFilterOptions as getFilterOptionsIncidents } from '../Events/Incidents/config';
|
|
8
|
+
|
|
9
|
+
import { getFiltersConfig as getFiltersConfigLocations, getFilterOptions as getFilterOptionsLocations } from '../Locations/config';
|
|
10
|
+
import { getFiltersConfig as getFiltersConfigProductionSites, getFilterOptions as getFilterOptionsProductionSites } from '../Locations/MineSite/config';
|
|
11
|
+
|
|
12
|
+
import { getFiltersConfig as getFilterConfigDocuments, getFilterOptions as getFilterOptionsDocuments } from '../Documents/config';
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
export const getCheckboxConfig = ({ subject }) => {
|
|
16
|
+
return {
|
|
17
|
+
name: 'Name',
|
|
18
|
+
datastakeId: 'ID'
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const getSelectFiltersConfig = ({ subject }) => {
|
|
23
|
+
return {
|
|
24
|
+
name: '',
|
|
25
|
+
datastakeId: '',
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const FILTER_REGISTRY = {
|
|
30
|
+
stakeholders: {
|
|
31
|
+
config: getFiltersConfigStakeholders,
|
|
32
|
+
options: getFilterOptionsStakeholders,
|
|
33
|
+
},
|
|
34
|
+
workers: {
|
|
35
|
+
config: getFiltersConfigWorkers,
|
|
36
|
+
options: getFilterOptionsWorkers,
|
|
37
|
+
},
|
|
38
|
+
operators: {
|
|
39
|
+
config: getFiltersConfigOperators,
|
|
40
|
+
options: getFilterOptionsOperators,
|
|
41
|
+
},
|
|
42
|
+
events: {
|
|
43
|
+
config: getFiltersConfigEvents,
|
|
44
|
+
options: getFilterOptionsEvents,
|
|
45
|
+
},
|
|
46
|
+
activities: {
|
|
47
|
+
config: getFiltersConfigActivities,
|
|
48
|
+
options: getFilterOptionsActivities,
|
|
49
|
+
},
|
|
50
|
+
incidents: {
|
|
51
|
+
config: getFiltersConfigIncidents,
|
|
52
|
+
options: getFilterOptionsIncidents,
|
|
53
|
+
},
|
|
54
|
+
locations: {
|
|
55
|
+
config: getFiltersConfigLocations,
|
|
56
|
+
options: getFilterOptionsLocations,
|
|
57
|
+
},
|
|
58
|
+
'production-sites': {
|
|
59
|
+
config: getFiltersConfigProductionSites,
|
|
60
|
+
options: getFilterOptionsProductionSites,
|
|
61
|
+
},
|
|
62
|
+
documents: {
|
|
63
|
+
config: getFilterConfigDocuments,
|
|
64
|
+
options: getFilterOptionsDocuments,
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const DEFAULT_SUBJECT = 'stakeholders';
|
|
69
|
+
|
|
70
|
+
export const getFiltersConfig = ({ t, subject }) => {
|
|
71
|
+
const registry = FILTER_REGISTRY[subject] || FILTER_REGISTRY[DEFAULT_SUBJECT];
|
|
72
|
+
return registry?.config({ t });
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export const getFilterOptions = ({ t, subject, options }) => {
|
|
76
|
+
const registry = FILTER_REGISTRY[subject] || FILTER_REGISTRY[DEFAULT_SUBJECT];
|
|
77
|
+
return registry.options(options, t);
|
|
78
|
+
};
|
|
@@ -4,8 +4,8 @@ import { MessageTypes } from '../../../helpers/messages.js';
|
|
|
4
4
|
import DynamicForm from '../../core/components/DynamicForm/index.jsx';
|
|
5
5
|
|
|
6
6
|
const Create = ({
|
|
7
|
-
namespace
|
|
8
|
-
view
|
|
7
|
+
namespace,
|
|
8
|
+
view,
|
|
9
9
|
edit = false,
|
|
10
10
|
formData = {},
|
|
11
11
|
loading = false,
|
|
@@ -27,7 +27,8 @@ const Create = ({
|
|
|
27
27
|
changeAjaxOptions = () => {},
|
|
28
28
|
getAppHeader = () => {},
|
|
29
29
|
getApiBaseUrl = () => {},
|
|
30
|
-
scope
|
|
30
|
+
scope,
|
|
31
|
+
formType
|
|
31
32
|
}) => {
|
|
32
33
|
let {
|
|
33
34
|
form = {},
|
|
@@ -52,7 +53,7 @@ const Create = ({
|
|
|
52
53
|
<div className="daf-create-form">
|
|
53
54
|
<DynamicForm
|
|
54
55
|
form={form}
|
|
55
|
-
data={data}
|
|
56
|
+
data={{...defaultData, ...data}}
|
|
56
57
|
showSaveAndNext={false}
|
|
57
58
|
module={APP}
|
|
58
59
|
onCancel={onCancel}
|
|
@@ -75,7 +76,7 @@ const Create = ({
|
|
|
75
76
|
const newPayload = {
|
|
76
77
|
...defaultData,
|
|
77
78
|
...payloadData,
|
|
78
|
-
form:
|
|
79
|
+
form: formType
|
|
79
80
|
};
|
|
80
81
|
|
|
81
82
|
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { useState, useEffect, useCallback, useMemo } from 'react';
|
|
2
|
+
import { useGetQueryParams } from "../../hooks/useGetQueryParams.js";
|
|
3
|
+
import { getFiltersConfig, getFilterOptions, getCheckboxConfig, getSelectFiltersConfig } from './config.js';
|
|
4
|
+
|
|
5
|
+
export const useFetchData = ({
|
|
6
|
+
location,
|
|
7
|
+
getData,
|
|
8
|
+
activeTab,
|
|
9
|
+
extendingFilters,
|
|
10
|
+
subject,
|
|
11
|
+
}) => {
|
|
12
|
+
const { paginationQuery, searchParams, otherParams, sortBy, sortDir, } = useGetQueryParams({location});
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
const cleanSearchParams = Object.fromEntries(
|
|
15
|
+
Object.entries(searchParams).filter(([_, value]) => value != null && value !== '')
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
const hasPagination = paginationQuery.skip != null || paginationQuery.take != null;
|
|
19
|
+
|
|
20
|
+
if (!hasPagination) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
getData({
|
|
25
|
+
...extendingFilters,
|
|
26
|
+
pagination: paginationQuery,
|
|
27
|
+
...(Object.keys(otherParams).length > 0 && otherParams ),
|
|
28
|
+
...(Object.keys(cleanSearchParams).length > 0 && { search: cleanSearchParams }),
|
|
29
|
+
tab: activeTab,
|
|
30
|
+
sortBy: {
|
|
31
|
+
[sortBy || "updatedAt"]: sortDir ? (sortDir === "ascend" ? 1 : -1) : -1,
|
|
32
|
+
},
|
|
33
|
+
}, subject)
|
|
34
|
+
}, [location.search, activeTab, JSON.stringify(extendingFilters)]);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const useTablePage = ({
|
|
38
|
+
subject,
|
|
39
|
+
location,
|
|
40
|
+
getData,
|
|
41
|
+
getColumns,
|
|
42
|
+
extendingFilters,
|
|
43
|
+
options,
|
|
44
|
+
t,
|
|
45
|
+
goTo,
|
|
46
|
+
user,
|
|
47
|
+
getRedirectLink,
|
|
48
|
+
theme,
|
|
49
|
+
data,
|
|
50
|
+
applications,
|
|
51
|
+
subjectClear,
|
|
52
|
+
}) => {
|
|
53
|
+
const [selectOptions, setSelectOptions] = useState();
|
|
54
|
+
const [activeTab, setActiveTab] = useState("own");
|
|
55
|
+
|
|
56
|
+
useFetchData({
|
|
57
|
+
location,
|
|
58
|
+
getData,
|
|
59
|
+
activeTab,
|
|
60
|
+
extendingFilters: extendingFilters,
|
|
61
|
+
subject,
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const columns = useMemo(() =>
|
|
65
|
+
getColumns({
|
|
66
|
+
t,
|
|
67
|
+
goTo,
|
|
68
|
+
user,
|
|
69
|
+
options,
|
|
70
|
+
activeTab,
|
|
71
|
+
getRedirectLink,
|
|
72
|
+
theme,
|
|
73
|
+
subject,
|
|
74
|
+
data,
|
|
75
|
+
applications,
|
|
76
|
+
}),
|
|
77
|
+
[t, goTo, user, options, activeTab, getRedirectLink, theme, data, applications, subject, getColumns]
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
const selectFiltersConfig = useMemo(() =>
|
|
81
|
+
getFiltersConfig({ t, subject }),
|
|
82
|
+
[t, subject, getFiltersConfig]
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
setSelectOptions((prev) => ({
|
|
87
|
+
...prev,
|
|
88
|
+
...getFilterOptions({ t, subject, options }),
|
|
89
|
+
}));
|
|
90
|
+
}, [options, t, subject, getFilterOptions]);
|
|
91
|
+
|
|
92
|
+
const checkboxConfig = useMemo(() =>
|
|
93
|
+
getCheckboxConfig({ subject }),
|
|
94
|
+
[subject, getCheckboxConfig]
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
const _filtersConfig = useMemo(() => {
|
|
98
|
+
return getSelectFiltersConfig({ subject });
|
|
99
|
+
}, [subject, getSelectFiltersConfig]);
|
|
100
|
+
|
|
101
|
+
const handleActiveTabChange = useCallback((value) => {
|
|
102
|
+
setActiveTab(value);
|
|
103
|
+
}, []);
|
|
104
|
+
|
|
105
|
+
useEffect(
|
|
106
|
+
() => () => {
|
|
107
|
+
if (subjectClear && typeof subjectClear === 'function') {
|
|
108
|
+
subjectClear();
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
[subjectClear]
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
return {
|
|
115
|
+
activeTab,
|
|
116
|
+
selectOptions,
|
|
117
|
+
columns,
|
|
118
|
+
selectFiltersConfig,
|
|
119
|
+
handleActiveTabChange,
|
|
120
|
+
checkboxConfig,
|
|
121
|
+
_filtersConfig,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import TablePageWithTabs from '../../core/components/Screens/TableScreen/TablePageWithTabs/index.jsx';
|
|
3
|
+
import Create from './create.jsx';
|
|
4
|
+
import { displayMessage } from '../../../helpers/messages.js';
|
|
5
|
+
import { useTablePage } from './hook.js';
|
|
6
|
+
|
|
7
|
+
const TablePage = ({
|
|
8
|
+
t = () => {},
|
|
9
|
+
goTo = () => {},
|
|
10
|
+
user = {},
|
|
11
|
+
options = {},
|
|
12
|
+
getRedirectLink = () => {},
|
|
13
|
+
theme = {},
|
|
14
|
+
loading = false,
|
|
15
|
+
data = {},
|
|
16
|
+
isMobile,
|
|
17
|
+
APP,
|
|
18
|
+
location,
|
|
19
|
+
formConfig = {
|
|
20
|
+
getFormData: () => {},
|
|
21
|
+
saveFormData: () => {},
|
|
22
|
+
formLoading: false,
|
|
23
|
+
query: {},
|
|
24
|
+
ajaxForms: {},
|
|
25
|
+
changeAjaxForms: () => {},
|
|
26
|
+
ajaxOptions: {},
|
|
27
|
+
changeAjaxOptions: () => {},
|
|
28
|
+
formData: {},
|
|
29
|
+
formValue: {},
|
|
30
|
+
form: {},
|
|
31
|
+
namespace: '',
|
|
32
|
+
view: '',
|
|
33
|
+
scope: '',
|
|
34
|
+
formType: '',
|
|
35
|
+
defaultValues: {},
|
|
36
|
+
},
|
|
37
|
+
extendingFilters = {},
|
|
38
|
+
getData = () => {},
|
|
39
|
+
getApiBaseUrl = () => {},
|
|
40
|
+
getAppHeader = () => {},
|
|
41
|
+
applications = [],
|
|
42
|
+
subjectClear,
|
|
43
|
+
subject,
|
|
44
|
+
getColumns = () => {},
|
|
45
|
+
viewConfig = {
|
|
46
|
+
title: '',
|
|
47
|
+
breadcrumbs: [],
|
|
48
|
+
createTitle: '',
|
|
49
|
+
},
|
|
50
|
+
onDownload,
|
|
51
|
+
}) => {
|
|
52
|
+
|
|
53
|
+
const {
|
|
54
|
+
activeTab,
|
|
55
|
+
selectOptions,
|
|
56
|
+
columns,
|
|
57
|
+
selectFiltersConfig,
|
|
58
|
+
handleActiveTabChange,
|
|
59
|
+
checkboxConfig,
|
|
60
|
+
_filtersConfig,
|
|
61
|
+
} = useTablePage({
|
|
62
|
+
subject,
|
|
63
|
+
location,
|
|
64
|
+
getData,
|
|
65
|
+
getColumns,
|
|
66
|
+
extendingFilters,
|
|
67
|
+
options,
|
|
68
|
+
t,
|
|
69
|
+
goTo,
|
|
70
|
+
user,
|
|
71
|
+
getRedirectLink,
|
|
72
|
+
theme,
|
|
73
|
+
data,
|
|
74
|
+
applications,
|
|
75
|
+
subjectClear,
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<TablePageWithTabs
|
|
80
|
+
t={t}
|
|
81
|
+
title={t(viewConfig.title || "")}
|
|
82
|
+
breadCrumbs={viewConfig.breadcrumbs}
|
|
83
|
+
location={location}
|
|
84
|
+
loading={loading}
|
|
85
|
+
goTo={goTo}
|
|
86
|
+
defaultActiveTab={"own"}
|
|
87
|
+
columns={columns}
|
|
88
|
+
data={data}
|
|
89
|
+
checkboxConfig={checkboxConfig}
|
|
90
|
+
APP={APP}
|
|
91
|
+
getApiBaseUrl={getApiBaseUrl}
|
|
92
|
+
selectOptions={selectOptions}
|
|
93
|
+
selectFiltersConfig={selectFiltersConfig}
|
|
94
|
+
getRedirectLink={getRedirectLink}
|
|
95
|
+
filtersConfig={_filtersConfig}
|
|
96
|
+
isMobile={isMobile}
|
|
97
|
+
view={subject}
|
|
98
|
+
getActiveTab={handleActiveTabChange}
|
|
99
|
+
onDownload={onDownload && typeof onDownload === 'function' ? onDownload : undefined}
|
|
100
|
+
drawerTitle={t(viewConfig.createTitle || "")}
|
|
101
|
+
>
|
|
102
|
+
{({onDrawerClose}) => (
|
|
103
|
+
<Create
|
|
104
|
+
t={t}
|
|
105
|
+
goTo={goTo}
|
|
106
|
+
user={user}
|
|
107
|
+
APP={APP}
|
|
108
|
+
getApiBaseUrl={getApiBaseUrl}
|
|
109
|
+
getAppHeader={getAppHeader}
|
|
110
|
+
getData={formConfig.getFormData}
|
|
111
|
+
saveData={formConfig.saveFormData}
|
|
112
|
+
loading={formConfig.formLoading}
|
|
113
|
+
onSubmitted={(type, m, data) => {
|
|
114
|
+
if (data.datastakeId) {
|
|
115
|
+
displayMessage(
|
|
116
|
+
type,
|
|
117
|
+
t("affirmations::subject-created-successfully") || m,
|
|
118
|
+
);
|
|
119
|
+
goTo(`/app/edit/${subject}/${data.datastakeId}`);
|
|
120
|
+
}
|
|
121
|
+
}}
|
|
122
|
+
onCancel={onDrawerClose}
|
|
123
|
+
query={formConfig.query}
|
|
124
|
+
ajaxForms={formConfig.ajaxForms}
|
|
125
|
+
changeAjaxForms={formConfig.changeAjaxForms}
|
|
126
|
+
ajaxOptions={formConfig.ajaxOptions}
|
|
127
|
+
changeAjaxOptions={formConfig.changeAjaxOptions}
|
|
128
|
+
formData={formConfig.formData}
|
|
129
|
+
formValue={formConfig.formValue}
|
|
130
|
+
form={formConfig.form}
|
|
131
|
+
namespace={formConfig.namespace}
|
|
132
|
+
view={formConfig.view}
|
|
133
|
+
scope={formConfig.scope}
|
|
134
|
+
formType={formConfig.formType}
|
|
135
|
+
defaultData={formConfig.defaultValues}
|
|
136
|
+
/>
|
|
137
|
+
)}
|
|
138
|
+
</TablePageWithTabs>
|
|
139
|
+
);
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
export default TablePage;
|
package/src/index.js
CHANGED
|
@@ -77,6 +77,7 @@ export { default as ProjectWidget } from "./@daf/core/components/Dashboard/Widge
|
|
|
77
77
|
export { default as WidgetCard } from "./@daf/core/components/Dashboard/Widget/WidgetCard/index.js";
|
|
78
78
|
export { default as CarouselWidget } from "./@daf/core/components/Dashboard/Widget/CarouselWidget/index.jsx";
|
|
79
79
|
export { default as ImageCarousel } from "./@daf/core/components/Dashboard/Widget/ImageCarousel/index.jsx";
|
|
80
|
+
export { default as StatCard } from "./@daf/core/components/Dashboard/Widget/StatCard/index.js";
|
|
80
81
|
// export { default as WidgetCatalogue } from "./@daf/core/components/Dashboard/Widget/WidgetCatalogue/index.jsx";
|
|
81
82
|
|
|
82
83
|
// Forms
|
|
@@ -193,6 +194,7 @@ export { InformationChannelProvider } from "./@daf/core/components/Screens/Infor
|
|
|
193
194
|
export { default as SDGIcons } from "./@daf/core/components/UI/SDGIcon/index.jsx";
|
|
194
195
|
export { default as CountryFlag } from "./@daf/core/components/UI/CountryFlag/index.jsx"
|
|
195
196
|
export { default as KeyIndicatorNavigateLabel } from "./@daf/core/components/UI/KeyIndicatorNavigateLabel/index.jsx";
|
|
197
|
+
export { default as MissingTagButton } from "./@daf/core/components/UI/MissingTagButton/index.jsx";
|
|
196
198
|
|
|
197
199
|
//Settings
|
|
198
200
|
export { default as Settings } from "./@daf/core/components/Screens/Settings/index.js";
|