datastake-daf 0.6.161 → 0.6.163
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 +132 -78
- package/package.json +1 -1
- package/src/@daf/core/components/AvatarGroup/index.jsx +0 -1
- package/src/@daf/core/components/Dashboard/Map/helper.js +418 -492
- package/src/@daf/core/components/Dashboard/Map/hook.js +11 -3
- package/src/@daf/core/components/Dashboard/Widget/ProjectWidget/ProjectWidget.stories.jsx +3 -3
- package/src/@daf/core/components/Dashboard/Widget/ProjectWidget/components/SdgList.jsx +78 -0
- package/src/@daf/core/components/Dashboard/Widget/ProjectWidget/index.jsx +85 -86
- package/src/@daf/core/components/Dashboard/Widget/ProjectWidget/style.js +11 -1
- package/src/@daf/core/components/PdfForm/components/dataLinkHandler.js +2 -2
- package/src/@daf/core/components/PdfForm/index.js +13 -1
- package/src/@daf/core/components/PdfForm/storyConfig.js +6221 -1581
- package/src/@daf/core/components/PdfForm/utils/ajaxSelectFieldData.js +1 -1
|
@@ -332,15 +332,23 @@ export const useMap = ({
|
|
|
332
332
|
}
|
|
333
333
|
addAllDataToMap();
|
|
334
334
|
}
|
|
335
|
+
}, [data, mapRef, activeStakeholder]);
|
|
336
|
+
|
|
337
|
+
useEffect(() => {
|
|
338
|
+
if (mapRef && data && type === "chain") {
|
|
339
|
+
if (!initialMarkerSetIsDone) {
|
|
340
|
+
setInitialMarkerSetIsDone(true);
|
|
341
|
+
} else {
|
|
342
|
+
clearMapMarkers();
|
|
343
|
+
}
|
|
344
|
+
addAllDataToMap();
|
|
345
|
+
}
|
|
335
346
|
}, [
|
|
336
|
-
data,
|
|
337
|
-
mapRef,
|
|
338
347
|
zoom,
|
|
339
348
|
selectedMarkersId,
|
|
340
349
|
markerWithPopup,
|
|
341
350
|
openPopupIdRef.current,
|
|
342
351
|
polylinesRef.current.length,
|
|
343
|
-
activeStakeholder,
|
|
344
352
|
]);
|
|
345
353
|
|
|
346
354
|
useEffect(() => {
|
|
@@ -23,7 +23,6 @@ export const Primary = {
|
|
|
23
23
|
args: {
|
|
24
24
|
image:
|
|
25
25
|
"https://images.squarespace-cdn.com/content/v1/606d4deb4db8c15ea53b3624/1618824875786-3V9HT8BLB1L5PEEJC6ZQ/124.jpg",
|
|
26
|
-
title: "ProjectWidgetTitle",
|
|
27
26
|
onLinkClick: () => {},
|
|
28
27
|
linkIcon: "Link",
|
|
29
28
|
sdgList: [
|
|
@@ -56,14 +55,15 @@ export const Primary = {
|
|
|
56
55
|
<DashboardLayout>
|
|
57
56
|
<Widget title="Project Catalogue" className="with-border-header">
|
|
58
57
|
<section>
|
|
59
|
-
<ProjectWidget {...args} />
|
|
58
|
+
<ProjectWidget {...args} title="ALL SDGS" />
|
|
60
59
|
|
|
61
60
|
<ProjectWidget
|
|
62
61
|
{...args}
|
|
62
|
+
title="SOME SDGS"
|
|
63
63
|
sdgList={["noPoverty", "lifeBelowWater"]}
|
|
64
64
|
/>
|
|
65
65
|
|
|
66
|
-
<ProjectWidget {...args} sdgList={[]} />
|
|
66
|
+
<ProjectWidget {...args} sdgList={[]} title="No SDGS" />
|
|
67
67
|
</section>
|
|
68
68
|
</Widget>
|
|
69
69
|
</DashboardLayout>
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Label, SDGList } from "../style";
|
|
2
|
+
import { Tooltip, Popover } from "antd";
|
|
3
|
+
import { SDG_IMAGES } from "../../../../../../../constants/SDGs";
|
|
4
|
+
import { useMemo } from "react";
|
|
5
|
+
|
|
6
|
+
const SDG_IMAGE_WIDTH = 24;
|
|
7
|
+
const GAP_BETWEEN_SDGS = 4;
|
|
8
|
+
const TOTAL_SPACE_FOR_SDG = SDG_IMAGE_WIDTH + GAP_BETWEEN_SDGS;
|
|
9
|
+
|
|
10
|
+
export default function SdgList({ sdgList = [], t, cardWidth }) {
|
|
11
|
+
const maxSdgToShow = useMemo(() => {
|
|
12
|
+
return Math.floor(cardWidth / TOTAL_SPACE_FOR_SDG);
|
|
13
|
+
}, [cardWidth]);
|
|
14
|
+
|
|
15
|
+
const { visibleSdgs, hiddenCount } = useMemo(() => {
|
|
16
|
+
if (sdgList.length <= maxSdgToShow) {
|
|
17
|
+
return { visibleSdgs: sdgList, hiddenCount: 0 };
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
visibleSdgs: sdgList.slice(0, maxSdgToShow - 1),
|
|
21
|
+
hiddenCount: sdgList.length - (maxSdgToShow - 1),
|
|
22
|
+
};
|
|
23
|
+
}, [sdgList, maxSdgToShow]);
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<>
|
|
27
|
+
<Label>SDGs:</Label>
|
|
28
|
+
<SDGList>
|
|
29
|
+
{visibleSdgs.map((sdg, index) => (
|
|
30
|
+
<li key={index} className="project-widget-item">
|
|
31
|
+
<Tooltip title={t(`SDGS::${sdg}`)}>
|
|
32
|
+
<div
|
|
33
|
+
style={{
|
|
34
|
+
backgroundImage: `url(${SDG_IMAGES[sdg].img})`,
|
|
35
|
+
}}
|
|
36
|
+
className="sdg-item-image"
|
|
37
|
+
/>
|
|
38
|
+
</Tooltip>
|
|
39
|
+
</li>
|
|
40
|
+
))}
|
|
41
|
+
{hiddenCount > 0 && (
|
|
42
|
+
<li className="project-widget-item">
|
|
43
|
+
<Popover
|
|
44
|
+
placement="top"
|
|
45
|
+
content={
|
|
46
|
+
<div
|
|
47
|
+
style={{
|
|
48
|
+
display: "flex",
|
|
49
|
+
gap: "4px",
|
|
50
|
+
flexWrap: "wrap",
|
|
51
|
+
maxWidth: 200,
|
|
52
|
+
}}
|
|
53
|
+
>
|
|
54
|
+
{sdgList.slice(visibleSdgs.length).map((sdg, idx) => (
|
|
55
|
+
<Tooltip key={idx} title={t(`SDGS::${sdg}`)}>
|
|
56
|
+
<div
|
|
57
|
+
style={{
|
|
58
|
+
width: SDG_IMAGE_WIDTH,
|
|
59
|
+
height: SDG_IMAGE_WIDTH,
|
|
60
|
+
backgroundImage: `url(${SDG_IMAGES[sdg].img})`,
|
|
61
|
+
backgroundSize: "cover",
|
|
62
|
+
borderRadius: 4,
|
|
63
|
+
}}
|
|
64
|
+
title={t(`SDGS::${sdg}`)}
|
|
65
|
+
/>
|
|
66
|
+
</Tooltip>
|
|
67
|
+
))}
|
|
68
|
+
</div>
|
|
69
|
+
}
|
|
70
|
+
>
|
|
71
|
+
<div className="sdg-item-image sdg-item-more">+{hiddenCount}</div>
|
|
72
|
+
</Popover>
|
|
73
|
+
</li>
|
|
74
|
+
)}
|
|
75
|
+
</SDGList>
|
|
76
|
+
</>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
@@ -1,94 +1,93 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Card,
|
|
3
|
-
import { ImageContainer, ProjectWidgetItems,
|
|
1
|
+
import React, { useMemo } from "react";
|
|
2
|
+
import { Card, theme } from "antd";
|
|
3
|
+
import { ImageContainer, ProjectWidgetItems, Label } from "./style.js";
|
|
4
4
|
import CustomIcon from "../../../Icon/CustomIcon.jsx";
|
|
5
|
-
import
|
|
6
|
-
|
|
5
|
+
import SdgList from "./components/SdgList.jsx";
|
|
7
6
|
const { Meta } = Card;
|
|
8
7
|
const { useToken } = theme;
|
|
9
8
|
|
|
10
9
|
export default function ProjectWidget({
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
10
|
+
title,
|
|
11
|
+
description,
|
|
12
|
+
onLinkClick,
|
|
13
|
+
image,
|
|
14
|
+
linkIcon = "Link",
|
|
15
|
+
sdgList,
|
|
16
|
+
items,
|
|
17
|
+
onCardClick,
|
|
18
|
+
hideSDGList = false,
|
|
19
|
+
t = (x) => x,
|
|
20
|
+
...props
|
|
22
21
|
}) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
22
|
+
const [isHovered, setIsHovered] = React.useState(false);
|
|
23
|
+
const { token } = useToken();
|
|
24
|
+
|
|
25
|
+
const cardRef = React.useRef(null);
|
|
26
|
+
const [cardWidth, setCardWidth] = React.useState(0);
|
|
27
|
+
|
|
28
|
+
React.useEffect(() => {
|
|
29
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
30
|
+
setCardWidth(entries[0].contentRect.width);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
resizeObserver.observe(cardRef.current);
|
|
34
|
+
return () => resizeObserver.disconnect();
|
|
35
|
+
}, [cardRef]);
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<Card
|
|
39
|
+
style={{
|
|
40
|
+
flex: 1,
|
|
41
|
+
width: "100%",
|
|
42
|
+
minWidth: "200px",
|
|
43
|
+
}}
|
|
44
|
+
hoverable
|
|
45
|
+
onMouseEnter={() => setIsHovered(true)}
|
|
46
|
+
onMouseLeave={() => setIsHovered(false)}
|
|
47
|
+
onClick={onCardClick}
|
|
48
|
+
cover={
|
|
49
|
+
<ImageContainer>
|
|
50
|
+
<div
|
|
51
|
+
className="image"
|
|
52
|
+
style={{
|
|
53
|
+
backgroundImage: `url(${image})`,
|
|
54
|
+
}}
|
|
55
|
+
/>
|
|
56
|
+
{onLinkClick && (
|
|
57
|
+
<div className="icon-container" onClick={onLinkClick}>
|
|
58
|
+
<CustomIcon
|
|
59
|
+
name={linkIcon}
|
|
60
|
+
width={16}
|
|
61
|
+
height={16}
|
|
62
|
+
color={isHovered ? token.colorPrimary7 : "black"}
|
|
63
|
+
/>
|
|
64
|
+
</div>
|
|
65
|
+
)}
|
|
66
|
+
</ImageContainer>
|
|
67
|
+
}
|
|
68
|
+
{...props}
|
|
69
|
+
>
|
|
70
|
+
<Meta title={title || undefined} description={description || undefined} />
|
|
71
|
+
<ProjectWidgetItems>
|
|
72
|
+
{items.map((item, index) => (
|
|
73
|
+
<li key={index} className="project-widget-item">
|
|
74
|
+
<Label>{item.label}</Label>
|
|
75
|
+
{item.render()}
|
|
76
|
+
</li>
|
|
77
|
+
))}
|
|
78
|
+
</ProjectWidgetItems>
|
|
65
79
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
<div
|
|
80
|
-
style={{
|
|
81
|
-
backgroundImage: `url(${SDG_IMAGES[sdg].img})`,
|
|
82
|
-
}}
|
|
83
|
-
className="sdg-item-image"
|
|
84
|
-
/>
|
|
85
|
-
</Tooltip>
|
|
86
|
-
</li>
|
|
87
|
-
);
|
|
88
|
-
})}
|
|
89
|
-
</SDGList>
|
|
90
|
-
</div>
|
|
91
|
-
)}
|
|
92
|
-
</Card>
|
|
93
|
-
);
|
|
80
|
+
{!hideSDGList && (
|
|
81
|
+
<div
|
|
82
|
+
style={{
|
|
83
|
+
borderTop: "1px solid var(--base-gray-30)",
|
|
84
|
+
paddingTop: "10px",
|
|
85
|
+
}}
|
|
86
|
+
ref={cardRef}
|
|
87
|
+
>
|
|
88
|
+
<SdgList sdgList={sdgList} t={t} cardWidth={cardWidth} />
|
|
89
|
+
</div>
|
|
90
|
+
)}
|
|
91
|
+
</Card>
|
|
92
|
+
);
|
|
94
93
|
}
|
|
@@ -48,8 +48,10 @@ export const ProjectWidgetItems = styled.ul`
|
|
|
48
48
|
export const SDGList = styled.ul`
|
|
49
49
|
list-style: none;
|
|
50
50
|
padding: 0;
|
|
51
|
+
width: 100%;
|
|
52
|
+
overflow-x: hidden;
|
|
51
53
|
display: flex;
|
|
52
|
-
flex-wrap:
|
|
54
|
+
flex-wrap: nowrap;
|
|
53
55
|
gap: 4px;
|
|
54
56
|
margin: 0;
|
|
55
57
|
|
|
@@ -60,6 +62,14 @@ export const SDGList = styled.ul`
|
|
|
60
62
|
background-position: center;
|
|
61
63
|
background-repeat: no-repeat;
|
|
62
64
|
}
|
|
65
|
+
|
|
66
|
+
.sdg-item-more {
|
|
67
|
+
display: flex;
|
|
68
|
+
align-items: center;
|
|
69
|
+
justify-content: center;
|
|
70
|
+
background: var(--base-gray-30);
|
|
71
|
+
color: var(--base-gray-90);
|
|
72
|
+
}
|
|
63
73
|
`;
|
|
64
74
|
|
|
65
75
|
export const Label = styled.span`
|
|
@@ -90,13 +90,13 @@ export const handleDataLinkWithTableKeys = ({
|
|
|
90
90
|
inputs[tableKey].label = resolvedLabel || Object.values(formInputConfig.label)[0] ||
|
|
91
91
|
(uploadTypeFields.includes(tableKey) ? uploadTypeLabels[tableKey] : tableKey);
|
|
92
92
|
}
|
|
93
|
-
values[tableKey] = item?.linking?.SCL?.[item?.[tableKey]]?.name || item?.[formInputConfig?.tableLabel?.toLowerCase()] || item?.[tableKey];
|
|
93
|
+
values[tableKey] = item?.linking?.SCL?.[item?.[tableKey]]?.name || item[formInputConfig?.meta?.onNewSetValueKey] || item?.[formInputConfig?.tableLabel?.toLowerCase()] || item?.[tableKey];
|
|
94
94
|
} else {
|
|
95
95
|
inputs[tableKey] = {
|
|
96
96
|
label: uploadTypeFields.includes(tableKey) ? uploadTypeLabels[tableKey] : tableKey,
|
|
97
97
|
type: inputConfig?.type
|
|
98
98
|
};
|
|
99
|
-
values[tableKey] = item?.[tableKey];
|
|
99
|
+
values[tableKey] = item?.linking?.SCL?.[item?.[tableKey]]?.name || item?.[tableKey];
|
|
100
100
|
}
|
|
101
101
|
});
|
|
102
102
|
|
|
@@ -413,7 +413,19 @@ const PdfForm = ({
|
|
|
413
413
|
const organizeFormByHeaders = (formData) => {
|
|
414
414
|
const organizedSections = {};
|
|
415
415
|
|
|
416
|
-
|
|
416
|
+
// Sort sections by position before processing
|
|
417
|
+
const sortedSectionKeys = Object.keys(formData)
|
|
418
|
+
.filter(sectionKey => {
|
|
419
|
+
const section = formData[sectionKey];
|
|
420
|
+
return typeof section === 'object' && section.label;
|
|
421
|
+
})
|
|
422
|
+
.sort((a, b) => {
|
|
423
|
+
const positionA = formData[a]?.position || 0;
|
|
424
|
+
const positionB = formData[b]?.position || 0;
|
|
425
|
+
return positionA - positionB;
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
sortedSectionKeys.forEach((sectionKey) => {
|
|
417
429
|
const section = formData[sectionKey];
|
|
418
430
|
|
|
419
431
|
if (typeof section !== 'object' || !section.label) {
|