datastake-daf 0.6.743 → 0.6.744

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.
Files changed (27) hide show
  1. package/dist/pages/index.js +1743 -160
  2. package/dist/services/index.js +2 -2
  3. package/package.json +1 -1
  4. package/src/@daf/pages/dashboards/AllInformation/Documents/columns.js +39 -14
  5. package/src/@daf/pages/dashboards/AllInformation/Documents/create.jsx +5 -4
  6. package/src/@daf/pages/dashboards/AllInformation/Documents/index.jsx +16 -26
  7. package/src/@daf/pages/dashboards/AllInformation/Events/config.js +158 -6
  8. package/src/@daf/pages/dashboards/AllInformation/Events/create.jsx +2 -2
  9. package/src/@daf/pages/dashboards/AllInformation/Events/index.jsx +8 -0
  10. package/src/@daf/pages/dashboards/AllInformation/Locations/create.jsx +1 -1
  11. package/src/@daf/pages/dashboards/AllInformation/Locations/index.jsx +8 -0
  12. package/src/@daf/pages/dashboards/AllInformation/Stakeholders/create.jsx +1 -1
  13. package/src/@daf/pages/dashboards/AllInformation/Stakeholders/index.jsx +9 -1
  14. package/src/@daf/pages/dashboards/DueDilligence/Incidents/columns.js +221 -0
  15. package/src/@daf/pages/dashboards/DueDilligence/Incidents/config.js +166 -0
  16. package/src/@daf/pages/dashboards/DueDilligence/Incidents/create.jsx +104 -0
  17. package/src/@daf/pages/dashboards/DueDilligence/Incidents/index.jsx +157 -0
  18. package/src/@daf/pages/dashboards/DueDilligence/Incidents2/columns.js +176 -0
  19. package/src/@daf/pages/dashboards/DueDilligence/Incidents2/config.js +171 -0
  20. package/src/@daf/pages/dashboards/DueDilligence/Incidents2/create.jsx +104 -0
  21. package/src/@daf/pages/dashboards/DueDilligence/Incidents2/index.jsx +156 -0
  22. package/src/@daf/pages/dashboards/Operations/ProductionSites/columns.js +150 -0
  23. package/src/@daf/pages/dashboards/Operations/ProductionSites/config.js +165 -0
  24. package/src/@daf/pages/dashboards/Operations/ProductionSites/create.jsx +104 -0
  25. package/src/@daf/pages/dashboards/Operations/ProductionSites/index.jsx +155 -0
  26. package/src/@daf/services/LinkedSubjects.js +2 -2
  27. package/src/pages.js +3 -0
