datastake-daf 0.6.347 → 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.
@@ -55634,7 +55634,8 @@ const getColumns$2 = ({
55634
55634
  token,
55635
55635
  selectedLocations,
55636
55636
  setSelectedLocations,
55637
- selectOptions
55637
+ selectOptions,
55638
+ entity
55638
55639
  }) => {
55639
55640
  const cols = [{
55640
55641
  title: "",
@@ -55735,7 +55736,7 @@ const getColumns$2 = ({
55735
55736
  dataIndex: "administrativeLevel1",
55736
55737
  key: "administrativeLevel1",
55737
55738
  ellipsis: true,
55738
- show: true,
55739
+ show: entity.includes("locations"),
55739
55740
  render: (value, all) => {
55740
55741
  if (all.empty) {
55741
55742
  return /*#__PURE__*/jsxRuntime.jsx("div", {
@@ -55757,7 +55758,7 @@ const getColumns$2 = ({
55757
55758
  title: t("Territory"),
55758
55759
  dataIndex: "administrativeLevel2",
55759
55760
  key: "administrativeLevel2",
55760
- show: true,
55761
+ show: entity.includes("locations"),
55761
55762
  ellipsis: true,
55762
55763
  render: (value, all) => {
55763
55764
  if (all.empty) {
@@ -55822,7 +55823,7 @@ const getColumns$2 = ({
55822
55823
  title: "",
55823
55824
  dataIndex: "actions",
55824
55825
  key: "actions",
55825
- width: 70,
55826
+ width: 60,
55826
55827
  show: true,
55827
55828
  render: (value, all) => {
55828
55829
  if (all.empty) {
@@ -55849,12 +55850,14 @@ const getColumns$2 = ({
55849
55850
  const getColumns$1 = ({
55850
55851
  t,
55851
55852
  selectOptions,
55852
- module
55853
+ module,
55854
+ entity
55853
55855
  }) => {
55854
55856
  return [{
55855
55857
  title: t("admin::organisation_id"),
55856
55858
  dataIndex: "datastakeId",
55857
55859
  key: "datastakeId",
55860
+ show: true,
55858
55861
  render: (value, all) => {
55859
55862
  return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
55860
55863
  title: value,
@@ -55865,6 +55868,7 @@ const getColumns$1 = ({
55865
55868
  title: t("Name"),
55866
55869
  dataIndex: "name",
55867
55870
  key: "name",
55871
+ show: true,
55868
55872
  render: (value, all) => {
55869
55873
  return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
55870
55874
  title: value,
@@ -55875,6 +55879,7 @@ const getColumns$1 = ({
55875
55879
  title: t("Category"),
55876
55880
  dataIndex: "category",
55877
55881
  key: "category",
55882
+ show: true,
55878
55883
  render: (value, all) => {
55879
55884
  const label = findOptions(value, selectOptions?.category);
55880
55885
  return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
@@ -55886,6 +55891,7 @@ const getColumns$1 = ({
55886
55891
  title: t("Country"),
55887
55892
  dataIndex: "country",
55888
55893
  key: "country",
55894
+ show: true,
55889
55895
  render: (value, all) => {
55890
55896
  const label = findOptions(value, selectOptions?.country);
55891
55897
  return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
@@ -55898,7 +55904,7 @@ const getColumns$1 = ({
55898
55904
  dataIndex: "administrativeLevel1",
55899
55905
  key: "administrativeLevel1",
55900
55906
  ellipsis: true,
55901
- show: true,
55907
+ show: entity.includes("locations"),
55902
55908
  render: (value, all) => {
55903
55909
  let label;
55904
55910
  if (all?.administrativeLevel1 && value === all?.administrativeLevel1) {
@@ -55915,6 +55921,7 @@ const getColumns$1 = ({
55915
55921
  title: t("Territory"),
55916
55922
  dataIndex: "administrativeLevel2",
55917
55923
  key: "administrativeLevel2",
55924
+ show: entity.includes("locations"),
55918
55925
  render: (value, all) => {
55919
55926
  let label;
55920
55927
  if (all?.administrativeLevel2 && value === all?.administrativeLevel2) {
@@ -55927,7 +55934,7 @@ const getColumns$1 = ({
55927
55934
  children: label || '-'
55928
55935
  });
55929
55936
  }
55930
- }];
55937
+ }].filter(c => c?.show);
55931
55938
  };
55932
55939
 
55933
55940
  const {
@@ -55940,7 +55947,8 @@ function CombineLocationModal({
55940
55947
  onSuccess,
55941
55948
  selectedLocations,
55942
55949
  selectOptions,
55943
- module
55950
+ module,
55951
+ entity
55944
55952
  }) {
55945
55953
  const {
55946
55954
  token
@@ -55952,9 +55960,10 @@ function CombineLocationModal({
55952
55960
  t,
55953
55961
  selectOptions,
55954
55962
  module,
55955
- selectedLocations
55963
+ selectedLocations,
55964
+ entity
55956
55965
  });
55957
- }, [selectedLocations, t, selectOptions, module]);
55966
+ }, [selectedLocations, t, selectOptions, module, entity]);
55958
55967
  const onSubmit = () => {
55959
55968
  MainForm.validateFields().then(data => {
55960
55969
  const ids = selectedLocations.map(location => location._id);
@@ -55973,6 +55982,13 @@ function CombineLocationModal({
55973
55982
  width: 1100,
55974
55983
  disabled: isDisabled,
55975
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
+ },
55976
55992
  children: [/*#__PURE__*/jsxRuntime.jsxs(Container, {
55977
55993
  children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
55978
55994
  className: "daf-table-wrapper no-pagination",
@@ -56051,32 +56067,34 @@ function CombineLocationModal({
56051
56067
  }).filter((option, index, self) => index === self.findIndex(o => o.value === option.value)),
56052
56068
  placeholder: t("admin::country")
56053
56069
  })
56054
- }), /*#__PURE__*/jsxRuntime.jsx(antd.Form.Item, {
56055
- className: "flex-1",
56056
- name: "administrativeLevel1",
56057
- children: /*#__PURE__*/jsxRuntime.jsx(antd.Select, {
56058
- placeholder: t("Province"),
56059
- options: selectedLocations.map(location => {
56060
- const _data = getNameByLevel(location?.linking?.SCL, "level_1");
56061
- return {
56062
- label: _data?.name || "-",
56063
- value: _data?.id || "-"
56064
- };
56065
- }).filter((option, index, self) => index === self.findIndex(o => o.value === option.value))
56066
- })
56067
- }), /*#__PURE__*/jsxRuntime.jsx(antd.Form.Item, {
56068
- className: "flex-1",
56069
- name: "administrativeLevel2",
56070
- children: /*#__PURE__*/jsxRuntime.jsx(antd.Select, {
56071
- placeholder: t("Territory"),
56072
- options: selectedLocations.map(location => {
56073
- const _data = getNameByLevel(location?.linking?.SCL, "level_2");
56074
- return {
56075
- label: _data?.name || "-",
56076
- value: _data?.id || "-"
56077
- };
56078
- }).filter((option, index, self) => index === self.findIndex(o => o.value === option.value))
56079
- })
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
+ })]
56080
56098
  })]
56081
56099
  })]
56082
56100
  }), /*#__PURE__*/jsxRuntime.jsx("div", {
@@ -56155,9 +56173,10 @@ function LocationTable(_ref) {
56155
56173
  selectedLocations,
56156
56174
  setSelectedLocations,
56157
56175
  getRedirectLink,
56158
- selectOptions
56176
+ selectOptions,
56177
+ entity: headerTitle
56159
56178
  });
56160
- }, [t, goTo, module, token, selectedLocations, getRedirectLink, selectOptions]);
56179
+ }, [t, goTo, module, token, selectedLocations, getRedirectLink, selectOptions, headerTitle]);
56161
56180
  return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
56162
56181
  children: [/*#__PURE__*/jsxRuntime.jsxs(AdminTable, {
56163
56182
  filters: filter,
@@ -56234,7 +56253,8 @@ function LocationTable(_ref) {
56234
56253
  },
56235
56254
  selectedLocations: selectedLocations,
56236
56255
  selectOptions: selectOptions || {},
56237
- module: module
56256
+ module: module,
56257
+ entity: headerTitle
56238
56258
  })]
56239
56259
  });
56240
56260
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datastake-daf",
3
- "version": "0.6.347",
3
+ "version": "0.6.349",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^5.2.5",
6
6
  "@antv/g2": "^5.1.1",
@@ -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: true,
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
- <Form.Item className="flex-1" name="administrativeLevel1">
159
- <Select
172
+ {entity.includes("locations") && (
173
+ <>
174
+ <Form.Item className="flex-1" name="administrativeLevel1">
175
+ <Select
160
176
  placeholder={t("Province")}
161
- options={selectedLocations.map((location) => {
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
- }).filter(
183
+ };
184
+ })
185
+ .filter(
168
186
  (option, index, self) =>
169
187
  index === self.findIndex((o) => o.value === option.value),
170
- )}
171
- ></Select>
172
- </Form.Item>
188
+ )}
189
+ />
190
+ </Form.Item>
173
191
 
174
- <Form.Item className="flex-1" name="administrativeLevel2">
175
- <Select
192
+ <Form.Item className="flex-1" name="administrativeLevel2">
193
+ <Select
176
194
  placeholder={t("Territory")}
177
- options={selectedLocations.map((location) => {
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
- }).filter(
201
+ };
202
+ })
203
+ .filter(
184
204
  (option, index, self) =>
185
205
  index === self.findIndex((o) => o.value === option.value),
186
- )}
187
- ></Select>
188
- </Form.Item>
206
+ )}
207
+ />
208
+ </Form.Item>
209
+ </>
210
+ )}
189
211
  </Form>
190
212
  </Container>
191
213
  <div style={{ height: 57 }} />
@@ -460,6 +460,7 @@ export const Primary = {
460
460
  loading: false,
461
461
  isMobile: true,
462
462
  module: "tif",
463
+ headerTitle: "locations",
463
464
  config: {
464
465
  options: {
465
466
  countries: [
@@ -77,6 +77,7 @@ export const getColumns = ({
77
77
  selectedLocations,
78
78
  setSelectedLocations,
79
79
  selectOptions,
80
+ entity,
80
81
  }) => {
81
82
  const cols = [
82
83
  {
@@ -173,7 +174,7 @@ export const getColumns = ({
173
174
  dataIndex: "administrativeLevel1",
174
175
  key: "administrativeLevel1",
175
176
  ellipsis: true,
176
- show: true,
177
+ show: entity.includes("locations"),
177
178
  render: (value, all) => {
178
179
  if (all.empty) {
179
180
  return <div className="daf-default-cell" />;
@@ -193,7 +194,7 @@ export const getColumns = ({
193
194
  title: t("Territory"),
194
195
  dataIndex: "administrativeLevel2",
195
196
  key: "administrativeLevel2",
196
- show: true,
197
+ show: entity.includes("locations"),
197
198
  ellipsis: true,
198
199
  render: (value, all) => {
199
200
  if (all.empty) {
@@ -263,7 +264,7 @@ export const getColumns = ({
263
264
  title: "",
264
265
  dataIndex: "actions",
265
266
  key: "actions",
266
- width: 70,
267
+ width: 60,
267
268
  show: true,
268
269
  render: (value, all) => {
269
270
  if (all.empty) {
@@ -80,8 +80,9 @@ export default function LocationTable({
80
80
  setSelectedLocations,
81
81
  getRedirectLink,
82
82
  selectOptions,
83
+ entity: headerTitle
83
84
  });
84
- }, [t, goTo, module, token, selectedLocations, getRedirectLink, selectOptions]);
85
+ }, [t, goTo, module, token, selectedLocations, getRedirectLink, selectOptions, headerTitle]);
85
86
 
86
87
  return (
87
88
  <>
@@ -172,6 +173,7 @@ export default function LocationTable({
172
173
  selectedLocations={selectedLocations}
173
174
  selectOptions={selectOptions || {}}
174
175
  module={module}
176
+ entity={headerTitle}
175
177
  />
176
178
  </>
177
179
  );