datastake-daf 0.6.766 → 0.6.767

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.
@@ -0,0 +1,106 @@
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 Create = ({
7
+ namespace = 'stakeholders',
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
+ scope
31
+ }) => {
32
+ let {
33
+ form = {},
34
+ data = defaultData || {},
35
+ } = !edit ? (formData[`${APP}-${view}`] || {}) : {
36
+ form: formConfig,
37
+ data: formValue
38
+ };
39
+
40
+ useEffect(() => {
41
+ if (Object.keys(form).length === 0 && !formData[`${APP}-${view}`]) {
42
+ if (!edit) {
43
+ getData({ namespace, module: APP, view, scope });
44
+ } else {
45
+ form = formConfig;
46
+ data = formValue;
47
+ }
48
+ }
49
+ }, [edit, user?.language, scope]);
50
+
51
+ return (
52
+ <div className="daf-create-form">
53
+ <DynamicForm
54
+ form={form}
55
+ data={data}
56
+ showSaveAndNext={false}
57
+ module={APP}
58
+ onCancel={onCancel}
59
+ isCreate
60
+ t={t}
61
+ excludedKeys={["title"]}
62
+ user={user}
63
+ ajaxForms={ajaxForms}
64
+ ajaxOptions={ajaxOptions}
65
+ getAppHeader={getAppHeader}
66
+ getApiBaseUrl={getApiBaseUrl}
67
+ changeAjaxOptions={changeAjaxOptions}
68
+ app={APP}
69
+ query={query}
70
+ goTo={goTo}
71
+ changeAjaxForms={changeAjaxForms}
72
+ submit={(payload, setSelectedFormNext) => {
73
+ const payloadData = { ...payload, module: APP, namespace };
74
+
75
+ const newPayload = {
76
+ ...defaultData,
77
+ ...payloadData,
78
+ form: 'stakeholder'
79
+ };
80
+
81
+
82
+ const callback = (type, m, data) => {
83
+ if (setSelectedFormNext) {
84
+ setSelectedFormNext();
85
+ }
86
+ if (type === MessageTypes.SUCCESS) {
87
+ if (onSubmitted) onSubmitted(type, m, data);
88
+ } else {
89
+ message.error(m);
90
+ }
91
+ };
92
+
93
+ saveData(
94
+ !data && !data.id ? newPayload : Object.assign(newPayload, { id: data.id }),
95
+ callback,
96
+ );
97
+ }}
98
+ isFormDisabled={() => {
99
+ return !data || !data.typeOfEvent;
100
+ }}
101
+ />
102
+ </div>
103
+ )
104
+ }
105
+
106
+ export default Create
@@ -0,0 +1,115 @@
1
+ import React, { useState, useEffect, useCallback } from 'react';
2
+ import { useFetchData } from '../../../../../pages/hook.js';
3
+ import TablePageWithTabs from '../TablePageWithTabs/index.jsx';
4
+
5
+ const TableWithTabsAndCreate = ({
6
+ t = () => {},
7
+ goTo = () => {},
8
+ user = {},
9
+ options = {},
10
+ getRedirectLink = () => {},
11
+ theme = {},
12
+ loading = false,
13
+ data = {},
14
+ isMobile,
15
+ APP,
16
+ location,
17
+ formConfig = {
18
+ getFormData: () => {},
19
+ saveFormData: () => {},
20
+ formLoading: false,
21
+ query: {},
22
+ ajaxForms: {},
23
+ changeAjaxForms: () => {},
24
+ ajaxOptions: {},
25
+ changeAjaxOptions: () => {},
26
+ formData: {},
27
+ formValue: {},
28
+ form: {},
29
+ namespace: '',
30
+ view: '',
31
+ scope: '',
32
+ },
33
+ filtersConfig = {
34
+ getFiltersConfig: () => {},
35
+ getFilterOptions: () => {},
36
+ extendingFilters: {},
37
+ checkboxConfig: {},
38
+ selectOptions: {},
39
+ selectFiltersConfig: {},
40
+ },
41
+ getData = () => {},
42
+ getApiBaseUrl = () => {},
43
+ getAppHeader = () => {},
44
+ applications = [],
45
+ subjectClear,
46
+ subject,
47
+ columns,
48
+ viewConfig = {
49
+ title: '',
50
+ breadcrumbs: [],
51
+ createTitle: '',
52
+ },
53
+ onDownload,
54
+ }) => {
55
+ const [selectOptions, setSelectOptions] = useState();
56
+ const [activeTab, setActiveTab] = useState("own");
57
+
58
+ useFetchData({
59
+ location,
60
+ getData,
61
+ activeTab,
62
+ extendingFilters: filtersConfig.extendingFilters,
63
+ subject,
64
+ })
65
+
66
+ useEffect(() => {
67
+ setSelectOptions((prev) => ({
68
+ ...prev,
69
+ ...filtersConfig.getFilterOptions(options, t),
70
+ }))
71
+ }, [options, t])
72
+
73
+ const handleActiveTabChange = useCallback((value) => {
74
+ setActiveTab(value);
75
+ }, []);
76
+
77
+ useEffect(
78
+ () => () => {
79
+ if(subjectClear && typeof subjectClear === 'function') {
80
+ subjectClear();
81
+ }
82
+ },
83
+ [],
84
+ );
85
+
86
+ return (
87
+ <TablePageWithTabs
88
+ t={t}
89
+ title={t(viewConfig.title || "")}
90
+ breadCrumbs={viewConfig.breadcrumbs}
91
+ location={location}
92
+ loading={loading}
93
+ goTo={goTo}
94
+ defaultActiveTab={"own"}
95
+ columns={columns}
96
+ data={data}
97
+ checkboxConfig={filtersConfig.checkboxConfig}
98
+ APP={APP}
99
+ getApiBaseUrl={getApiBaseUrl}
100
+ selectOptions={selectOptions}
101
+ selectFiltersConfig={filtersConfig.selectFiltersConfig}
102
+ getRedirectLink={getRedirectLink}
103
+ filtersConfig={filtersConfig}
104
+ isMobile={isMobile}
105
+ view={subject}
106
+ getActiveTab={handleActiveTabChange}
107
+ onDownload={onDownload && typeof onDownload === 'function' ? onDownload : undefined}
108
+ drawerTitle={t(viewConfig.createTitle || "")}
109
+ >
110
+
111
+ </TablePageWithTabs>
112
+ );
113
+ };
114
+
115
+ export default TableWithTabsAndCreate;
@@ -9,6 +9,11 @@ export const defaultMapConfig = {
9
9
  preferCanvas: true,
10
10
  zoomControl: false,
11
11
  maxBounds: maxBounds,
12
+ zoomSnap: 0.5,
13
+ zoomDelta: 0.5,
14
+ wheelPxPerZoomLevel: 150,
15
+ zoomAnimation: true,
16
+ zoomAnimationThreshold: 10,
12
17
  };