@@ -1342,12 +1342,12 @@ const getNamespace = namespace => {
1342
1342
  class LinkedSubjectsService extends BaseService {
1343
1343
  getForm({
1344
1344
  namespace
1345
- }, language = "en") {
1345
+ }, language = "en", scope) {
1346
1346
  return this.apiGet({
1347
1347
  url: `forms/${namespace === "documents" ? namespace : getNamespace(namespace)}`,
1348
1348
  isApp: true,
1349
1349
  params: {
1350
- scope: "create",
1350
+ scope: scope || "create",
1351
1351
  language
1352
1352
  }
1353
1353
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datastake-daf",
3
- "version": "0.6.743",
3
+ "version": "0.6.744",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^5.2.5",
6
6
  "@antv/g2": "^5.1.1",
@@ -6,14 +6,7 @@ import CustomIcon from '../../../../core/components/Icon/CustomIcon.jsx';
6
6
  import AvatarGroup from '../../../../core/components/AvatarGroup/index.jsx';
7
7
  import sourceAvatarConfig from '../../../../../helpers/sourceAvatarConfig.js';
8
8
 
9
- const getLinkValue = (value, linkingObject) => {
10
- if(linkingObject && linkingObject?.[value]) {
11
- return linkingObject?.[value]?.name;
12
- }
13
- return null;
14
- }
15
-
16
- export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink, theme, subject, data, applications}) => [
9
+ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink, theme, subject, applications}) => [
17
10
  {
18
11
  dataIndex: 'datastakeId',
19
12
  title: t('ID'),
@@ -28,8 +21,8 @@ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink,
28
21
  },
29
22
  },
30
23
  {
31
- dataIndex: 'title',
32
- title: t('Title'),
24
+ dataIndex: 'name',
25
+ title: t('Name'),
33
26
  ellipsis: true,
34
27
  show: true,
35
28
  render: (v, all) => {
@@ -41,8 +34,8 @@ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink,
41
34
  },
42
35
  },
43
36
  {
44
- dataIndex: 'type',
45
- title: t('Type'),
37
+ dataIndex: 'category',
38
+ title: t('Category'),
46
39
  ellipsis: true,
47
40
  show: true,
48
41
  render: (v, all) => {
@@ -50,12 +43,41 @@ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink,
50
43
  return <div className="daf-default-cell" />
51
44
  }
52
45
 
53
- const type = findOptions(v, data?.options?.locationCategories);
46
+ const category = findOptions(v, options?.categoriesOptions);
54
47
 
55
- return type ? <Tooltip title={type}>{type}</Tooltip> : '-';
48
+ return category ? <Tooltip title={category}>{category}</Tooltip> : '-';
56
49
  },
57
50
  },
