datastake-daf 0.6.732 → 0.6.733

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.
@@ -13518,7 +13518,7 @@ const getTabs = t => {
13518
13518
  label: t("Events")
13519
13519
  }];
13520
13520
  };
13521
- const getFiltersConfig$1 = (t, filters, locationCategories) => {
13521
+ const getFiltersConfig$2 = (t, filters, locationCategories) => {
13522
13522
  const value = filters.type ? {
13523
13523
  value: filters.type
13524
13524
  } : {};
@@ -13721,7 +13721,7 @@ function MineSites({
13721
13721
  config: dataFetchConfig
13722
13722
  });
13723
13723
  const tabs = React.useMemo(() => getTabs(t), [t]);
13724
- const filtersConfig = React.useMemo(() => getFiltersConfig$1(t, filters, locationCategories), [activeTab, filters, t, locationCategories]);
13724
+ const filtersConfig = React.useMemo(() => getFiltersConfig$2(t, filters, locationCategories), [activeTab, filters, t, locationCategories]);
13725
13725
  const onFilterChange = filters => {
13726
13726
  setFilters(p => ({
13727
13727
  ...p,
@@ -15957,7 +15957,7 @@ function AvatarGroup({
15957
15957
  });
15958
15958
  }
15959
15959
 
15960
- const getColumns = ({
15960
+ const getColumns$1 = ({
15961
15961
  t,
15962
15962
  goTo,
15963
15963
  user,
@@ -16050,9 +16050,9 @@ const getColumns = ({
16050
16050
  }) : '-';
16051
16051
  }
16052
16052
  }, {
16053
- title: t("Date"),
16054
- dataIndex: "date",
16055
- key: "date",
16053
+ title: t("Last Update"),
16054
+ dataIndex: "updatedAt",
16055
+ key: "updatedAt",
16056
16056
  width: 125,
16057
16057
  render: (date, all) => {
16058
16058
  if (all.empty) {
@@ -16113,11 +16113,11 @@ const getColumns = ({
16113
16113
  }
16114
16114
  }].filter(column => column.show !== false);
16115
16115
 
16116
- const checkboxConfig = {
16116
+ const checkboxConfig$1 = {
16117
16117
  name: 'Name',
16118
16118
  datastakeId: 'ID'
16119
16119
  };
16120
- const getFiltersConfig = ({
16120
+ const getFiltersConfig$1 = ({
16121
16121
  t
16122
16122
  }) => {
16123
16123
  return {
@@ -16135,11 +16135,11 @@ const getFiltersConfig = ({
16135
16135
  }
16136
16136
  };
16137
16137
  };
16138
- const filtersConfig = {
16138
+ const filtersConfig$1 = {
16139
16139
  name: '',
16140
16140
  datastakeId: ''
16141
16141
  };
16142
- const getFilterOptions = (options, t) => {
16142
+ const getFilterOptions$1 = (options, t) => {
16143
16143
  const {
16144
16144
  countries
16145
16145
  } = options || {};
@@ -29848,7 +29848,7 @@ function DynamicForm({
29848
29848
  });
29849
29849
  }
29850
29850
 
29851
- const StakeholdersCreate = ({
29851
+ const StakeholdersCreate$1 = ({
29852
29852
  namespace = 'stakeholders',
29853
29853
  view = 'scoping',
29854
29854
  edit = false,
@@ -29976,7 +29976,7 @@ const StakeholdersTable = ({
29976
29976
  }) => {
29977
29977
  const [selectOptions, setSelectOptions] = React.useState();
29978
29978
  const [activeTab, setActiveTab] = React.useState();
29979
- const columns = React.useMemo(() => getColumns({
29979
+ const columns = React.useMemo(() => getColumns$1({
29980
29980
  t,
29981
29981
  goTo,
29982
29982
  user,
@@ -30006,6 +30006,441 @@ const StakeholdersTable = ({
30006
30006
  tab: activeTab
30007
30007
  }, 'stakeholders');
30008
30008
  }, [paginationQuery, otherParams, searchParams, activeTab]);
30009
+ const selectFiltersConfig = React.useMemo(() => {
30010
+ return getFiltersConfig$1({
30011
+ t
30012
+ });
30013
+ }, [t]);
30014
+ React.useEffect(() => {
30015
+ setSelectOptions(prev => ({
30016
+ ...prev,
30017
+ ...getFilterOptions$1(options)
30018
+ }));
30019
+ }, [options, t]);
30020
+ const handleActiveTabChange = React.useCallback(value => {
30021
+ setActiveTab(value);
30022
+ }, []);
30023
+ return /*#__PURE__*/jsxRuntime.jsx(TablePageWithTabs, {
30024
+ t: t,
30025
+ title: t("Stakeholders"),
30026
+ breadCrumbs: breadCrumbs,
30027
+ location: location,
30028
+ loading: loading,
30029
+ goTo: goTo,
30030
+ defaultActiveTab: "all",
30031
+ columns: columns,
30032
+ data: data,
30033
+ checkboxConfig: checkboxConfig$1,
30034
+ APP: APP,
30035
+ getApiBaseUrl: getApiBaseUrl,
30036
+ selectOptions: selectOptions,
30037
+ selectFiltersConfig: selectFiltersConfig,
30038
+ getRedirectLink: getRedirectLink,
30039
+ filtersConfig: filtersConfig$1,
30040
+ isMobile: isMobile,
30041
+ view: "stakeholders",
30042
+ getActiveTab: handleActiveTabChange,
30043
+ onDownload: () => {
30044
+ console.log("download");
30045
+ },
30046
+ drawerTitle: t("Create Stakeholder"),
30047
+ children: ({
30048
+ onDrawerClose
30049
+ }) => /*#__PURE__*/jsxRuntime.jsx(StakeholdersCreate$1, {
30050
+ t: t,
30051
+ goTo: goTo,
30052
+ user: user,
30053
+ APP: APP,
30054
+ getApiBaseUrl: getApiBaseUrl,
30055
+ getAppHeader: getAppHeader,
30056
+ getData: getFormData,
30057
+ saveData: saveFormData,
30058
+ loading: formLoading,
30059
+ onSubmitted: (type, m, data) => {
30060
+ if (data.datastakeId) {
30061
+ displayMessage(type, t("affirmations::subject-created-successfully") || m);
30062
+ goTo(`/app/locations`);
30063
+ }
30064
+ },
30065
+ onCancel: onDrawerClose,
30066
+ query: query,
30067
+ ajaxForms: ajaxForms,
30068
+ changeAjaxForms: changeAjaxForms,
30069
+ ajaxOptions: ajaxOptions,
30070
+ changeAjaxOptions: changeAjaxOptions,
30071
+ formData: formData,
30072
+ formValue: formValue,
30073
+ form: form
30074
+ })
30075
+ });
30076
+ };
30077
+
30078
+ const getColumns = ({
30079
+ t,
30080
+ goTo,
30081
+ user,
30082
+ options,
30083
+ activeTab,
30084
+ getRedirectLink,
30085
+ theme,
30086
+ subject,
30087
+ data,
30088
+ dataOptions
30089
+ }) => [{
30090
+ dataIndex: 'datastakeId',
30091
+ title: t('ID'),
30092
+ ellipsis: true,
30093
+ show: true,
30094
+ render: (v, all) => {
30095
+ if (all.empty) {
30096
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
30097
+ className: "daf-default-cell"
30098
+ });
30099
+ }
30100
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
30101
+ title: v,
30102
+ children: v
30103
+ });
30104
+ }
30105
+ }, {
30106
+ dataIndex: 'name',
30107
+ title: t('Name'),
30108
+ ellipsis: true,
30109
+ show: true,
30110
+ render: (v, all) => {
30111
+ if (all.empty) {
30112
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
30113
+ className: "daf-default-cell"
30114
+ });
30115
+ }
30116
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
30117
+ title: v,
30118
+ children: v
30119
+ });
30120
+ }
30121
+ }, {
30122
+ dataIndex: 'category',
30123
+ title: t('Category'),
30124
+ ellipsis: true,
30125
+ show: true,
30126
+ render: (v, all) => {
30127
+ if (all.empty) {
30128
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
30129
+ className: "daf-default-cell"
30130
+ });
30131
+ }
30132
+ const category = findOptions(v, dataOptions?.locationCategories);
30133
+ return category ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
30134
+ title: category,
30135
+ children: category
30136
+ }) : '-';
30137
+ }
30138
+ }, {
30139
+ dataIndex: 'country',
30140
+ title: t('Country'),
30141
+ ellipsis: true,
30142
+ show: true,
30143
+ render: (v, all) => {
30144
+ if (all.empty) {
30145
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
30146
+ className: "daf-default-cell"
30147
+ });
30148
+ }
30149
+ const country = findOptions(v, options?.countries);
30150
+ return country ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
30151
+ title: country,
30152
+ children: country
30153
+ }) : '-';
30154
+ }
30155
+ }, {
30156
+ dataIndex: 'administrativeLevel1',
30157
+ title: t('Region'),
30158
+ ellipsis: true,
30159
+ show: true,
30160
+ render: (v, all) => {
30161
+ if (all.empty) {
30162
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
30163
+ className: "daf-default-cell"
30164
+ });
30165
+ }
30166
+ findOptions(v, options?.countries);
30167
+ return '-';
30168
+ }
30169
+ }, {
30170
+ dataIndex: 'administrativeLevel2',
30171
+ title: t('District'),
30172
+ ellipsis: true,
30173
+ show: true,
30174
+ render: (v, all) => {
30175
+ if (all.empty) {
30176
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
30177
+ className: "daf-default-cell"
30178
+ });
30179
+ }
30180
+ findOptions(v, options?.countries);
30181
+ return '-';
30182
+ }
30183
+ }, {
30184
+ title: t("Last Update"),
30185
+ dataIndex: "updatedAt",
30186
+ key: "updatedAt",
30187
+ width: 125,
30188
+ render: (date, all) => {
30189
+ if (all.empty) {
30190
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
30191
+ className: "daf-default-cell"
30192
+ });
30193
+ }
30194
+ const _date = date ? renderDateFormatted(date, "DD MMM YYYY", user?.language || 'en') : "-";
30195
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
30196
+ title: _date,
30197
+ children: _date
30198
+ });
30199
+ },
30200
+ ellipsis: true
30201
+ }, {
30202
+ title: t("Sources"),
30203
+ dataIndex: "sources",
30204
+ key: "sources",
30205
+ show: activeTab !== "own",
30206
+ render: (val, all) => {
30207
+ if (all.empty) {
30208
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
30209
+ className: "daf-default-cell"
30210
+ });
30211
+ }
30212
+ if (!val || val?.length === 0) {
30213
+ return "--";
30214
+ }
30215
+ return /*#__PURE__*/jsxRuntime.jsx(AvatarGroup, {
30216
+ items: val
30217
+ });
30218
+ }
30219
+ }, {
30220
+ id: 'actions',
30221
+ title: "",
30222
+ width: 60,
30223
+ render: (_, all) => {
30224
+ if (all.empty) {
30225
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
30226
+ className: "daf-default-cell"
30227
+ });
30228
+ }
30229
+ const link = `/app/view/${subject}/${all.datastakeId}`;
30230
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
30231
+ style: {
30232
+ display: "flex",
30233
+ justifyContent: "center"
30234
+ },
30235
+ children: /*#__PURE__*/jsxRuntime.jsx("a", {
30236
+ href: getRedirectLink(link),
30237
+ children: /*#__PURE__*/jsxRuntime.jsx(CustomIcon, {
30238
+ name: "Link",
30239
+ size: 15,
30240
+ color: theme.baseGray70
30241
+ })
30242
+ })
30243
+ });
30244
+ }
30245
+ }].filter(column => column.show !== false);
30246
+
30247
+ const checkboxConfig = {
30248
+ name: 'Name',
30249
+ datastakeId: 'ID'
30250
+ };
30251
+ const getFiltersConfig = ({
30252
+ t
30253
+ }) => {
30254
+ return {
30255
+ country: {
30256
+ type: 'select',
30257
+ placeholder: t('Country'),
30258
+ style: {
30259
+ flex: 1
30260
+ },
30261
+ labelStyle: {
30262
+ flex: 1
30263
+ },
30264
+ getLabel: option => option.label,
30265
+ getValue: option => option.value
30266
+ }
30267
+ };
30268
+ };
30269
+ const filtersConfig = {
30270
+ name: '',
30271
+ datastakeId: ''
30272
+ };
30273
+ const getFilterOptions = (options, t) => {
30274
+ const {
30275
+ countries
30276
+ } = options || {};
30277
+ const _default = {
30278
+ country: countries
30279
+ };
30280
+ return _default;
30281
+ };
30282
+
30283
+ const StakeholdersCreate = ({
30284
+ namespace = 'locations',
30285
+ view = 'scoping',
30286
+ edit = false,
30287
+ formData = {},
30288
+ loading = false,
30289
+ onSubmitted = () => {},
30290
+ onCancel = () => {},
30291
+ getData = () => {},
30292
+ saveData = () => {},
30293
+ form: formConfig = {},
30294
+ formValue = {},
30295
+ defaultData = {},
30296
+ user = {},
30297
+ APP,
30298
+ query,
30299
+ goTo = () => {},
30300
+ t = () => {},
30301
+ ajaxForms = {},
30302
+ changeAjaxForms = () => {},
30303
+ ajaxOptions = {},
30304
+ changeAjaxOptions = () => {},
30305
+ getAppHeader = () => {},
30306
+ getApiBaseUrl = () => {}
30307
+ }) => {
30308
+ let {
30309
+ form = {},
30310
+ data = defaultData || {}
30311
+ } = !edit ? formData[`${APP}-${view}`] || {} : {
30312
+ form: formConfig,
30313
+ data: formValue
30314
+ };
30315
+ React.useEffect(() => {
30316
+ if (Object.keys(form).length === 0 && !formData[`${APP}-${view}`]) {
30317
+ if (!edit) {
30318
+ getData({
30319
+ namespace,
30320
+ module: APP,
30321
+ view,
30322
+ scope: 'global'
30323
+ });
30324
+ } else {
30325
+ form = formConfig;
30326
+ data = formValue;
30327
+ }
30328
+ }
30329
+ }, [edit, user?.language]);
30330
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
30331
+ className: "daf-create-form",
30332
+ children: /*#__PURE__*/jsxRuntime.jsx(DynamicForm, {
30333
+ form: form,
30334
+ data: data,
30335
+ showSaveAndNext: false,
30336
+ module: APP,
30337
+ onCancel: onCancel,
30338
+ isCreate: true,
30339
+ t: t,
30340
+ excludedKeys: ["title"],
30341
+ user: user,
30342
+ ajaxForms: ajaxForms,
30343
+ ajaxOptions: ajaxOptions,
30344
+ getAppHeader: getAppHeader,
30345
+ getApiBaseUrl: getApiBaseUrl,
30346
+ changeAjaxOptions: changeAjaxOptions,
30347
+ app: APP,
30348
+ query: query,
30349
+ goTo: goTo,
30350
+ changeAjaxForms: changeAjaxForms,
30351
+ submit: (payload, setSelectedFormNext) => {
30352
+ const payloadData = {
30353
+ ...payload,
30354
+ module: APP,
30355
+ namespace
30356
+ };
30357
+ const newPayload = {
30358
+ ...defaultData,
30359
+ ...payloadData
30360
+ };
30361
+ const callback = (type, m, data) => {
30362
+ if (setSelectedFormNext) {
30363
+ setSelectedFormNext();
30364
+ }
30365
+ if (type === MessageTypes.SUCCESS) {
30366
+ if (onSubmitted) onSubmitted(type, m, data);
30367
+ } else {
30368
+ antd.message.error(m);
30369
+ }
30370
+ };
30371
+ saveData(!data && !data.id ? newPayload : Object.assign(newPayload, {
30372
+ id: data.id
30373
+ }), callback);
30374
+ },
30375
+ isFormDisabled: () => {
30376
+ return !data || !data.typeOfEvent;
30377
+ }
30378
+ })
30379
+ });
30380
+ };
30381
+
30382
+ const LocationsTable = ({
30383
+ t = () => {},
30384
+ goTo = () => {},
30385
+ user = {},
30386
+ options = {},
30387
+ getRedirectLink = () => {},
30388
+ theme = {},
30389
+ loading = false,
30390
+ data = {},
30391
+ isMobile,
30392
+ APP,
30393
+ location,
30394
+ getData = () => {},
30395
+ getApiBaseUrl = () => {},
30396
+ getAppHeader = () => {},
30397
+ getFormData = () => {},
30398
+ saveFormData = () => {},
30399
+ formLoading = false,
30400
+ query = {},
30401
+ ajaxForms = {},
30402
+ changeAjaxForms = () => {},
30403
+ ajaxOptions = {},
30404
+ changeAjaxOptions = () => {},
30405
+ formData = {},
30406
+ formValue = {},
30407
+ form = {},
30408
+ dataOptions = {}
30409
+ }) => {
30410
+ const [selectOptions, setSelectOptions] = React.useState();
30411
+ const [activeTab, setActiveTab] = React.useState();
30412
+ const columns = React.useMemo(() => getColumns({
30413
+ t,
30414
+ goTo,
30415
+ user,
30416
+ options,
30417
+ activeTab,
30418
+ getRedirectLink,
30419
+ theme,
30420
+ subject: 'location',
30421
+ data,
30422
+ dataOptions
30423
+ }), [t, goTo, user, options, activeTab, getRedirectLink, theme, data, dataOptions]);
30424
+ const breadCrumbs = [];
30425
+ const {
30426
+ paginationQuery,
30427
+ searchParams,
30428
+ otherParams
30429
+ } = useGetQueryParams({
30430
+ location
30431
+ });
30432
+ React.useEffect(() => {
30433
+ getData({
30434
+ pagination: paginationQuery,
30435
+ ...(Object.keys(otherParams).length > 0 && {
30436
+ filters: otherParams
30437
+ }),
30438
+ ...(Object.keys(searchParams).length > 0 && {
30439
+ search: searchParams
30440
+ }),
30441
+ tab: activeTab
30442
+ }, 'locations');
30443
+ }, [paginationQuery, otherParams, searchParams, activeTab]);
30009
30444
  const selectFiltersConfig = React.useMemo(() => {
30010
30445
  return getFiltersConfig({
30011
30446
  t
@@ -30022,7 +30457,7 @@ const StakeholdersTable = ({
30022
30457
  }, []);
30023
30458
  return /*#__PURE__*/jsxRuntime.jsx(TablePageWithTabs, {
30024
30459
  t: t,
30025
- title: t("Stakeholders"),
30460
+ title: t("Locations"),
30026
30461
  breadCrumbs: breadCrumbs,
30027
30462
  location: location,
30028
30463
  loading: loading,
@@ -30038,12 +30473,12 @@ const StakeholdersTable = ({
30038
30473
  getRedirectLink: getRedirectLink,
30039
30474
  filtersConfig: filtersConfig,
30040
30475
  isMobile: isMobile,
30041
- view: "stakeholders",
30476
+ view: "locations",
30042
30477
  getActiveTab: handleActiveTabChange,
30043
30478
  onDownload: () => {
30044
30479
  console.log("download");
30045
30480
  },
30046
- drawerTitle: t("Create Stakeholder"),
30481
+ drawerTitle: t("Create Location"),
30047
30482
  children: ({
30048
30483
  onDrawerClose
30049
30484
  }) => /*#__PURE__*/jsxRuntime.jsx(StakeholdersCreate, {
@@ -30053,16 +30488,14 @@ const StakeholdersTable = ({
30053
30488
  APP: APP,
30054
30489
  getApiBaseUrl: getApiBaseUrl,
30055
30490
  getAppHeader: getAppHeader,
30056
- defaultData: {
30057
- economicSector: 'miningMineralTrade'
30058
- },
30059
30491
  getData: getFormData,
30060
30492
  saveData: saveFormData,
30061
30493
  loading: formLoading,
30062
30494
  onSubmitted: (type, m, data) => {
30063
30495
  if (data.datastakeId) {
30064
30496
  displayMessage(type, t("affirmations::subject-created-successfully") || m);
30065
- goTo(`/app/edit/stakeholders/${data.datastakeId}`);
30497
+ // goTo(`/app/edit/stakeholders/${data.datastakeId}`);
30498
+ window.location.reload();
30066
30499
  }
30067
30500
  },
30068
30501
  onCancel: onDrawerClose,
@@ -30078,6 +30511,7 @@ const StakeholdersTable = ({
30078
30511
  });
30079
30512
  };
30080
30513
 
30514
+ exports.LocationsTable = LocationsTable;
30081
30515
  exports.StakeholdersTable = StakeholdersTable;
30082
30516
  exports.SupplyChainDashboard = SupplyChain;
30083
30517
  exports.TablePageWithTabs = TablePageWithTabs;
@@ -1359,7 +1359,7 @@ class LinkedSubjectsService extends BaseService {
1359
1359
  }) {
1360
1360
  const _namespace = getNamespace(namespace);
1361
1361
  return this.apiGet({
1362
- url: `/${_namespace}/associated-information`,
1362
+ url: `/${_namespace}`,
1363
1363
  isApp: true,
1364
1364
  params: query,
1365
1365
  signal
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datastake-daf",
3
- "version": "0.6.732",
3
+ "version": "0.6.733",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^5.2.5",
6
6
  "@antv/g2": "^5.1.1",
@@ -0,0 +1,144 @@
1
+ import React from 'react';
2
+ import { Tooltip } from 'antd';
3
+ import { findOptions } from '../../../../../helpers/StringHelper.js';
4
+ import { renderDateFormatted } from '../../../../../helpers/Forms.js';
5
+ import CustomIcon from '../../../../core/components/Icon/CustomIcon.jsx';
6
+ import AvatarGroup from '../../../../core/components/AvatarGroup/index.jsx';
7
+
8
+ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink, theme, subject, data, dataOptions}) => [
9
+ {
10
+ dataIndex: 'datastakeId',
11
+ title: t('ID'),
12
+ ellipsis: true,
13
+ show: true,
14
+ render: (v, all) => {
15
+ if (all.empty) {
16
+ return <div className="daf-default-cell" />
17
+ }
18
+
19
+ return <Tooltip title={v}>{v}</Tooltip>;
20
+ },
21
+ },
22
+ {
23
+ dataIndex: 'name',
24
+ title: t('Name'),
25
+ ellipsis: true,
26
+ show: true,
27
+ render: (v, all) => {
28
+ if (all.empty) {
29
+ return <div className="daf-default-cell" />
30
+ }
31
+
32
+ return <Tooltip title={v}>{v}</Tooltip>;
33
+ },
34
+ },
35
+ {
36
+ dataIndex: 'category',
37
+ title: t('Category'),
38
+ ellipsis: true,
39
+ show: true,
40
+ render: (v, all) => {
41
+ if (all.empty) {
42
+ return <div className="daf-default-cell" />
43
+ }
44
+
45
+ const category = findOptions(v, dataOptions?.locationCategories);
46
+
47
+ return category ? <Tooltip title={category}>{category}</Tooltip> : '-';
48
+ },
49
+ },
50
+ {
51
+ dataIndex: 'country',
52
+ title: t('Country'),
53
+ ellipsis: true,
54
+ show: true,
55
+ render: (v, all) => {
56
+ if (all.empty) {
57
+ return <div className="daf-default-cell" />
58
+ }
59
+
60
+ const country = findOptions(v, options?.countries);
61
+
62
+ return country ? <Tooltip title={country}>{country}</Tooltip> : '-';
63
+ },
64
+ },
65
+ {
66
+ dataIndex: 'administrativeLevel1',
67
+ title: t('Region'),
68
+ ellipsis: true,
69
+ show: true,
70
+ render: (v, all) => {
71
+ if (all.empty) {
72
+ return <div className="daf-default-cell" />
73
+ }
74
+
75
+ const country = findOptions(v, options?.countries);
76
+
77
+ return '-';
78
+ },
79
+ },
80
+ {
81
+ dataIndex: 'administrativeLevel2',
82
+ title: t('District'),
83
+ ellipsis: true,
84
+ show: true,
85
+ render: (v, all) => {
86
+ if (all.empty) {
87
+ return <div className="daf-default-cell" />
88
+ }
89
+
90
+ const country = findOptions(v, options?.countries);
91
+
92
+ return '-';
93
+ },
94
+ },
95
+ {
96
+ title: t("Last Update"),
97
+ dataIndex: "updatedAt",
98
+ key: "updatedAt",
99
+ width: 125,
100
+ render: (date, all) => {
101
+ if (all.empty) {
102
+ return <div className="daf-default-cell" />;
103
+ }
104
+
105
+ const _date = date ? renderDateFormatted(date, "DD MMM YYYY", user?.language || 'en') : "-";
106
+ return <Tooltip title={_date}>{_date}</Tooltip>;
107
+ },
108
+ ellipsis: true,
109
+ },
110
+ {
111
+ title: t("Sources"),
112
+ dataIndex: "sources",
113
+ key: "sources",
114
+ show: activeTab !== "own",
115
+ render: (val, all) => {
116
+ if (all.empty) {
117
+ return <div className="daf-default-cell" />;
118
+ }
119
+ if (!val || val?.length === 0) {
120
+ return "--";
121
+ }
122
+
123
+ return <AvatarGroup items={val}></AvatarGroup>;
124
+ },
125
+ },
126
+ {
127
+ id: 'actions',
128
+ title: "",
129
+ width: 60,
130
+ render: (_, all) => {
131
+ if (all.empty) {
132
+ return <div className="daf-default-cell" />;
133
+ }
134
+
135
+ const link = `/app/view/${subject}/${all.datastakeId}`;
136
+
137
+ return <div style={{ display: "flex", justifyContent: "center" }}>
138
+ <a href={getRedirectLink(link)}>
139
+ <CustomIcon name="Link" size={15} color={theme.baseGray70} />
140
+ </a>
141
+ </div>;
142
+ }
143
+ }
144
+ ].filter((column) => column.show !== false);
@@ -0,0 +1,31 @@
1
+ export const checkboxConfig = {
2
+ name: 'Name',
3
+ datastakeId: 'ID'
4
+ }
5
+
6
+ export const getFiltersConfig = ({t}) => {
7
+ return {
8
+ country: {
9
+ type: 'select',
10
+ placeholder: t('Country'),
11
+ style: { flex: 1 },
12
+ labelStyle: { flex: 1 },
13
+ getLabel: (option) => option.label,
14
+ getValue: (option) => option.value,
15
+ },
16
+ }
17
+ }
18
+
19
+ export const filtersConfig = {
20
+ name: '',
21
+ datastakeId: '',
22
+ };
23
+
24
+ export const getFilterOptions = (options, t) => {
25
+ const { countries } = options || {};
26
+ const _default = {
27
+ country: countries,
28
+ }
29
+
30
+ return _default;
31
+ }
@@ -0,0 +1,103 @@
1
+ import React, { useEffect} from 'react'
2
+ import { message } from 'antd';
3
+ import { MessageTypes } from '../../../../../helpers/messages.js';
4
+ import DynamicForm from '../../../../core/components/DynamicForm/index.jsx';
5
+
6
+ const StakeholdersCreate = ({
7
+ namespace = 'locations',
8
+ view = 'scoping',
9
+ edit = false,
10
+ formData = {},
11
+ loading = false,
12
+ onSubmitted = () => {},
13
+ onCancel = () => {},
14
+ getData = () => {},
15
+ saveData = () => {},
16
+ form: formConfig = {},
17
+ formValue = {},
18
+ defaultData = {},
19
+ user = {},
20
+ APP,
21
+ query,
22
+ goTo = () => {},
23
+ t = () => {},
24
+ ajaxForms = {},
25
+ changeAjaxForms = () => {},
26
+ ajaxOptions = {},
27
+ changeAjaxOptions = () => {},
28
+ getAppHeader = () => {},
29
+ getApiBaseUrl = () => {},
30
+ }) => {
31
+ let {
32
+ form = {},
33
+ data = defaultData || {},
34
+ } = !edit ? (formData[`${APP}-${view}`] || {}) : {
35
+ form: formConfig,
36
+ data: formValue
37
+ };
38
+
39
+ useEffect(() => {
40
+ if (Object.keys(form).length === 0 && !formData[`${APP}-${view}`]) {
41
+ if (!edit) {
42
+ getData({ namespace, module: APP, view, scope: 'global' });
43
+ } else {
44
+ form = formConfig;
45
+ data = formValue;
46
+ }
47
+ }
48
+ }, [edit, user?.language]);
49
+
50
+ return (
51
+ <div className="daf-create-form">
52
+ <DynamicForm
53
+ form={form}
54
+ data={data}
55
+ showSaveAndNext={false}
56
+ module={APP}
57
+ onCancel={onCancel}
58
+ isCreate
59
+ t={t}
60
+ excludedKeys={["title"]}
61
+ user={user}
62
+ ajaxForms={ajaxForms}
63
+ ajaxOptions={ajaxOptions}
64
+ getAppHeader={getAppHeader}
65
+ getApiBaseUrl={getApiBaseUrl}
66
+ changeAjaxOptions={changeAjaxOptions}
67
+ app={APP}
68
+ query={query}
69
+ goTo={goTo}
70
+ changeAjaxForms={changeAjaxForms}
71
+ submit={(payload, setSelectedFormNext) => {
72
+ const payloadData = { ...payload, module: APP, namespace };
73
+
74
+ const newPayload = {
75
+ ...defaultData,
76
+ ...payloadData,
77
+ };
78
+
79
+ const callback = (type, m, data) => {
80
+ if (setSelectedFormNext) {
81
+ setSelectedFormNext();
82
+ }
83
+ if (type === MessageTypes.SUCCESS) {
84
+ if (onSubmitted) onSubmitted(type, m, data);
85
+ } else {
86
+ message.error(m);
87
+ }
88
+ };
89
+
90
+ saveData(
91
+ !data && !data.id ? newPayload : Object.assign(newPayload, { id: data.id }),
92
+ callback,
93
+ );
94
+ }}
95
+ isFormDisabled={() => {
96
+ return !data || !data.typeOfEvent;
97
+ }}
98
+ />
99
+ </div>
100
+ )
101
+ }
102
+
103
+ export default StakeholdersCreate
@@ -0,0 +1,142 @@
1
+ import React, { useMemo, useState, useEffect, useCallback } from 'react'
2
+ import TablePageWithTabs from '../../../pages/TablePageWithTabs/index.jsx'
3
+ import { getColumns } from './columns.js';
4
+ import { checkboxConfig, getFiltersConfig, filtersConfig, getFilterOptions } from './config.js';
5
+ import { useGetQueryParams } from '../../../../hooks/useGetQueryParams.js';
6
+ import StakeholdersCreate from './create.jsx';
7
+ import { displayMessage } from '../../../../../helpers/messages.js';
8
+
9
+ const LocationsTable = ({
10
+ t = () => {},
11
+ goTo = () => {},
12
+ user = {},
13
+ options = {},
14
+ getRedirectLink = () => {},
15
+ theme = {},
16
+ loading = false,
17
+ data = {},
18
+ isMobile,
19
+ APP,
20
+ location,
21
+ getData = () => {},
22
+ getApiBaseUrl = () => {},
23
+ getAppHeader = () => {},
24
+ getFormData = () => {},
25
+ saveFormData = () => {},
26
+ formLoading = false,
27
+ query = {},
28
+ ajaxForms = {},
29
+ changeAjaxForms = () => {},
30
+ ajaxOptions = {},
31
+ changeAjaxOptions = () => {},
32
+ formData = {},
33
+ formValue = {},
34
+ form = {},
35
+ dataOptions = {},
36
+ }) => {
37
+ const [selectOptions, setSelectOptions] = useState();
38
+ const [activeTab, setActiveTab] = useState();
39
+ const columns = useMemo(() => getColumns({
40
+ t,
41
+ goTo,
42
+ user,
43
+ options,
44
+ activeTab,
45
+ getRedirectLink,
46
+ theme,
47
+ subject: 'location',
48
+ data,
49
+ dataOptions
50
+ }), [t, goTo, user, options, activeTab, getRedirectLink, theme, data, dataOptions]);
51
+
52
+ const breadCrumbs = [];
53
+
54
+ const { paginationQuery, searchParams, otherParams } = useGetQueryParams({location});
55
+
56
+ useEffect(() => {
57
+ getData({
58
+ pagination: paginationQuery,
59
+ ...(Object.keys(otherParams).length > 0 && { filters: otherParams }),
60
+ ...(Object.keys(searchParams).length > 0 && { search: searchParams }),
61
+ tab: activeTab,
62
+ }, 'locations')
63
+ }, [paginationQuery, otherParams, searchParams, activeTab]);
64
+
65
+ const selectFiltersConfig = useMemo(() => {
66
+ return getFiltersConfig({t});
67
+ }, [t]);
68
+
69
+ useEffect(() => {
70
+ setSelectOptions((prev) => ({
71
+ ...prev,
72
+ ...getFilterOptions(options, t),
73
+ }))
74
+ }, [options, t])
75
+
76
+ const handleActiveTabChange = useCallback((value) => {
77
+ setActiveTab(value);
78
+ }, []);
79
+
80
+ return (
81
+ <TablePageWithTabs
82
+ t={t}
83
+ title={t("Locations")}
84
+ breadCrumbs={breadCrumbs}
85
+ location={location}
86
+ loading={loading}
87
+ goTo={goTo}
88
+ defaultActiveTab={"all"}
89
+ columns={columns}
90
+ data={data}
91
+ checkboxConfig={checkboxConfig}
92
+ APP={APP}
93
+ getApiBaseUrl={getApiBaseUrl}
94
+ selectOptions={selectOptions}
95
+ selectFiltersConfig={selectFiltersConfig}
96
+ getRedirectLink={getRedirectLink}
97
+ filtersConfig={filtersConfig}
98
+ isMobile={isMobile}
99
+ view="locations"
100
+ getActiveTab={handleActiveTabChange}
101
+ onDownload={() => {
102
+ console.log("download");
103
+ }}
104
+ drawerTitle={t("Create Location")}
105
+ >
106
+ {({onDrawerClose}) => (
107
+ <StakeholdersCreate
108
+ t={t}
109
+ goTo={goTo}
110
+ user={user}
111
+ APP={APP}
112
+ getApiBaseUrl={getApiBaseUrl}
113
+ getAppHeader={getAppHeader}
114
+ getData={getFormData}
115
+ saveData={saveFormData}
116
+ loading={formLoading}
117
+ onSubmitted={(type, m, data) => {
118
+ if (data.datastakeId) {
119
+ displayMessage(
120
+ type,
121
+ t("affirmations::subject-created-successfully") || m,
122
+ );
123
+ // goTo(`/app/edit/stakeholders/${data.datastakeId}`);
124
+ window.location.reload();
125
+ }
126
+ }}
127
+ onCancel={onDrawerClose}
128
+ query={query}
129
+ ajaxForms={ajaxForms}
130
+ changeAjaxForms={changeAjaxForms}
131
+ ajaxOptions={ajaxOptions}
132
+ changeAjaxOptions={changeAjaxOptions}
133
+ formData={formData}
134
+ formValue={formValue}
135
+ form={form}
136
+ />
137
+ )}
138
+ </TablePageWithTabs>
139
+ )
140
+ }
141
+
142
+ export default LocationsTable
@@ -10,7 +10,7 @@ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink,
10
10
  dataIndex: 'datastakeId',
11
11
  title: t('ID'),
12
12
  ellipsis: true,
13
- show: true,
13
+ show: true,
14
14
  render: (v, all) => {
15
15
  if (all.empty) {
16
16
  return <div className="daf-default-cell" />
@@ -78,9 +78,9 @@ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink,
78
78
  },
79
79
  },
80
80
  {
81
- title: t("Date"),
82
- dataIndex: "date",
83
- key: "date",
81
+ title: t("Last Update"),
82
+ dataIndex: "updatedAt",
83
+ key: "updatedAt",
84
84
  width: 125,
85
85
  render: (date, all) => {
86
86
  if (all.empty) {
@@ -108,9 +108,6 @@ const StakeholdersTable = ({
108
108
  APP={APP}
109
109
  getApiBaseUrl={getApiBaseUrl}
110
110
  getAppHeader={getAppHeader}
111
- defaultData={{
112
- economicSector: 'miningMineralTrade'
113
- }}
114
111
  getData={getFormData}
115
112
  saveData={saveFormData}
116
113
  loading={formLoading}
@@ -120,7 +117,7 @@ const StakeholdersTable = ({
120
117
  type,
121
118
  t("affirmations::subject-created-successfully") || m,
122
119
  );
123
- goTo(`/app/edit/stakeholders/${data.datastakeId}`);
120
+ goTo(`/app/locations`);
124
121
  }
125
122
  }}
126
123
  onCancel={onDrawerClose}
@@ -42,7 +42,7 @@ class LinkedSubjectsService extends BaseService {
42
42
  const _namespace = getNamespace(namespace);
43
43
 
44
44
  return this.apiGet({
45
- url: `/${_namespace}/associated-information`,
45
+ url: `/${_namespace}`,
46
46
  isApp: true,
47
47
  params: query,
48
48
  signal,
package/src/pages.js CHANGED
@@ -4,4 +4,5 @@ export { default as UserDashboard } from './@daf/pages/dashboards/UserDashboard/
4
4
  export { default as StakeholdersTable } from './@daf/pages/dashboards/AllInformation/Stakeholders/index.jsx';
5
5
 
6
6
  // Pages
7
- export { default as TablePageWithTabs } from './@daf/pages/pages/TablePageWithTabs/index.jsx';
7
+ export { default as TablePageWithTabs } from './@daf/pages/pages/TablePageWithTabs/index.jsx';
8
+ export { default as LocationsTable } from './@daf/pages/dashboards/AllInformation/Locations/index.jsx';