datastake-daf 0.6.815 → 0.6.817

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.
@@ -1458,6 +1458,11 @@ class LinkedSubjectsService extends BaseService {
1458
1458
  getForm({
1459
1459
  namespace
1460
1460
  }, language = "en", scope) {
1461
+ console.log({
1462
+ namespace,
1463
+ language,
1464
+ scope
1465
+ });
1461
1466
  return this.apiGet({
1462
1467
  url: `forms/${namespace === "documents" ? namespace : getNamespace(namespace)}`,
1463
1468
  isApp: true,
@@ -1727,6 +1732,201 @@ class PartnerService extends BaseService {
1727
1732
  }
1728
1733
  var PartnerService$1 = createLazyService(PartnerService);
1729
1734
 
1735
+ class EventsService extends BaseService {
1736
+ getForm({
1737
+ scope
1738
+ }, language = "en") {
1739
+ return this.apiGet({
1740
+ isApp: true,
1741
+ url: `/forms/event`,
1742
+ params: {
1743
+ scope,
1744
+ language
1745
+ }
1746
+ });
1747
+ }
1748
+ getWithModule({
1749
+ query,
1750
+ signal,
1751
+ module
1752
+ }) {
1753
+ return this.apiGet({
1754
+ isApp: true,
1755
+ url: `/${module}/event`,
1756
+ params: query,
1757
+ signal
1758
+ });
1759
+ }
1760
+ getOne({
1761
+ id,
1762
+ module,
1763
+ signal
1764
+ }) {
1765
+ return this.apiGet({
1766
+ url: `/${module}/event/${id}`,
1767
+ isApp: true,
1768
+ signal
1769
+ });
1770
+ }
1771
+ get(query, signal) {
1772
+ return this.apiGet({
1773
+ isApp: true,
1774
+ url: "/event",
1775
+ params: query,
1776
+ signal
1777
+ });
1778
+ }
1779
+ getData(id, sourceId, source, version) {
1780
+ return this.apiGet({
1781
+ isApp: true,
1782
+ url: `/event/${id}`,
1783
+ params: {
1784
+ authorId: sourceId,
1785
+ source,
1786
+ version
1787
+ }
1788
+ });
1789
+ }
1790
+ getLinking(query) {
1791
+ return this.apiGet({
1792
+ isApp: true,
1793
+ url: "/event/linking",
1794
+ params: query
1795
+ });
1796
+ }
1797
+ submit(payload) {
1798
+ if (payload.id) {
1799
+ return this.apiPut({
1800
+ isApp: true,
1801
+ url: `/event/${payload.id}`,
1802
+ data: filterCreateData(payload)
1803
+ });
1804
+ }
1805
+ if (payload?.form) {
1806
+ delete payload.form;
1807
+ return this.apiPut({
1808
+ isApp: true,
1809
+ url: "/event",
1810
+ data: filterCreateData(payload)
1811
+ });
1812
+ }
1813
+ return this.apiPost({
1814
+ isApp: true,
1815
+ url: "/event",
1816
+ data: filterCreateData(payload)
1817
+ });
1818
+ }
1819
+ submitStep(data, id) {
1820
+ return this.apiPut({
1821
+ isApp: true,
1822
+ url: `/event/submit/${id}`,
1823
+ data: filterCreateData(data)
1824
+ });
1825
+ }
1826
+ remove(id, data) {
1827
+ return this.apiDelete({
1828
+ isApp: true,
1829
+ url: `/event/${id}/remove`,
1830
+ data: data
1831
+ });
1832
+ }
1833
+ submitForm(id) {
1834
+ const app = window.globalServicesConfig.application;
1835
+ return this.apiPost({
1836
+ isApp: true,
1837
+ url: `/${app}/versioning/submit/Event/${id}`
1838
+ });
1839
+ }
1840
+ getOptions() {
1841
+ return this.apiGet({
1842
+ isApp: true,
1843
+ url: `/forms/options`,
1844
+ params: {
1845
+ id: "categoryOptions,eventsType,testimonialsType,eventCategory,countries,eventCategoryOptions"
1846
+ }
1847
+ });
1848
+ }
1849
+ }
1850
+ var EventsService$1 = createLazyService(EventsService);
1851
+
1852
+ class WorkersService extends BaseService {
1853
+ get(params) {
1854
+ return this.apiGet({
1855
+ isApp: true,
1856
+ url: "/stakeholder",
1857
+ params
1858
+ });
1859
+ }
1860
+ getForm(scope = "modalNashirikiWorker", language = "en") {
1861
+ return this.apiGet({
1862
+ isApp: true,
1863
+ url: `/forms/stakeholder`,
1864
+ params: {
1865
+ scope,
1866
+ language
1867
+ }
1868
+ });
1869
+ }
1870
+ getData(id, sourceId, version, source) {
1871
+ return this.apiGet({
1872
+ isApp: true,
1873
+ url: `/stakeholder/${id}`,
1874
+ params: {
1875
+ authorId: sourceId,
1876
+ version,
1877
+ source
1878
+ }
1879
+ });
1880
+ }
1881
+ submit(payload) {
1882
+ if (payload.id) {
1883
+ // const { id, ...data } = payload;
1884
+ return this.apiPut({
1885
+ isApp: true,
1886
+ url: `/stakeholder/${payload.id}`,
1887
+ data: filterCreateData(payload)
1888
+ });
1889
+ }
1890
+ if (payload?.form) {
1891
+ delete payload.form;
1892
+ return this.apiPost({
1893
+ isApp: true,
1894
+ url: "/stakeholder",
1895
+ data: filterCreateData(payload)
1896
+ });
1897
+ }
1898
+ return this.apiPost({
1899
+ isApp: true,
1900
+ url: "/stakeholder",
1901
+ data: filterCreateData(payload)
1902
+ });
1903
+ }
1904
+ submitStep(data, id) {
1905
+ return this.apiPut({
1906
+ isApp: true,
1907
+ url: `/stakeholder/submit/${id}`,
1908
+ data: filterCreateData(data)
1909
+ });
1910
+ }
1911
+ remove(id, data) {
1912
+ return this.apiDelete({
1913
+ isApp: true,
1914
+ url: `/stakeholder/${id}/remove`,
1915
+ data: data
1916
+ });
1917
+ }
1918
+ getOptions() {
1919
+ return this.apiGet({
1920
+ isApp: true,
1921
+ url: `/forms/options`,
1922
+ params: {
1923
+ id: "activityAtSiteOptions,category,countries,optionPositionSupplyChain,subCategory"
1924
+ }
1925
+ });
1926
+ }
1927
+ }
1928
+ var WorkersService$1 = createLazyService(WorkersService);
1929
+
1730
1930
  exports.AdminService = AdminService$1;
1731
1931
  exports.AuthenticationService = AuthenticationService$1;
1732
1932
  exports.BaseHTTPService = BaseHTTPService;
@@ -1736,6 +1936,7 @@ exports.DashboardService = DashboardService$1;
1736
1936
  exports.DataStoreService = DataStoreService$1;
1737
1937
  exports.ErrorHandler = ErrorHandler;
1738
1938
  exports.ErrorService = ErrorService;
1939
+ exports.EventsService = EventsService$1;
1739
1940
  exports.LinkedSubjectsService = LinkedSubjects;
1740
1941
  exports.NotificationService = NotificationService$1;
1741
1942
  exports.OperatorService = OperatorService$1;
@@ -1743,6 +1944,7 @@ exports.PartnerService = PartnerService$1;
1743
1944
  exports.QueryService = QueryService$1;
1744
1945
  exports.SourceService = SourceService$1;
1745
1946
  exports.UserService = UserService$1;
1947
+ exports.WorkersService = WorkersService$1;
1746
1948
  exports.configureServices = configureServices;
1747
1949
  exports.createLazyService = createLazyService;
1748
1950
  exports.getServicesConfig = getServicesConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datastake-daf",
3
- "version": "0.6.815",
3
+ "version": "0.6.817",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^5.2.5",
6
6
  "@antv/g2": "^5.1.1",
@@ -0,0 +1,140 @@
1
+ import React from 'react';
2
+ import { Tooltip } from 'antd';
3
+ import { findOptions, getLinkValue } 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
+ import sourceAvatarConfig from '../../../../helpers/sourceAvatarConfig.js';
8
+ import MoreMenu from '../../../core/components/Table/MoreMenu/index.jsx';
9
+ import NavigationAction from '../../../core/components/Table/NavigationAction/index.jsx';
10
+ import { renderStatusTag } from '../../../utils/tags.js';
11
+
12
+ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink, theme, subject, data, applications}) => [
13
+ {
14
+ dataIndex: 'datastakeId',
15
+ title: t('ID'),
16
+ ellipsis: true,
17
+ show: true,
18
+ key: "datastakeId",
19
+ sorter: () => 0 + 0,
20
+ render: (v, all) => {
21
+ if (all.empty) {
22
+ return <div className="daf-default-cell" />
23
+ }
24
+
25
+ return <Tooltip title={v}>{v}</Tooltip>;
26
+ },
27
+ },
28
+ {
29
+ dataIndex: "name",
30
+ title: t('Name'),
31
+ ellipsis: true,
32
+ show: true,
33
+ key: "name",
34
+ sorter: () => 0 + 0,
35
+ render: (v, all) => {
36
+ if (all.empty) {
37
+ return <div className="daf-default-cell" />
38
+ }
39
+
40
+ return <Tooltip title={v}>{v}</Tooltip>;
41
+ },
42
+ },
43
+ {
44
+ dataIndex: 'region',
45
+ title: findOptions(user?.company?.country, options?.administrativeLevel1)?.length > 2 ? findOptions(user?.company?.country, options?.administrativeLevel1) : t("Province"),
46
+ ellipsis: true,
47
+ show: true,
48
+ render: (v, all) => {
49
+ if (all.empty) {
50
+ return <div className="daf-default-cell" />
51
+ }
52
+
53
+ const region = getLinkValue(all?.administrativeLevel1, all?.linking?.SCL);
54
+
55
+ return region ? <Tooltip title={region}>{region}</Tooltip> : '-';
56
+ },
57
+ },
58
+ {
59
+ dataIndex: 'territory',
60
+ title: findOptions(user?.company?.country, options?.administrativeLevel2)?.length > 2 ? findOptions(user?.company?.country, options?.administrativeLevel2) : t("Territory"),
61
+ ellipsis: true,
62
+ show: true,
63
+ render: (v, all) => {
64
+ if (all.empty) {
65
+ return <div className="daf-default-cell" />
66
+ }
67
+
68
+ const district = getLinkValue(all?.administrativeLevel2, all?.linking?.SCL);
69
+
70
+ return district ? <Tooltip title={district}>{district}</Tooltip> : '-';
71
+ },
72
+ },
73
+ {
74
+ title: t("Last Update"),
75
+ dataIndex: "updatedAt",
76
+ key: "updatedAt",
77
+ render: (date, all) => {
78
+ if (all.empty) {
79
+ return <div className="daf-default-cell" />;
80
+ }
81
+
82
+ const _date = date ? renderDateFormatted(date, "DD MMM YYYY", user?.language || 'en') : "-";
83
+ return <Tooltip title={_date}>{_date}</Tooltip>;
84
+ },
85
+ ellipsis: true,
86
+ },
87
+ {
88
+ title: t("Sources"),
89
+ dataIndex: "sources",
90
+ key: "sources",
91
+ show: activeTab !== "own",
92
+ render: (val, all) => {
93
+ if (all.empty) {
94
+ return <div className="daf-default-cell" />;
95
+ }
96
+
97
+ if (!val || val?.length === 0) {
98
+ return "-";
99
+ }
100
+
101
+ const sources = sourceAvatarConfig(val, user, applications);
102
+
103
+ return <AvatarGroup items={sources} />;
104
+ },
105
+ },
106
+ {
107
+ title: t("Status"),
108
+ dataIndex: 'status',
109
+ ellipsis: true,
110
+ show: activeTab == "own",
111
+ render: (v, all) => {
112
+ if (all.empty) {
113
+ return <div className="daf-default-cell" />
114
+ }
115
+ const _val = all?.published || all?.status === "submitted" ? "submitted" : v;
116
+
117
+ return renderStatusTag({ value: _val, t });
118
+ },
119
+ },
120
+ {
121
+ id: 'actions',
122
+ title: "",
123
+ width: 60,
124
+ render: (_, all) => {
125
+ if (all.empty) {
126
+ return <div className="daf-default-cell" />;
127
+ }
128
+
129
+ const onClick = () => {
130
+ let link = `/app/view/${subject}/${all.datastakeId}`;
131
+ if (activeTab === "shared") {
132
+ link += `?sourceId=${all?.authorId?.id}`;
133
+ }
134
+ goTo(getRedirectLink(link));
135
+ };
136
+
137
+ return <NavigationAction onClick={onClick} theme={theme} />;
138
+ }
139
+ }
140
+ ].filter((column) => column.show !== false);
@@ -0,0 +1,41 @@
1
+ import { getStatusOptions } from '../../../utils/filters';
2
+
3
+ export const getFiltersConfig = ({t}) => {
4
+ return {
5
+ status: {
6
+ type: "select",
7
+ label: "Status",
8
+ placeholder: () => `${t("Filter by")} ${t("Status").toLowerCase()}`,
9
+ style: { flex: 1 },
10
+ labelStyle: { fley: 1 },
11
+ getLabel: (option) => option.label,
12
+ getValue: (option) => option.value,
13
+ },
14
+ timeframe: {
15
+ type: "timeframe",
16
+ label: "Timeframe",
17
+ style: { flex: 1 },
18
+ },
19
+ }
20
+ }
21
+
22
+ export const getFilterOptions = (options, t) => {
23
+ const _default = {
24
+ status: getStatusOptions(t) || [],
25
+ timeframe: [],
26
+ }
27
+
28
+ return _default;
29
+ }
30
+
31
+ export const formConfig = {
32
+ namespace: 'conflict-areas',
33
+ view: ['scoping', 'new'],
34
+ scope: 'conflictAreaCreate',
35
+ formType: 'conflict-area',
36
+ }
37
+
38
+ export const viewConfig = {
39
+ title: "Conflict Areas",
40
+ createTitle: "New Conflict Area",
41
+ }
@@ -50,7 +50,11 @@ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink,
50
50
  return <div className="daf-default-cell" />
51
51
  }
52
52
 
53
- const locationCategories = [...(data?.options?.locationCategories || []), ...(options?.productionSiteCategories || [])]
53
+ const locationCategories = [
54
+ ...(data?.options?.locationCategories || []),
55
+ ...(options?.productionSiteCategories || []),
56
+ ...(options?.locationCategories || [])
57
+ ]
54
58
 
55
59
  const category = findOptions(v, locationCategories);
56
60
 
@@ -1,6 +1,6 @@
1
1
  import { getStatusOptions } from '../../../utils/filters';
2
2
 
3
- export const getFiltersConfig = ({t}) => {
3
+ export const getFiltersConfig = ({t, screen}) => {
4
4
  return {
5
5
  country: {
6
6
  type: 'select',
@@ -91,6 +91,7 @@ export const getFiltersConfig = ({t}) => {
91
91
  labelStyle: { flex: 1 },
92
92
  getLabel: (option) => option.label,
93
93
  getValue: (option) => option.value,
94
+ show: () => screen === 'scl',
94
95
  },
95
96
  positionInTheMineralSupplyChain: {
96
97
  type: 'select',
@@ -0,0 +1,110 @@
1
+ import React from 'react';
2
+ import { Tooltip } from 'antd';
3
+ import { findOptions, getLinkValue } 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
+ import sourceAvatarConfig from '../../../../helpers/sourceAvatarConfig.js';
8
+ import MoreMenu from '../../../core/components/Table/MoreMenu/index.jsx';
9
+ import NavigationAction from '../../../core/components/Table/NavigationAction/index.jsx';
10
+ import { renderStatusTag } from '../../../utils/tags.js';
11
+
12
+ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink, theme, subject, data, applications}) => [
13
+ {
14
+ dataIndex: 'datastakeId',
15
+ title: t('ID'),
16
+ ellipsis: true,
17
+ show: true,
18
+ key: "datastakeId",
19
+ sorter: () => 0 + 0,
20
+ render: (v, all) => {
21
+ if (all.empty) {
22
+ return <div className="daf-default-cell" />
23
+ }
24
+
25
+ return <Tooltip title={v}>{v}</Tooltip>;
26
+ },
27
+ },
28
+ {
29
+ dataIndex: 'name',
30
+ title: t('Name'),
31
+ ellipsis: true,
32
+ show: true,
33
+ key: "name",
34
+ sorter: () => 0 + 0,
35
+ render: (v, all) => {
36
+ if (all.empty) {
37
+ return <div className="daf-default-cell" />
38
+ }
39
+
40
+ return <Tooltip title={v}>{v}</Tooltip>;
41
+ },
42
+ },
43
+ {
44
+ title: t("Last Update"),
45
+ dataIndex: "updatedAt",
46
+ key: "updatedAt",
47
+ render: (date, all) => {
48
+ if (all.empty) {
49
+ return <div className="daf-default-cell" />;
50
+ }
51
+
52
+ const _date = date ? renderDateFormatted(date, "DD MMM YYYY", user?.language || 'en') : "-";
53
+ return <Tooltip title={_date}>{_date}</Tooltip>;
54
+ },
55
+ ellipsis: true,
56
+ },
57
+ {
58
+ title: t("Sources"),
59
+ dataIndex: "sources",
60
+ key: "sources",
61
+ show: activeTab !== "own",
62
+ render: (val, all) => {
63
+ if (all.empty) {
64
+ return <div className="daf-default-cell" />;
65
+ }
66
+
67
+ if (!val || val?.length === 0) {
68
+ return "-";
69
+ }
70
+
71
+ const sources = sourceAvatarConfig(val, user, applications);
72
+
73
+ return <AvatarGroup items={sources} />;
74
+ },
75
+ },
76
+ {
77
+ title: t("Status"),
78
+ dataIndex: 'status',
79
+ ellipsis: true,
80
+ show: activeTab == "own",
81
+ render: (v, all) => {
82
+ if (all.empty) {
83
+ return <div className="daf-default-cell" />
84
+ }
85
+ const _val = all?.published || all?.status === "submitted" ? "submitted" : v;
86
+
87
+ return renderStatusTag({ value: _val, t });
88
+ },
89
+ },
90
+ {
91
+ id: 'actions',
92
+ title: "",
93
+ width: 60,
94
+ render: (_, all) => {
95
+ if (all.empty) {
96
+ return <div className="daf-default-cell" />;
97
+ }
98
+
99
+ const onClick = () => {
100
+ let link = `/app/view/${subject}/${all.datastakeId}`;
101
+ if (activeTab === "shared") {
102
+ link += `?sourceId=${all?.authorId?.id}`;
103
+ }
104
+ goTo(getRedirectLink(link));
105
+ };
106
+
107
+ return <NavigationAction onClick={onClick} theme={theme} />;
108
+ }
109
+ }
110
+ ].filter((column) => column.show !== false);
@@ -0,0 +1,41 @@
1
+ import { getStatusOptions } from '../../../utils/filters';
2
+
3
+ export const getFiltersConfig = ({t}) => {
4
+ return {
5
+ status: {
6
+ type: "select",
7
+ label: "Status",
8
+ placeholder: () => `${t("Filter by")} ${t("Status").toLowerCase()}`,
9
+ style: { flex: 1 },
10
+ labelStyle: { fley: 1 },
11
+ getLabel: (option) => option.label,
12
+ getValue: (option) => option.value,
13
+ },
14
+ timeframe: {
15
+ type: "timeframe",
16
+ label: "Timeframe",
17
+ style: { flex: 1 },
18
+ },
19
+ }
20
+ }
21
+
22
+ export const getFilterOptions = (options, t) => {
23
+ const _default = {
24
+ status: getStatusOptions(t) || [],
25
+ timeframe: [],
26
+ }
27
+
28
+ return _default;
29
+ }
30
+
31
+ export const formConfig = {
32
+ namespace: 'armed-groups',
33
+ view: ['scoping', 'new'],
34
+ scope: 'global',
35
+ formType: 'armed-group',
36
+ }
37
+
38
+ export const viewConfig = {
39
+ title: "Armed Groups",
40
+ createTitle: "New Armed Group",
41
+ }
@@ -49,7 +49,13 @@ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink,
49
49
  return <div className="daf-default-cell" />
50
50
  }
51
51
 
52
- const country = findOptions(v, data?.options?.positionSupplyChainOptions || data?.options?.optionPositionSupplyChain);
52
+ const positionSupplyChainOptions = [
53
+ ...(data?.options?.positionSupplyChainOptions || []),
54
+ ...(options?.positionSupplyChainOptions || []),
55
+ ...(options?.optionPositionSupplyChain || [])
56
+ ]
57
+
58
+ const country = findOptions(v, positionSupplyChainOptions);
53
59
 
54
60
  return country ? <Tooltip title={country}>{country}</Tooltip> : '-';
55
61
  },
@@ -66,7 +72,13 @@ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink,
66
72
  return <div className="daf-default-cell" />
67
73
  }
68
74
 
69
- const subCategory = findOptions(v, data?.options?.subCategoriesOptions || data?.options?.subCategory);
75
+ const subCategoriesOptions = [
76
+ ...(data?.options?.subCategoriesOptions || []),
77
+ ...(options?.subCategoriesOptions || []),
78
+ ...(options?.subCategory || [])
79
+ ]
80
+
81
+ const subCategory = findOptions(v, subCategoriesOptions);
70
82
 
71
83
  return subCategory ? <Tooltip title={subCategory}>{subCategory}</Tooltip> : '-';
72
84
  },
@@ -66,7 +66,13 @@ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink,
66
66
  return <div className="daf-default-cell" />
67
67
  }
68
68
 
69
- const activity = findOptions(v, data?.options?.activityAtSiteOptions || data?.options?.activityAtSite);
69
+ const activityAtSiteOptions = [
70
+ ...(data?.options?.activityAtSiteOptions || []),
71
+ ...(options?.activityAtSiteOptions || []),
72
+ ...(options?.activityAtSite || [])
73
+ ]
74
+
75
+ const activity = findOptions(v, activityAtSiteOptions);
70
76
 
71
77
  return activity ? <Tooltip title={activity}>{activity}</Tooltip> : '-';
72
78
  },
@@ -16,7 +16,7 @@ export const getSelectFiltersConfig = ({ subject }) => {
16
16
 
17
17
  export const getFiltersConfig = ({ t, subject }) => {
18
18
  const registry = FILTER_REGISTRY[subject] || FILTER_REGISTRY[DEFAULT_SUBJECT];
19
- return registry?.config({ t });
19
+ return registry?.config({ t , screen: subject});
20
20
  };
21
21
 
22
22
  export const getFilterOptions = ({ t, subject, options }) => {