51
+ {
52
+ dataIndex: 'subCategory',
53
+ title: t('Sub Category'),
54
+ ellipsis: true,
55
+ show: true,
56
+ render: (v, all) => {
57
+ if (all.empty) {
58
+ return <div className="daf-default-cell" />
59
+ }
60
+
61
+ const subCategory = findOptions(v, options?.subCategoriesOptions);
58
62
 
63
+ return subCategory ? <Tooltip title={subCategory}>{subCategory}</Tooltip> : '-';
64
+ },
65
+ },
66
+ {
67
+ dataIndex: 'country',
68
+ title: t('Country'),
69
+ ellipsis: true,
70
+ show: true,
71
+ render: (v, all) => {
72
+ if (all.empty) {
73
+ return <div className="daf-default-cell" />
74
+ }
75
+
76
+ const country = findOptions(v, options?.countries);
77
+
78
+ return country ? <Tooltip title={country}>{country}</Tooltip> : '-';
79
+ },
80
+ },
59
81
  {
60
82
  title: t("Last Update"),
61
83
  dataIndex: "updatedAt",
@@ -80,6 +102,9 @@ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink,
80
102
  if (all.empty) {
81
103
  return <div className="daf-default-cell" />;
82
104
  }
105
+ if (!val || val?.length === 0) {
106
+ return "--";
107
+ }
83
108
 
84
109
  const sources = sourceAvatarConfig(val, user, applications);
85
110
 
@@ -3,8 +3,8 @@ import { message } from 'antd';
3
3
  import { MessageTypes } from '../../../../../helpers/messages.js';
4
4
  import DynamicForm from '../../../../core/components/DynamicForm/index.jsx';
5
5
 
6
- const DocumentsCreate = ({
7
- namespace = 'documents',
6
+ const StakeholdersCreate = ({
7
+ namespace = 'stakeholders',
8
8
  view = 'scoping',
9
9
  edit = false,
10
10
  formData = {},
@@ -39,7 +39,7 @@ const DocumentsCreate = ({
39
39
  useEffect(() => {
40
40
  if (Object.keys(form).length === 0 && !formData[`${APP}-${view}`]) {
41
41
  if (!edit) {
42
- getData({ namespace, module: APP, view, scope: 'global' });
42
+ getData({ namespace, module: APP, view, scope: 'create' });
43
43
  } else {
44
44
  form = formConfig;
45
45
  data = formValue;
@@ -76,6 +76,7 @@ const DocumentsCreate = ({
76
76
  ...payloadData,
77
77
  form: 'document'
78
78
  };
79
+
79
80
 
80
81
  const callback = (type, m, data) => {
81
82
  if (setSelectedFormNext) {
@@ -101,4 +102,4 @@ const DocumentsCreate = ({
101
102
  )
102
103
  }
103
104
 
104
- export default DocumentsCreate
105
+ export default StakeholdersCreate
@@ -3,7 +3,7 @@ import TablePageWithTabs from '../../../pages/TablePageWithTabs/index.jsx'
3
3
  import { getColumns } from './columns.js';
4
4
  import { checkboxConfig, getFiltersConfig, filtersConfig, getFilterOptions } from './config.js';
5
5
  import { useGetQueryParams } from '../../../../hooks/useGetQueryParams.js';
6
- import DocumentsCreate from './create.jsx';
6
+ import StakeholdersCreate from './create.jsx';
7
7
  import { displayMessage } from '../../../../../helpers/messages.js';
8
8
 
9
9
  const DocumentsTable = ({
@@ -32,12 +32,11 @@ const DocumentsTable = ({
32
32
  formData = {},
33
33
  formValue = {},
34
34
  form = {},
35
- extendingFilters = {},
36
35
  applications = [],
36
+ subjectClear = () => {},
37
37
  }) => {
38
38
  const [selectOptions, setSelectOptions] = useState();
39
39
  const [activeTab, setActiveTab] = useState();
40
-
41
40
  const columns = useMemo(() => getColumns({
42
41
  t,
43
42
  goTo,
@@ -47,36 +46,21 @@ const DocumentsTable = ({
47
46
  getRedirectLink,
48
47
  theme,
49
48
  subject: 'documents',
50
- data,
51
49
  applications,
52
- }), [t, goTo, user, options, activeTab, getRedirectLink, theme, data, applications]);
50
+ }), [t, goTo, user, options, activeTab, getRedirectLink, theme, applications]);
53
51
 
54
52
  const breadCrumbs = [];
55
53
 
56
- const { paginationQuery, searchParams, otherParams, sortBy, sortDir } = useGetQueryParams({location});
57
-
58
- const filters = useMemo(() => {
59
- return {
60
- ...otherParams,
61
- ...extendingFilters
62
- }
63
- }, [otherParams, extendingFilters])
54
+ const { paginationQuery, searchParams, otherParams } = useGetQueryParams({location});
64
55
 
65
56
  useEffect(() => {
66
- console.log("fetching data")
67
57
  getData({
68
58
  pagination: paginationQuery,
69
- ...(Object.keys(filters).length > 0 && { filters: filters }),
59
+ ...(Object.keys(otherParams).length > 0 && { filters: otherParams }),
70
60
  ...(Object.keys(searchParams).length > 0 && { search: searchParams }),
71
61
  tab: activeTab,
72
- sortBy: {
73
- [sortBy || "updatedAt"]: sortDir ? (sortDir === "ascend" ? 1 : -1) : -1,
74
- }
75
62
  }, 'documents')
76
- console.log("data fetched")
77
- }, [location.search, activeTab, JSON.stringify(extendingFilters)]);
78
-
79
- console.log({data})
63
+ }, [paginationQuery, otherParams, searchParams, activeTab]);
80
64
 
81
65
  const selectFiltersConfig = useMemo(() => {
82
66
  return getFiltersConfig({t});
@@ -93,10 +77,17 @@ const DocumentsTable = ({
93
77
  setActiveTab(value);
94
78
  }, []);
95
79
 
80
+ useEffect(
81
+ () => () => {
82
+ subjectClear();
83
+ },
84
+ [],
85
+ );
86
+
96
87
  return (
97
88
  <TablePageWithTabs
98
89
  t={t}
99
- title={t("documents")}
90
+ title={t("Documents")}
100
91
  breadCrumbs={breadCrumbs}
101
92
  location={location}
102
93
  loading={loading}
@@ -120,7 +111,7 @@ const DocumentsTable = ({
120
111
  drawerTitle={t("Create Document")}
121
112
  >
122
113
  {({onDrawerClose}) => (
123
- <DocumentsCreate
114
+ <StakeholdersCreate
124
115
  t={t}
125
116
  goTo={goTo}
126
117
  user={user}
@@ -136,8 +127,7 @@ const DocumentsTable = ({
136
127
  type,
137
128
  t("affirmations::subject-created-successfully") || m,
138
129
  );
139
- // goTo(`/app/edit/stakeholders/${data.datastakeId}`);
140
- goTo(`/app/edit/documents/${data.datastakeId}`)
130
+ goTo(`/app/edit/documents/${data.datastakeId}`);
141
131
  }
142
132
  }}
143
133
  onCancel={onDrawerClose}
@@ -5,15 +5,136 @@ export const checkboxConfig = {
5
5
 
6
6
  export const getFiltersConfig = ({t}) => {
7
7
  return {
8
- country: {
8
+
9
+ timeframe: {
10
+ type: "timeframe",
11
+ label: "Timeframe",
12
+ style: { flex: 1 },
13
+ },
14
+ country: {
15
+ type: 'select',
16
+ label: 'Country',
17
+ placeholder: (t) => `${t('Filter by')} ${t('Country').toLowerCase()}`,
18
+ style: { flex: 1 },
19
+ labelStyle: { flex: 1 },
20
+ getLabel: (option) => option.label,
21
+ getValue: (option) => option.value,
22
+ },
23
+ administrativeLevel1: {
24
+ type: 'ajaxSelect',
25
+ label: ({ t = (s) => s, options = {}, filters = {}, language = 'en' }) => {
26
+ const { administrativeLevel1 } = options;
27
+
28
+ if (administrativeLevel1) {
29
+ if (options.country) {
30
+ const _item = administrativeLevel1[filters.country];
31
+ if (_item) {
32
+ if (_item[language]) {
33
+ return _item[language]
34
+ }
35
+ }
36
+ }
37
+ }
38
+
39
+ return t('Province');
40
+ },
41
+ placeholder: (t) => `${t('Filter by')} ${t('Province').toLowerCase()}`,
42
+ filters: (data) => ({
43
+ country: data.country,
44
+ level: 'level_1',
45
+ }),
46
+ show: (data) => !data.country,
47
+ disabled: (data) => !data.country,
48
+ mapper: { label: "name", value: "id" },
49
+ method: 'getOptions',
50
+ entity: 'AdministrativeLevel',
51
+ style: { flex: 1 },
52
+ labelStyle: { flex: 1 },
53
+ },
54
+ administrativeLevel2: {
55
+ type: 'ajaxSelect',
56
+ label: ({ t = (s) => s, options = {}, filters = {}, language = 'en' }) => {
57
+ const { administrativeLevel2 } = options;
58
+
59
+ if (administrativeLevel2) {
60
+ if (options.country) {
61
+ const _item = administrativeLevel2[filters.country];
62
+ if (_item) {
63
+ if (_item[language]) {
64
+ return _item[language]
65
+ }
66
+ }
67
+ }
68
+ }
69
+
70
+ return t('Province');
71
+ },
72
+ show: (data) => !(data.country && data.administrativeLevel1),
73
+ placeholder: (t) => `${t('Filter by')} ${t('Territory').toLowerCase()}`,
74
+ filters: (data) => ({
75
+ country: data.country,
76
+ level: 'level_2',
77
+ administrativeLevel1: data.administrativeLevel1,
78
+ }),
79
+ disabled: (data) => !(data.country && data.administrativeLevel1),
80
+ mapper: { label: "name", value: "id" },
81
+ method: 'getOptions',
82
+ entity: 'AdministrativeLevel',
83
+ style: { flex: 1 },
84
+ labelStyle: { flex: 1 },
85
+ },
86
+ subCategory: {
87
+ type: 'select',
88
+ label: 'Category',
89
+ placeholder: (t) => `${t('Filter by')} ${t('Category').toLowerCase()}`,
90
+ style: { flex: 1 },
91
+ labelStyle: { flex: 1 },
92
+ getLabel: (option) => option.label,
93
+ getValue: (option) => option.value,
94
+ filterOptions: (val) => {
95
+ if (val) {
96
+ const { option, filters } = val
97
+ if (filters && option) {
98
+ const { filters: optionFilters } = option;
99
+ if (Array.isArray(optionFilters) && optionFilters.length) {
100
+ const { value, condition } = optionFilters[0];
101
+ if (condition === 'includes') {
102
+ return value.includes('corporation');
103
+ }
104
+ }
105
+ }
106
+ }
107
+ return true;
108
+ },
109
+ },
110
+ positionInTheMineralSupplyChain: {
111
+ type: 'select',
112
+ label: 'Position',
113
+ placeholder: (t) => `${t('Filter by')} ${t('Position').toLowerCase()}`,
114
+ style: { flex: 1 },
115
+ labelStyle: { flex: 1 },
116
+ getLabel: (option) => option.label,
117
+ getValue: (option) => option.value,
118
+ },
119
+ status: {
120
+ type: "select",
121
+ label: "Status",
122
+ placeholder: (t) => `${t("Filter by")} ${t("Status").toLowerCase()}`,
123
+ style: { flex: 1 },
124
+ labelStyle: { fley: 1 },
125
+ getLabel: (option) => option.label,
126
+ getValue: (option) => option.value,
127
+ },
128
+ category:{
9
129
  type: 'select',
10
- placeholder: t('Country'),
130
+ label: 'Category',
131
+ placeholder: (t) => `${t('Filter by')} ${t('Category').toLowerCase()}`,
11
132
  style: { flex: 1 },
12
133
  labelStyle: { flex: 1 },
13
134
  getLabel: (option) => option.label,
14
135
  getValue: (option) => option.value,
15
- },
16
- }
136
+ }
137
+ }
17
138
  }
18
139
 
19
140
  export const filtersConfig = {
@@ -22,9 +143,40 @@ export const filtersConfig = {
22
143
  };
23
144
 
24
145
  export const getFilterOptions = (options, t) => {
25
- const { countries } = options || {};
146
+ const {
147
+ timeframe = [],
148
+ statusOptions = [],
149
+ categoryOptions = [],
150
+ countries = [],
151
+ subCategory = [],
152
+ subCategoriesOptions,
153
+ stakeholderCategoryOptions,
154
+ stakeholderSubCategoriesOptions,
155
+ administrativeLevel1,
156
+ administrativeLevel2,
157
+ category=[],
158
+ } = options || {};
159
+ console.log({options})
160
+
26
161
  const _default = {
27
- country: countries,
162
+ timeframe: timeframe,
163
+ country: countries,
164
+
165
+ category: stakeholderCategoryOptions || categoryOptions,
166
+ administrativeLevel1,
167
+ administrativeLevel2,
168
+ // subCategory: subCategoriesOptions,
169
+ category: category,
170
+ status: [
171
+ {
172
+ value: "submitted",
173
+ label: "Submitted",
174
+ },
175
+ {
176
+ value: "private",
177
+ label: "Private",
178
+ },
179
+ ],
28
180
  }
29
181
 
30
182
  return _default;
@@ -4,7 +4,7 @@ import { MessageTypes } from '../../../../../helpers/messages.js';
4
4
  import DynamicForm from '../../../../core/components/DynamicForm/index.jsx';
5
5
 
6
6
  const EventsCreate = ({
7
- namespace = 'events',
7
+ namespace = 'event',
8
8
  view = 'scoping',
9
9
  edit = false,
10
10
  formData = {},
@@ -39,7 +39,7 @@ const EventsCreate = ({
39
39
  useEffect(() => {
40
40
  if (Object.keys(form).length === 0 && !formData[`${APP}-${view}`]) {
41
41
  if (!edit) {
42
- getData({ namespace, module: APP, view, scope: 'global' });
42
+ getData({ namespace, module: APP, view, scope: 'create' });
43
43
  } else {
44
44
  form = formConfig;
45
45
  data = formValue;
@@ -34,6 +34,7 @@ const EventsTable = ({
34
34
  form = {},
35
35
  extendingFilters = {},
36
36
  applications = [],
37
+ subjectClear = () => {},
37
38
  }) => {
38
39
  const [selectOptions, setSelectOptions] = useState();
39
40
  const [activeTab, setActiveTab] = useState();
@@ -93,6 +94,13 @@ const EventsTable = ({
93
94
  setActiveTab(value);
94
95
  }, []);
95
96
 
97
+ useEffect(
98
+ () => () => {
99
+ subjectClear();
100
+ },
101
+ [],
102
+ );
103
+
96
104
  return (
97
105
  <TablePageWithTabs
98
106
  t={t}
@@ -39,7 +39,7 @@ const StakeholdersCreate = ({
39
39
  useEffect(() => {
40
40
  if (Object.keys(form).length === 0 && !formData[`${APP}-${view}`]) {
41
41
  if (!edit) {
42
- getData({ namespace, module: APP, view, scope: 'global' });
42
+ getData({ namespace, module: APP, view, scope: 'create' });
43
43
  } else {
44
44
  form = formConfig;
45
45
  data = formValue;
@@ -33,6 +33,7 @@ const LocationsTable = ({
33
33
  formValue = {},
34
34
  form = {},
35
35
  applications = [],
36
+ subjectClear = () => {},
36
37
  }) => {
37
38
  const [selectOptions, setSelectOptions] = useState();
38
39
  const [activeTab, setActiveTab] = useState();
@@ -80,6 +81,13 @@ const LocationsTable = ({
80
81
  setActiveTab(value);
81
82
  }, []);
82
83
 
84
+ useEffect(
85
+ () => () => {
86
+ subjectClear();
87
+ },
88
+ [],
89
+ );
90
+
83
91
  return (
84
92
  <TablePageWithTabs
85
93
  t={t}
@@ -39,7 +39,7 @@ const StakeholdersCreate = ({
39
39
  useEffect(() => {
40
40
  if (Object.keys(form).length === 0 && !formData[`${APP}-${view}`]) {
41
41
  if (!edit) {
42
- getData({ namespace, module: APP, view, scope: 'global' });
42
+ getData({ namespace, module: APP, view, scope: 'create' });
43
43
  } else {
44
44
  form = formConfig;
45
45
  data = formValue;
@@ -33,6 +33,7 @@ const StakeholdersTable = ({
33
33
  formValue = {},
34
34
  form = {},
35
35
  applications = [],
36
+ subjectClear = () => {},
36
37
  }) => {
37
38
  const [selectOptions, setSelectOptions] = useState();
38
39
  const [activeTab, setActiveTab] = useState();
@@ -76,6 +77,13 @@ const StakeholdersTable = ({
76
77
  setActiveTab(value);
77
78
  }, []);
78
79
 
80
+ useEffect(
81
+ () => () => {
82
+ subjectClear();
83
+ },
84
+ [],
85
+ );
86
+
79
87
  return (
80
88
  <TablePageWithTabs
81
89
  t={t}
@@ -119,7 +127,7 @@ const StakeholdersTable = ({
119
127
  type,
120
128
  t("affirmations::subject-created-successfully") || m,
121
129
  );
122
- goTo(`/app/stakeholders`);
130
+ goTo(`/app/edit/stakeholders/${data.datastakeId}`);
123
131
  }
124
132
  }}
125
133
  onCancel={onDrawerClose}