datastake-daf 0.6.806 → 0.6.807
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.
- package/dist/pages/index.js +756 -121
- package/package.json +1 -1
- package/src/@daf/pages/Edit/hooks/usePrepareForm.js +6 -5
- package/src/@daf/pages/TablePage/create.jsx +2 -2
- package/src/@daf/pages/View/hooks/useCallToGetData.js +4 -2
- package/src/@daf/pages/View/hooks/usePrepareForm.js +13 -5
- package/src/pages.js +1 -0
package/package.json
CHANGED
|
@@ -28,15 +28,16 @@ export const usePrepareForm = ({
|
|
|
28
28
|
const prepareForm = (setExtra = true) => {
|
|
29
29
|
if (isSupported) {
|
|
30
30
|
const dKey = namespaceConfig?.dataKey;
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
const nKey = `${APP}-${namespaceConfig?.view}`;
|
|
32
|
+
if (hasKeyInObject(allData, dKey) && hasKeyInObject(allData[dKey], nKey)) {
|
|
33
|
+
const d = JSON.parse(JSON.stringify(allData[dKey][nKey].data || {}));
|
|
33
34
|
Object.keys(d).forEach((k) => {
|
|
34
35
|
if (d[k] === null) {
|
|
35
36
|
d[k] = undefined;
|
|
36
37
|
}
|
|
37
38
|
});
|
|
38
39
|
if (d.datastakeId === id || d.applicationId === id || id === "user" || d.id === id) {
|
|
39
|
-
const formG = mapFormGroup(allData[dKey].form || {}, d);
|
|
40
|
+
const formG = mapFormGroup(allData[dKey][nKey].form || {}, d);
|
|
40
41
|
setForm(formG);
|
|
41
42
|
|
|
42
43
|
if (setExtra) {
|
|
@@ -74,7 +75,7 @@ export const usePrepareForm = ({
|
|
|
74
75
|
setEditValues({ ...d });
|
|
75
76
|
setInputsMeta(d?.meta?.inputs || {});
|
|
76
77
|
setOriginalData({ ...d });
|
|
77
|
-
setLinkingForms(allData[dKey].linkingForms);
|
|
78
|
+
setLinkingForms(allData[dKey][nKey].linkingForms);
|
|
78
79
|
setLoading(false);
|
|
79
80
|
return;
|
|
80
81
|
}
|
|
@@ -84,7 +85,7 @@ export const usePrepareForm = ({
|
|
|
84
85
|
setEditValues({ ...d });
|
|
85
86
|
setInputsMeta(d?.meta?.inputs || {});
|
|
86
87
|
setOriginalData({ ...d });
|
|
87
|
-
setLinkingForms(allData[dKey].linkingForms);
|
|
88
|
+
setLinkingForms(allData[dKey][nKey].linkingForms);
|
|
88
89
|
setLoading(false);
|
|
89
90
|
}
|
|
90
91
|
}
|
|
@@ -33,13 +33,13 @@ const Create = ({
|
|
|
33
33
|
let {
|
|
34
34
|
form = {},
|
|
35
35
|
data = defaultData || {},
|
|
36
|
-
} = !edit ? (formData || {}) : {
|
|
36
|
+
} = !edit ? (formData[`${APP}-${view}`] || {}) : {
|
|
37
37
|
form: formConfig,
|
|
38
38
|
data: formValue
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
useEffect(() => {
|
|
42
|
-
if (Object.keys(form).length === 0) {
|
|
42
|
+
if (Object.keys(form).length === 0 && !formData[`${APP}-${view}`]) {
|
|
43
43
|
if (!edit) {
|
|
44
44
|
getData({ namespace, module: APP, view, scope });
|
|
45
45
|
} else {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useRef, useEffect } from "react";
|
|
2
2
|
import { hasKeyInObject } from "../../../../@daf/utils/object.js";
|
|
3
|
+
import { getNkey } from "../../../../@daf/core/components/ViewForm/helper.js";
|
|
3
4
|
|
|
4
5
|
export const useCallToGetData = ({
|
|
5
6
|
namespaceConfig,
|
|
@@ -18,10 +19,11 @@ export const useCallToGetData = ({
|
|
|
18
19
|
|
|
19
20
|
const callToGetData = (_doCall = false) => {
|
|
20
21
|
const dKey = namespaceConfig?.dataKey;
|
|
22
|
+
const nKey = `${APP}-${getNkey(namespace || "")}`;
|
|
21
23
|
const doCall = _doCall
|
|
22
24
|
? true
|
|
23
|
-
: hasKeyInObject(allData, dKey)
|
|
24
|
-
? allData[dKey]?.data?.datastakeId !== id
|
|
25
|
+
: hasKeyInObject(allData, dKey) && hasKeyInObject(allData[dKey], nKey)
|
|
26
|
+
? allData[dKey][nKey]?.data?.datastakeId !== id
|
|
25
27
|
: true;
|
|
26
28
|
if (doCall) {
|
|
27
29
|
if (isSupported) {
|
|
@@ -17,20 +17,27 @@ export const usePrepareForm = ({
|
|
|
17
17
|
const [linkingForms, setLinkingForms] = useState({});
|
|
18
18
|
const [loading, setLoading] = useState(true);
|
|
19
19
|
const [notFound, setNotFound] = useState(false);
|
|
20
|
+
|
|
21
|
+
console.log({form, data, groups, linkingForms, loading, notFound})
|
|
20
22
|
|
|
21
23
|
const prepareForm = (currentView) => {
|
|
22
24
|
const dKey = namespaceConfig?.dataKey;
|
|
25
|
+
const nKey = `${APP}-${currentView}`;
|
|
26
|
+
console.log({dKey, nKey, allData})
|
|
27
|
+
|
|
28
|
+
console.log({condition1: hasKeyInObject(allData, dKey)})
|
|
29
|
+
console.log({condition2: hasKeyInObject(allData[dKey], nKey)})
|
|
23
30
|
|
|
24
|
-
if (hasKeyInObject(allData, dKey)) {
|
|
31
|
+
if (hasKeyInObject(allData, dKey) && hasKeyInObject(allData[dKey], nKey)) {
|
|
25
32
|
const {
|
|
26
33
|
form = {},
|
|
27
34
|
data = {},
|
|
28
35
|
config = {},
|
|
29
36
|
linkingForms = {},
|
|
30
|
-
} = JSON.parse(JSON.stringify(allData[dKey] || {}));
|
|
37
|
+
} = JSON.parse(JSON.stringify(allData[dKey][nKey] || {}));
|
|
38
|
+
console.log("here", dKey, nKey)
|
|
31
39
|
|
|
32
|
-
if(
|
|
33
|
-
if (data.datastakeId === id || id === "user" || data.id === id) {
|
|
40
|
+
if (data.datastakeId === id || id === "user" || data.id === id) {
|
|
34
41
|
if (viewConfig.adminNamespaces.includes(namespace)) {
|
|
35
42
|
setForm(form);
|
|
36
43
|
} else {
|
|
@@ -57,8 +64,9 @@ export const usePrepareForm = ({
|
|
|
57
64
|
setNotFound(true);
|
|
58
65
|
}
|
|
59
66
|
}
|
|
60
|
-
}
|
|
61
67
|
}
|
|
68
|
+
|
|
69
|
+
console.log('data', data)
|
|
62
70
|
};
|
|
63
71
|
|
|
64
72
|
const getCertainData = allData?.[namespaceConfig?.dataKey];
|
package/src/pages.js
CHANGED
|
@@ -14,6 +14,7 @@ export { default as PlantingCycleSummary } from './@daf/pages/Summary/Activities
|
|
|
14
14
|
export { default as MonitoringCampaignSummary } from './@daf/pages/Summary/Activities/MonitoringCampaign/index.jsx';
|
|
15
15
|
export { default as MineSummary } from './@daf/pages/Summary/Minesite/index.jsx';
|
|
16
16
|
export { default as MonitoringActivitySummary } from './@daf/pages/Summary/Activities/Monitoring/index.jsx';
|
|
17
|
+
export { default as UsersTable } from './@daf/core/components/Screens/Users/index.jsx';
|
|
17
18
|
|
|
18
19
|
// View
|
|
19
20
|
export { default as View } from './@daf/pages/View/index.jsx';
|