datastake-daf 0.6.348 → 0.6.350

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.
@@ -9437,7 +9437,7 @@ createCommonjsModule(function (module, exports) {
9437
9437
  !function(e,n){module.exports=n();}(commonjsGlobal,(function(){return {name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(e){var n=["th","st","nd","rd"],t=e%100;return "["+e+(n[(t-20)%10]||n[t]||n[0])+"]"}}}));
9438
9438
  });
9439
9439
 
9440
- const _excluded$y = ["view", "module", "scope", "form", "meta"];
9440
+ const _excluded$y = ["view", "module", "scope", "form", "meta", "createdAt", "updatedAt"];
9441
9441
  dayjs__default["default"].extend(customParseFormat);
9442
9442
  dayjs__default["default"].extend(utc);
9443
9443
  dayjs__default["default"].extend(utc);
@@ -9809,7 +9809,9 @@ const filterCreateData = data => {
9809
9809
  module,
9810
9810
  scope,
9811
9811
  form,
9812
- meta
9812
+ meta,
9813
+ createdAt,
9814
+ updatedAt
9813
9815
  } = data,
9814
9816
  rest = _objectWithoutProperties(data, _excluded$y);
9815
9817
  const _meta = isObjectEmpty(meta) ? undefined : meta;
@@ -55635,7 +55637,7 @@ const getColumns$2 = ({
55635
55637
  selectedLocations,
55636
55638
  setSelectedLocations,
55637
55639
  selectOptions,
55638
- namespace
55640
+ entity
55639
55641
  }) => {
55640
55642
  const cols = [{
55641
55643
  title: "",
@@ -55736,7 +55738,7 @@ const getColumns$2 = ({
55736
55738
  dataIndex: "administrativeLevel1",
55737
55739
  key: "administrativeLevel1",
55738
55740
  ellipsis: true,
55739
- show: namespace.includes("locations"),
55741
+ show: entity.includes("locations"),
55740
55742
  render: (value, all) => {
55741
55743
  if (all.empty) {
55742
55744
  return /*#__PURE__*/jsxRuntime.jsx("div", {
@@ -55758,7 +55760,7 @@ const getColumns$2 = ({
55758
55760
  title: t("Territory"),
55759
55761
  dataIndex: "administrativeLevel2",
55760
55762
  key: "administrativeLevel2",
55761
- show: namespace.includes("locations"),
55763
+ show: entity.includes("locations"),
55762
55764
  ellipsis: true,
55763
55765
  render: (value, all) => {
55764
55766
  if (all.empty) {
@@ -55850,12 +55852,14 @@ const getColumns$2 = ({
55850
55852
  const getColumns$1 = ({
55851
55853
  t,
55852
55854
  selectOptions,
55853
- module
55855
+ module,
55856
+ entity
55854
55857
  }) => {
55855
55858
  return [{
55856
55859
  title: t("admin::organisation_id"),
55857
55860
  dataIndex: "datastakeId",
55858
55861
  key: "datastakeId",
55862
+ show: true,
55859
55863
  render: (value, all) => {
55860
55864
  return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
55861
55865
  title: value,
@@ -55866,6 +55870,7 @@ const getColumns$1 = ({
55866
55870
  title: t("Name"),
55867
55871
  dataIndex: "name",
55868
55872
  key: "name",
55873
+ show: true,
55869
55874
  render: (value, all) => {
55870
55875
  return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
55871
55876
  title: value,
@@ -55876,6 +55881,7 @@ const getColumns$1 = ({
55876
55881
  title: t("Category"),
55877
55882
  dataIndex: "category",
55878
55883
  key: "category",
55884
+ show: true,
55879
55885
  render: (value, all) => {
55880
55886
  const label = findOptions(value, selectOptions?.category);
55881
55887
  return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
@@ -55887,6 +55893,7 @@ const getColumns$1 = ({
55887
55893
  title: t("Country"),
55888
55894
  dataIndex: "country",
55889
55895
  key: "country",
55896
+ show: true,
55890
55897
  render: (value, all) => {
55891
55898
  const label = findOptions(value, selectOptions?.country);
55892
55899
  return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
@@ -55899,7 +55906,7 @@ const getColumns$1 = ({
55899
55906
  dataIndex: "administrativeLevel1",
55900
55907
  key: "administrativeLevel1",
55901
55908
  ellipsis: true,
55902
- show: true,
55909
+ show: entity.includes("locations"),
55903
55910
  render: (value, all) => {
55904
55911
  let label;
55905
55912
  if (all?.administrativeLevel1 && value === all?.administrativeLevel1) {
@@ -55916,6 +55923,7 @@ const getColumns$1 = ({
55916
55923
  title: t("Territory"),
55917
55924
  dataIndex: "administrativeLevel2",
55918
55925
  key: "administrativeLevel2",
55926
+ show: entity.includes("locations"),
55919
55927
  render: (value, all) => {
55920
55928
  let label;
55921
55929
  if (all?.administrativeLevel2 && value === all?.administrativeLevel2) {
@@ -55928,7 +55936,7 @@ const getColumns$1 = ({
55928
55936
  children: label || '-'
55929
55937
  });
55930
55938
  }
55931
- }];
55939
+ }].filter(c => c?.show);
55932
55940
  };
55933
55941
 
55934
55942
  const {
@@ -55941,7 +55949,8 @@ function CombineLocationModal({
55941
55949
  onSuccess,
55942
55950
  selectedLocations,
55943
55951
  selectOptions,
55944
- module
55952
+ module,
55953
+ entity
55945
55954
  }) {
55946
55955
  const {
55947
55956
  token
@@ -55953,9 +55962,10 @@ function CombineLocationModal({
55953
55962
  t,
55954
55963
  selectOptions,
55955
55964
  module,
55956
- selectedLocations
55965
+ selectedLocations,
55966
+ entity
55957
55967
  });
55958
- }, [selectedLocations, t, selectOptions, module]);
55968
+ }, [selectedLocations, t, selectOptions, module, entity]);
55959
55969
  const onSubmit = () => {
55960
55970
  MainForm.validateFields().then(data => {
55961
55971
  const ids = selectedLocations.map(location => location._id);
@@ -55974,6 +55984,13 @@ function CombineLocationModal({
55974
55984
  width: 1100,
55975
55985
  disabled: isDisabled,
55976
55986
  destroyOnClose: true,
55987
+ onValuesChange: () => {
55988
+ setIsDisabled(() => {
55989
+ const values = MainForm.getFieldsValue();
55990
+ const requiredFields = entity === "location" ? ["id", "name", "category", "country", "administrativeLevel1", "administrativeLevel2"] : ["id", "name", "category", "country"];
55991
+ return requiredFields.some(field => values[field] === undefined);
55992
+ });
55993
+ },
55977
55994
  children: [/*#__PURE__*/jsxRuntime.jsxs(Container, {
55978
55995
  children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
55979
55996
  className: "daf-table-wrapper no-pagination",
@@ -56052,32 +56069,34 @@ function CombineLocationModal({
56052
56069
  }).filter((option, index, self) => index === self.findIndex(o => o.value === option.value)),
56053
56070
  placeholder: t("admin::country")
56054
56071
  })
56055
- }), /*#__PURE__*/jsxRuntime.jsx(antd.Form.Item, {
56056
- className: "flex-1",
56057
- name: "administrativeLevel1",
56058
- children: /*#__PURE__*/jsxRuntime.jsx(antd.Select, {
56059
- placeholder: t("Province"),
56060
- options: selectedLocations.map(location => {
56061
- const _data = getNameByLevel(location?.linking?.SCL, "level_1");
56062
- return {
56063
- label: _data?.name || "-",
56064
- value: _data?.id || "-"
56065
- };
56066
- }).filter((option, index, self) => index === self.findIndex(o => o.value === option.value))
56067
- })
56068
- }), /*#__PURE__*/jsxRuntime.jsx(antd.Form.Item, {
56069
- className: "flex-1",
56070
- name: "administrativeLevel2",
56071
- children: /*#__PURE__*/jsxRuntime.jsx(antd.Select, {
56072
- placeholder: t("Territory"),
56073
- options: selectedLocations.map(location => {
56074
- const _data = getNameByLevel(location?.linking?.SCL, "level_2");
56075
- return {
56076
- label: _data?.name || "-",
56077
- value: _data?.id || "-"
56078
- };
56079
- }).filter((option, index, self) => index === self.findIndex(o => o.value === option.value))
56080
- })
56072
+ }), entity.includes("locations") && /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
56073
+ children: [/*#__PURE__*/jsxRuntime.jsx(antd.Form.Item, {
56074
+ className: "flex-1",
56075
+ name: "administrativeLevel1",
56076
+ children: /*#__PURE__*/jsxRuntime.jsx(antd.Select, {
56077
+ placeholder: t("Province"),
56078
+ options: selectedLocations.map(location => {
56079
+ const _data = getNameByLevel(location?.linking?.SCL, "level_1");
56080
+ return {
56081
+ label: _data?.name || "-",
56082
+ value: _data?.id || "-"
56083
+ };
56084
+ }).filter((option, index, self) => index === self.findIndex(o => o.value === option.value))
56085
+ })
56086
+ }), /*#__PURE__*/jsxRuntime.jsx(antd.Form.Item, {
56087
+ className: "flex-1",
56088
+ name: "administrativeLevel2",
56089
+ children: /*#__PURE__*/jsxRuntime.jsx(antd.Select, {
56090
+ placeholder: t("Territory"),
56091
+ options: selectedLocations.map(location => {
56092
+ const _data = getNameByLevel(location?.linking?.SCL, "level_2");
56093
+ return {
56094
+ label: _data?.name || "-",
56095
+ value: _data?.id || "-"
56096
+ };
56097
+ }).filter((option, index, self) => index === self.findIndex(o => o.value === option.value))
56098
+ })
56099
+ })]
56081
56100
  })]
56082
56101
  })]
56083
56102
  }), /*#__PURE__*/jsxRuntime.jsx("div", {
@@ -56157,7 +56176,7 @@ function LocationTable(_ref) {
56157
56176
  setSelectedLocations,
56158
56177
  getRedirectLink,
56159
56178
  selectOptions,
56160
- namespace: headerTitle
56179
+ entity: headerTitle
56161
56180
  });
56162
56181
  }, [t, goTo, module, token, selectedLocations, getRedirectLink, selectOptions, headerTitle]);
56163
56182
  return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
@@ -56236,7 +56255,8 @@ function LocationTable(_ref) {
56236
56255
  },
56237
56256
  selectedLocations: selectedLocations,
56238
56257
  selectOptions: selectOptions || {},
56239
- module: module
56258
+ module: module,
56259
+ entity: headerTitle
56240
56260
  })]
56241
56261
  });
56242
56262
  }
@@ -4339,6 +4339,8 @@ const filterCreateData = data => {
4339
4339
  scope,
4340
4340
  form,
4341
4341
  meta,
4342
+ createdAt,
4343
+ updatedAt,
4342
4344
  ...rest
4343
4345
  } = data;
4344
4346
  const _meta = isObjectEmpty(meta) ? undefined : meta;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datastake-daf",
3
- "version": "0.6.348",
3
+ "version": "0.6.350",
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,7 +77,7 @@ export const getColumns = ({
77
77
  selectedLocations,
78
78
  setSelectedLocations,
79
79
  selectOptions,
80
- namespace,
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: namespace.includes("locations"),
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: namespace.includes("locations"),
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
- namespace: headerTitle
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
  );
@@ -669,7 +669,7 @@ const isObjectEmpty = (obj) => {
669
669
 
670
670
  export const filterCreateData = (data) => {
671
671
  // eslint-disable-next-line no-unused-vars
672
- const { view, module, scope, form, meta, ...rest } = data;
672
+ const { view, module, scope, form, meta, createdAt, updatedAt, ...rest } = data;
673
673
  const _meta = isObjectEmpty(meta) ? undefined : meta;
674
674
  return { ...rest, meta: _meta };
675
675
  };