datastake-daf 0.6.348 → 0.6.349
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 +55 -37
- package/package.json +1 -1
- package/src/@daf/core/components/Screens/Admin/AdminModals/CombineLocation/helper.js +8 -3
- package/src/@daf/core/components/Screens/Admin/AdminModals/CombineLocation/index.jsx +39 -17
- package/src/@daf/core/components/Screens/Admin/AdminTables/LocationTable/LocationTable.stories.js +1 -0
- package/src/@daf/core/components/Screens/Admin/AdminTables/LocationTable/helper.js +3 -3
- package/src/@daf/core/components/Screens/Admin/AdminTables/LocationTable/index.jsx +2 -1
package/dist/components/index.js
CHANGED
|
@@ -55635,7 +55635,7 @@ const getColumns$2 = ({
|
|
|
55635
55635
|
selectedLocations,
|
|
55636
55636
|
setSelectedLocations,
|
|
55637
55637
|
selectOptions,
|
|
55638
|
-
|
|
55638
|
+
entity
|
|
55639
55639
|
}) => {
|
|
55640
55640
|
const cols = [{
|
|
55641
55641
|
title: "",
|
|
@@ -55736,7 +55736,7 @@ const getColumns$2 = ({
|
|
|
55736
55736
|
dataIndex: "administrativeLevel1",
|
|
55737
55737
|
key: "administrativeLevel1",
|
|
55738
55738
|
ellipsis: true,
|
|
55739
|
-
show:
|
|
55739
|
+
show: entity.includes("locations"),
|
|
55740
55740
|
render: (value, all) => {
|
|
55741
55741
|
if (all.empty) {
|
|
55742
55742
|
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
@@ -55758,7 +55758,7 @@ const getColumns$2 = ({
|
|
|
55758
55758
|
title: t("Territory"),
|
|
55759
55759
|
dataIndex: "administrativeLevel2",
|
|
55760
55760
|
key: "administrativeLevel2",
|
|
55761
|
-
show:
|
|
55761
|
+
show: entity.includes("locations"),
|
|
55762
55762
|
ellipsis: true,
|
|
55763
55763
|
render: (value, all) => {
|
|
55764
55764
|
if (all.empty) {
|
|
@@ -55850,12 +55850,14 @@ const getColumns$2 = ({
|
|
|
55850
55850
|
const getColumns$1 = ({
|
|
55851
55851
|
t,
|
|
55852
55852
|
selectOptions,
|
|
55853
|
-
module
|
|
55853
|
+
module,
|
|
55854
|
+
entity
|
|
55854
55855
|
}) => {
|
|
55855
55856
|
return [{
|
|
55856
55857
|
title: t("admin::organisation_id"),
|
|
55857
55858
|
dataIndex: "datastakeId",
|
|
55858
55859
|
key: "datastakeId",
|
|
55860
|
+
show: true,
|
|
55859
55861
|
render: (value, all) => {
|
|
55860
55862
|
return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
|
|
55861
55863
|
title: value,
|
|
@@ -55866,6 +55868,7 @@ const getColumns$1 = ({
|
|
|
55866
55868
|
title: t("Name"),
|
|
55867
55869
|
dataIndex: "name",
|
|
55868
55870
|
key: "name",
|
|
55871
|
+
show: true,
|
|
55869
55872
|
render: (value, all) => {
|
|
55870
55873
|
return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
|
|
55871
55874
|
title: value,
|
|
@@ -55876,6 +55879,7 @@ const getColumns$1 = ({
|
|
|
55876
55879
|
title: t("Category"),
|
|
55877
55880
|
dataIndex: "category",
|
|
55878
55881
|
key: "category",
|
|
55882
|
+
show: true,
|
|
55879
55883
|
render: (value, all) => {
|
|
55880
55884
|
const label = findOptions(value, selectOptions?.category);
|
|
55881
55885
|
return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
|
|
@@ -55887,6 +55891,7 @@ const getColumns$1 = ({
|
|
|
55887
55891
|
title: t("Country"),
|
|
55888
55892
|
dataIndex: "country",
|
|
55889
55893
|
key: "country",
|
|
55894
|
+
show: true,
|
|
55890
55895
|
render: (value, all) => {
|
|
55891
55896
|
const label = findOptions(value, selectOptions?.country);
|
|
55892
55897
|
return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
|
|
@@ -55899,7 +55904,7 @@ const getColumns$1 = ({
|
|
|
55899
55904
|
dataIndex: "administrativeLevel1",
|
|
55900
55905
|
key: "administrativeLevel1",
|
|
55901
55906
|
ellipsis: true,
|
|
55902
|
-
show:
|
|
55907
|
+
show: entity.includes("locations"),
|
|
55903
55908
|
render: (value, all) => {
|
|
55904
55909
|
let label;
|
|
55905
55910
|
if (all?.administrativeLevel1 && value === all?.administrativeLevel1) {
|
|
@@ -55916,6 +55921,7 @@ const getColumns$1 = ({
|
|
|
55916
55921
|
title: t("Territory"),
|
|
55917
55922
|
dataIndex: "administrativeLevel2",
|
|
55918
55923
|
key: "administrativeLevel2",
|
|
55924
|
+
show: entity.includes("locations"),
|
|
55919
55925
|
render: (value, all) => {
|
|
55920
55926
|
let label;
|
|
55921
55927
|
if (all?.administrativeLevel2 && value === all?.administrativeLevel2) {
|
|
@@ -55928,7 +55934,7 @@ const getColumns$1 = ({
|
|
|
55928
55934
|
children: label || '-'
|
|
55929
55935
|
});
|
|
55930
55936
|
}
|
|
55931
|
-
}];
|
|
55937
|
+
}].filter(c => c?.show);
|
|
55932
55938
|
};
|
|
55933
55939
|
|
|
55934
55940
|
const {
|
|
@@ -55941,7 +55947,8 @@ function CombineLocationModal({
|
|
|
55941
55947
|
onSuccess,
|
|
55942
55948
|
selectedLocations,
|
|
55943
55949
|
selectOptions,
|
|
55944
|
-
module
|
|
55950
|
+
module,
|
|
55951
|
+
entity
|
|
55945
55952
|
}) {
|
|
55946
55953
|
const {
|
|
55947
55954
|
token
|
|
@@ -55953,9 +55960,10 @@ function CombineLocationModal({
|
|
|
55953
55960
|
t,
|
|
55954
55961
|
selectOptions,
|
|
55955
55962
|
module,
|
|
55956
|
-
selectedLocations
|
|
55963
|
+
selectedLocations,
|
|
55964
|
+
entity
|
|
55957
55965
|
});
|
|
55958
|
-
}, [selectedLocations, t, selectOptions, module]);
|
|
55966
|
+
}, [selectedLocations, t, selectOptions, module, entity]);
|
|
55959
55967
|
const onSubmit = () => {
|
|
55960
55968
|
MainForm.validateFields().then(data => {
|
|
55961
55969
|
const ids = selectedLocations.map(location => location._id);
|
|
@@ -55974,6 +55982,13 @@ function CombineLocationModal({
|
|
|
55974
55982
|
width: 1100,
|
|
55975
55983
|
disabled: isDisabled,
|
|
55976
55984
|
destroyOnClose: true,
|
|
55985
|
+
onValuesChange: () => {
|
|
55986
|
+
setIsDisabled(() => {
|
|
55987
|
+
const values = MainForm.getFieldsValue();
|
|
55988
|
+
const requiredFields = entity === "location" ? ["id", "name", "category", "country", "administrativeLevel1", "administrativeLevel2"] : ["id", "name", "category", "country"];
|
|
55989
|
+
return requiredFields.some(field => values[field] === undefined);
|
|
55990
|
+
});
|
|
55991
|
+
},
|
|
55977
55992
|
children: [/*#__PURE__*/jsxRuntime.jsxs(Container, {
|
|
55978
55993
|
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
55979
55994
|
className: "daf-table-wrapper no-pagination",
|
|
@@ -56052,32 +56067,34 @@ function CombineLocationModal({
|
|
|
56052
56067
|
}).filter((option, index, self) => index === self.findIndex(o => o.value === option.value)),
|
|
56053
56068
|
placeholder: t("admin::country")
|
|
56054
56069
|
})
|
|
56055
|
-
}), /*#__PURE__*/jsxRuntime.
|
|
56056
|
-
|
|
56057
|
-
|
|
56058
|
-
|
|
56059
|
-
|
|
56060
|
-
|
|
56061
|
-
|
|
56062
|
-
|
|
56063
|
-
|
|
56064
|
-
|
|
56065
|
-
|
|
56066
|
-
|
|
56067
|
-
|
|
56068
|
-
|
|
56069
|
-
|
|
56070
|
-
|
|
56071
|
-
|
|
56072
|
-
|
|
56073
|
-
|
|
56074
|
-
|
|
56075
|
-
|
|
56076
|
-
|
|
56077
|
-
|
|
56078
|
-
|
|
56079
|
-
|
|
56080
|
-
|
|
56070
|
+
}), entity.includes("locations") && /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
56071
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(antd.Form.Item, {
|
|
56072
|
+
className: "flex-1",
|
|
56073
|
+
name: "administrativeLevel1",
|
|
56074
|
+
children: /*#__PURE__*/jsxRuntime.jsx(antd.Select, {
|
|
56075
|
+
placeholder: t("Province"),
|
|
56076
|
+
options: selectedLocations.map(location => {
|
|
56077
|
+
const _data = getNameByLevel(location?.linking?.SCL, "level_1");
|
|
56078
|
+
return {
|
|
56079
|
+
label: _data?.name || "-",
|
|
56080
|
+
value: _data?.id || "-"
|
|
56081
|
+
};
|
|
56082
|
+
}).filter((option, index, self) => index === self.findIndex(o => o.value === option.value))
|
|
56083
|
+
})
|
|
56084
|
+
}), /*#__PURE__*/jsxRuntime.jsx(antd.Form.Item, {
|
|
56085
|
+
className: "flex-1",
|
|
56086
|
+
name: "administrativeLevel2",
|
|
56087
|
+
children: /*#__PURE__*/jsxRuntime.jsx(antd.Select, {
|
|
56088
|
+
placeholder: t("Territory"),
|
|
56089
|
+
options: selectedLocations.map(location => {
|
|
56090
|
+
const _data = getNameByLevel(location?.linking?.SCL, "level_2");
|
|
56091
|
+
return {
|
|
56092
|
+
label: _data?.name || "-",
|
|
56093
|
+
value: _data?.id || "-"
|
|
56094
|
+
};
|
|
56095
|
+
}).filter((option, index, self) => index === self.findIndex(o => o.value === option.value))
|
|
56096
|
+
})
|
|
56097
|
+
})]
|
|
56081
56098
|
})]
|
|
56082
56099
|
})]
|
|
56083
56100
|
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
@@ -56157,7 +56174,7 @@ function LocationTable(_ref) {
|
|
|
56157
56174
|
setSelectedLocations,
|
|
56158
56175
|
getRedirectLink,
|
|
56159
56176
|
selectOptions,
|
|
56160
|
-
|
|
56177
|
+
entity: headerTitle
|
|
56161
56178
|
});
|
|
56162
56179
|
}, [t, goTo, module, token, selectedLocations, getRedirectLink, selectOptions, headerTitle]);
|
|
56163
56180
|
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
@@ -56236,7 +56253,8 @@ function LocationTable(_ref) {
|
|
|
56236
56253
|
},
|
|
56237
56254
|
selectedLocations: selectedLocations,
|
|
56238
56255
|
selectOptions: selectOptions || {},
|
|
56239
|
-
module: module
|
|
56256
|
+
module: module,
|
|
56257
|
+
entity: headerTitle
|
|
56240
56258
|
})]
|
|
56241
56259
|
});
|
|
56242
56260
|
}
|
package/package.json
CHANGED
|
@@ -2,12 +2,13 @@ import { findOptions } from "../../../../../../../helpers/StringHelper.js";
|
|
|
2
2
|
import { Tooltip } from "antd";
|
|
3
3
|
import { getNameByLevel } from "../../AdminTables/LocationTable/helper.js";
|
|
4
4
|
|
|
5
|
-
export const getColumns = ({ t, selectOptions, module }) => {
|
|
5
|
+
export const getColumns = ({ t, selectOptions, module, entity }) => {
|
|
6
6
|
return [
|
|
7
7
|
{
|
|
8
8
|
title: t("admin::organisation_id"),
|
|
9
9
|
dataIndex: "datastakeId",
|
|
10
10
|
key: "datastakeId",
|
|
11
|
+
show: true,
|
|
11
12
|
render: (value, all) => {
|
|
12
13
|
return <Tooltip title={value}>{value}</Tooltip>;
|
|
13
14
|
},
|
|
@@ -16,6 +17,7 @@ export const getColumns = ({ t, selectOptions, module }) => {
|
|
|
16
17
|
title: t("Name"),
|
|
17
18
|
dataIndex: "name",
|
|
18
19
|
key: "name",
|
|
20
|
+
show: true,
|
|
19
21
|
render: (value, all) => {
|
|
20
22
|
return <Tooltip title={value}>{value}</Tooltip>;
|
|
21
23
|
},
|
|
@@ -24,6 +26,7 @@ export const getColumns = ({ t, selectOptions, module }) => {
|
|
|
24
26
|
title: t("Category"),
|
|
25
27
|
dataIndex: "category",
|
|
26
28
|
key: "category",
|
|
29
|
+
show: true,
|
|
27
30
|
render: (value, all) => {
|
|
28
31
|
const label = findOptions(value, selectOptions?.category);
|
|
29
32
|
return <Tooltip title={label}>{label}</Tooltip>;
|
|
@@ -33,6 +36,7 @@ export const getColumns = ({ t, selectOptions, module }) => {
|
|
|
33
36
|
title: t("Country"),
|
|
34
37
|
dataIndex: "country",
|
|
35
38
|
key: "country",
|
|
39
|
+
show: true,
|
|
36
40
|
render: (value, all) => {
|
|
37
41
|
const label = findOptions(value, selectOptions?.country);
|
|
38
42
|
return <Tooltip title={label}>{label}</Tooltip>;
|
|
@@ -43,7 +47,7 @@ export const getColumns = ({ t, selectOptions, module }) => {
|
|
|
43
47
|
dataIndex: "administrativeLevel1",
|
|
44
48
|
key: "administrativeLevel1",
|
|
45
49
|
ellipsis: true,
|
|
46
|
-
show:
|
|
50
|
+
show: entity.includes("locations"),
|
|
47
51
|
render: (value, all) => {
|
|
48
52
|
let label;
|
|
49
53
|
if(all?.administrativeLevel1 && value === all?.administrativeLevel1) {
|
|
@@ -59,6 +63,7 @@ export const getColumns = ({ t, selectOptions, module }) => {
|
|
|
59
63
|
title: t("Territory"),
|
|
60
64
|
dataIndex: "administrativeLevel2",
|
|
61
65
|
key: "administrativeLevel2",
|
|
66
|
+
show: entity.includes("locations"),
|
|
62
67
|
render: (value, all) => {
|
|
63
68
|
let label;
|
|
64
69
|
if(all?.administrativeLevel2 && value === all?.administrativeLevel2) {
|
|
@@ -70,5 +75,5 @@ export const getColumns = ({ t, selectOptions, module }) => {
|
|
|
70
75
|
return <Tooltip title={label || '-'}>{label || '-'}</Tooltip>;
|
|
71
76
|
},
|
|
72
77
|
},
|
|
73
|
-
];
|
|
78
|
+
].filter((c) => c?.show);
|
|
74
79
|
};
|
|
@@ -17,6 +17,7 @@ export default function CombineLocationModal({
|
|
|
17
17
|
selectedLocations,
|
|
18
18
|
selectOptions,
|
|
19
19
|
module,
|
|
20
|
+
entity,
|
|
20
21
|
}) {
|
|
21
22
|
const { token } = useToken();
|
|
22
23
|
const [MainForm] = Form.useForm();
|
|
@@ -28,8 +29,9 @@ export default function CombineLocationModal({
|
|
|
28
29
|
selectOptions,
|
|
29
30
|
module,
|
|
30
31
|
selectedLocations,
|
|
32
|
+
entity,
|
|
31
33
|
});
|
|
32
|
-
}, [selectedLocations, t, selectOptions, module]);
|
|
34
|
+
}, [selectedLocations, t, selectOptions, module, entity]);
|
|
33
35
|
|
|
34
36
|
const onSubmit = () => {
|
|
35
37
|
MainForm.validateFields().then((data) => {
|
|
@@ -51,6 +53,18 @@ export default function CombineLocationModal({
|
|
|
51
53
|
width={1100}
|
|
52
54
|
disabled={isDisabled}
|
|
53
55
|
destroyOnClose={true}
|
|
56
|
+
onValuesChange={() => {
|
|
57
|
+
setIsDisabled(() => {
|
|
58
|
+
const values = MainForm.getFieldsValue();
|
|
59
|
+
|
|
60
|
+
const requiredFields =
|
|
61
|
+
entity === "location"
|
|
62
|
+
? ["id", "name", "category", "country", "administrativeLevel1", "administrativeLevel2"]
|
|
63
|
+
: ["id", "name", "category", "country"];
|
|
64
|
+
|
|
65
|
+
return requiredFields.some((field) => values[field] === undefined);
|
|
66
|
+
});
|
|
67
|
+
}}
|
|
54
68
|
>
|
|
55
69
|
<Container>
|
|
56
70
|
<div className="daf-table-wrapper no-pagination">
|
|
@@ -155,37 +169,45 @@ export default function CombineLocationModal({
|
|
|
155
169
|
></Select>
|
|
156
170
|
</Form.Item>
|
|
157
171
|
|
|
158
|
-
|
|
159
|
-
|
|
172
|
+
{entity.includes("locations") && (
|
|
173
|
+
<>
|
|
174
|
+
<Form.Item className="flex-1" name="administrativeLevel1">
|
|
175
|
+
<Select
|
|
160
176
|
placeholder={t("Province")}
|
|
161
|
-
options={selectedLocations
|
|
177
|
+
options={selectedLocations
|
|
178
|
+
.map((location) => {
|
|
162
179
|
const _data = getNameByLevel(location?.linking?.SCL, "level_1");
|
|
163
180
|
return {
|
|
164
181
|
label: _data?.name || "-",
|
|
165
182
|
value: _data?.id || "-",
|
|
166
|
-
}
|
|
167
|
-
|
|
183
|
+
};
|
|
184
|
+
})
|
|
185
|
+
.filter(
|
|
168
186
|
(option, index, self) =>
|
|
169
187
|
index === self.findIndex((o) => o.value === option.value),
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
188
|
+
)}
|
|
189
|
+
/>
|
|
190
|
+
</Form.Item>
|
|
173
191
|
|
|
174
|
-
|
|
175
|
-
|
|
192
|
+
<Form.Item className="flex-1" name="administrativeLevel2">
|
|
193
|
+
<Select
|
|
176
194
|
placeholder={t("Territory")}
|
|
177
|
-
options={selectedLocations
|
|
195
|
+
options={selectedLocations
|
|
196
|
+
.map((location) => {
|
|
178
197
|
const _data = getNameByLevel(location?.linking?.SCL, "level_2");
|
|
179
198
|
return {
|
|
180
199
|
label: _data?.name || "-",
|
|
181
200
|
value: _data?.id || "-",
|
|
182
|
-
}
|
|
183
|
-
|
|
201
|
+
};
|
|
202
|
+
})
|
|
203
|
+
.filter(
|
|
184
204
|
(option, index, self) =>
|
|
185
205
|
index === self.findIndex((o) => o.value === option.value),
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
206
|
+
)}
|
|
207
|
+
/>
|
|
208
|
+
</Form.Item>
|
|
209
|
+
</>
|
|
210
|
+
)}
|
|
189
211
|
</Form>
|
|
190
212
|
</Container>
|
|
191
213
|
<div style={{ height: 57 }} />
|
|
@@ -77,7 +77,7 @@ export const getColumns = ({
|
|
|
77
77
|
selectedLocations,
|
|
78
78
|
setSelectedLocations,
|
|
79
79
|
selectOptions,
|
|
80
|
-
|
|
80
|
+
entity,
|
|
81
81
|
}) => {
|
|
82
82
|
const cols = [
|
|
83
83
|
{
|
|
@@ -174,7 +174,7 @@ export const getColumns = ({
|
|
|
174
174
|
dataIndex: "administrativeLevel1",
|
|
175
175
|
key: "administrativeLevel1",
|
|
176
176
|
ellipsis: true,
|
|
177
|
-
show:
|
|
177
|
+
show: entity.includes("locations"),
|
|
178
178
|
render: (value, all) => {
|
|
179
179
|
if (all.empty) {
|
|
180
180
|
return <div className="daf-default-cell" />;
|
|
@@ -194,7 +194,7 @@ export const getColumns = ({
|
|
|
194
194
|
title: t("Territory"),
|
|
195
195
|
dataIndex: "administrativeLevel2",
|
|
196
196
|
key: "administrativeLevel2",
|
|
197
|
-
show:
|
|
197
|
+
show: entity.includes("locations"),
|
|
198
198
|
ellipsis: true,
|
|
199
199
|
render: (value, all) => {
|
|
200
200
|
if (all.empty) {
|
|
@@ -80,7 +80,7 @@ export default function LocationTable({
|
|
|
80
80
|
setSelectedLocations,
|
|
81
81
|
getRedirectLink,
|
|
82
82
|
selectOptions,
|
|
83
|
-
|
|
83
|
+
entity: headerTitle
|
|
84
84
|
});
|
|
85
85
|
}, [t, goTo, module, token, selectedLocations, getRedirectLink, selectOptions, headerTitle]);
|
|
86
86
|
|
|
@@ -173,6 +173,7 @@ export default function LocationTable({
|
|
|
173
173
|
selectedLocations={selectedLocations}
|
|
174
174
|
selectOptions={selectOptions || {}}
|
|
175
175
|
module={module}
|
|
176
|
+
entity={headerTitle}
|
|
176
177
|
/>
|
|
177
178
|
</>
|
|
178
179
|
);
|