13
18
 
14
19
  export const filterValidGPS = (data) => {
@@ -4,6 +4,7 @@ import Widget from '../../../../../core/components/Dashboard/Widget/index.jsx';
4
4
  import Map from '../../../../../core/components/Dashboard/Map/index.jsx';
5
5
  import { getTagColor } from '../../../../../utils/productTag.js';
6
6
  import PropTypes from 'prop-types';
7
+ import { findOptions } from '../../../../../../helpers/StringHelper.js';
7
8
 
8
9
 
9
10
  function SupplyChainMap({selectedSources = {}, t = () => {}, goTo = () => {}, options = {}, getRedirectLink = () => {} }) {
@@ -23,6 +24,8 @@ function SupplyChainMap({selectedSources = {}, t = () => {}, goTo = () => {}, op
23
24
 
24
25
  const { loading, data } = useWidgetFetch({config: defaultConfig});
25
26
 
27
+ console.log('data', data);
28
+
26
29
  return (
27
30
  <Widget
28
31
  title={t("Supply Chain Map")}
@@ -34,13 +37,13 @@ function SupplyChainMap({selectedSources = {}, t = () => {}, goTo = () => {}, op
34
37
  data={Array.isArray(data) && data.length > 0 ? data : []}
35
38
  renderTooltip={(data) => {
36
39
  const productsText = data?.products?.[0];
37
- const minerals = options?.minerals || [];
40
+ const minerals = options?.mineralOptions || [];
38
41
  const participants = data?.stakeholders?.map((stakeholder) => stakeholder.name);
39
42
  return [
40
43
  {
41
44
  label: t("Products"),
42
45
  value:
43
- minerals.find((mineral) => mineral.value === productsText)?.label ||
46
+ findOptions(productsText, minerals) ||
44
47
  productsText ||
45
48
  "-",
46
49
  ...(productsText && { tag: getTagColor(productsText) }),
@@ -1,5 +1,4 @@
1
1
  export const getEventCategoryBySubject = (eventCategoryObject, subject, isSingular = false) => {
2
- console.log({eventCategoryObject, subject})
3
2
  if (!eventCategoryObject || typeof eventCategoryObject !== 'object') {
4
3
  return null;
5
4
  }
@@ -90,7 +90,7 @@ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink,
90
90
  return <div className="daf-default-cell" />
91
91
  }
92
92
 
93
- const operators = all?.operator?.map((operator) => operator?.clientLocation?.name);
93
+ const operators = all?.operator?.map((operator) => operator?.locationClient?.name)?.filter(Boolean);
94
94
  return (operators && operators.length > 0) ? <MoreOptions data={operators || []} toolTipPlacement={operators?.length < 2 ? "topLeft" : "top"} /> : '-';
95
95
  },
96
96
  },
@@ -15,6 +15,7 @@ const TradeRelationships = ({
15
15
  APP,
16
16
  }) => {
17
17
  const [filters, setFilters] = useState({});
18
+ const [isFullyRendered, setIsFullyRendered] = useState(true);
18
19
 
19
20
  const onFilterChange = (filters) => {
20
21
  setFilters((p) => ({ ...p, ...filters }));
@@ -54,7 +55,7 @@ const TradeRelationships = ({
54
55
  <Widget
55
56
  title={t("Trade Relationships")}
56
57
  className="flex flex-1 with-border-header no-p-body"
57
- loading={loading}
58
+ loading={loading || isFullyRendered}
58
59
  >
59
60
  <div className="flex flex-1 flex-column justify-content-center">
60
61
  <div style={{ height: 600 }} className="flex flex-column">
@@ -76,6 +77,9 @@ const TradeRelationships = ({
76
77
  tooltipTitle="Trade"
77
78
  filtersConfig={filterConfig}
78
79
  onFilterChange={onFilterChange}
80
+ onRenderComplete={(data) => {
81
+ setIsFullyRendered(!data);
82
+ }}
79
83
  />
80
84
  </div>
81
85
  </div>
@@ -1,4 +1,9 @@
1
1
  const en = {
2
+ "accounts": "Accounts",
3
+ "users": "Users",
4
+ "subjects": "Subjects",
5
+ "active-users": "Active Users",
6
+ "total-data-points": "Total Data Points",
2
7
  "Identified Customers": "Identified Customers",
3
8
  "Identified Suppliers": "Identified Suppliers",
4
9
  "Associated Mine Sites": "Associated Mine Sites",
@@ -1,4 +1,9 @@
1
1
  const fr = {
2
+ "accounts": "Comptes",
3
+ "users": "Utilisateurs",
4
+ "subjects": "Sujets",
5
+ "active-users": "Utilisateurs Actifs",
6
+ "total-data-points": "Total Points de Données",
2
7
  "Identified Customers": "Clients identifiés",
3
8
  "Identified Suppliers": "Fournisseurs identifiés",
4
9
  "Associated Mine Sites": "Sites miniers associés",