datastake-daf 0.6.819 → 0.6.821
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/components/index.js +2264 -1099
- package/dist/hooks/index.js +16 -5
- package/dist/pages/index.js +251 -65
- package/dist/services/index.js +104 -9
- package/dist/utils/index.js +75 -8
- package/package.json +1 -1
- package/src/@daf/core/components/AuthForm/index.jsx +12 -3
- package/src/@daf/core/components/DynamicForm/_index.scss +1 -3
- package/src/@daf/core/components/EditForm/_index.scss +0 -4
- package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/TopContributors/hook.js +27 -1
- package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/TopContributors/index.jsx +2 -3
- package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/UserGrowth/hook.js +0 -1
- package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/UserGrowth/index.jsx +1 -3
- package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/index.jsx +1 -1
- package/src/@daf/core/components/Screens/Admin/AdminModals/AddAccount/index.jsx +82 -10
- package/src/@daf/core/components/Screens/Admin/AdminModals/CombineLocation/index.jsx +51 -51
- package/src/@daf/core/components/Screens/Admin/AdminModals/CombineSubjects/index.jsx +6 -1
- package/src/@daf/core/components/Screens/Admin/AdminModals/NewAccount/index.jsx +53 -31
- package/src/@daf/core/components/Screens/Admin/AdminModals/NewUser/index.jsx +36 -10
- package/src/@daf/core/components/Screens/Admin/AdminModals/TransferRights/index.jsx +2 -2
- package/src/@daf/core/components/Screens/Admin/AdminScreens/Accounts.jsx +37 -10
- package/src/@daf/core/components/Screens/Admin/AdminScreens/Dashboard.jsx +2 -2
- package/src/@daf/core/components/Screens/Admin/AdminScreens/Documents.jsx +81 -0
- package/src/@daf/core/components/Screens/Admin/AdminScreens/Events.jsx +77 -0
- package/src/@daf/core/components/Screens/Admin/AdminScreens/index.js +2 -1
- package/src/@daf/core/components/Screens/Admin/AdminTables/AccountTable/helper.js +22 -30
- package/src/@daf/core/components/Screens/Admin/AdminTables/AccountTable/index.jsx +28 -16
- package/src/@daf/core/components/Screens/Admin/AdminTables/DocumentsTable/column.js +93 -0
- package/src/@daf/core/components/Screens/Admin/AdminTables/DocumentsTable/helper.js +43 -0
- package/src/@daf/core/components/Screens/Admin/AdminTables/DocumentsTable/index.jsx +201 -0
- package/src/@daf/core/components/Screens/Admin/AdminTables/EventsTable/column.js +113 -0
- package/src/@daf/core/components/Screens/Admin/AdminTables/EventsTable/helper.js +58 -0
- package/src/@daf/core/components/Screens/Admin/AdminTables/EventsTable/index.jsx +176 -0
- package/src/@daf/core/components/Screens/Admin/AdminTables/LocationTable/helper.js +3 -6
- package/src/@daf/core/components/Screens/Admin/AdminTables/LocationTable/index.jsx +17 -2
- package/src/@daf/core/components/Screens/Admin/AdminTables/SubjectsTable/helper.js +3 -6
- package/src/@daf/core/components/Screens/Admin/AdminTables/SubjectsTable/index.jsx +27 -13
- package/src/@daf/core/components/Screens/Admin/AdminTables/UserTable/index.jsx +0 -1
- package/src/@daf/core/components/Screens/Admin/AdminTables/components/index.jsx +4 -2
- package/src/@daf/core/components/Screens/Admin/AdminTables/hook.js +3 -0
- package/src/@daf/core/components/Screens/Admin/AdminViews/components/Edit/index.jsx +21 -9
- package/src/@daf/core/components/Screens/Admin/AdminViews/components/Users/helper.js +16 -11
- package/src/@daf/core/components/Screens/Admin/AdminViews/components/Users/index.jsx +16 -4
- package/src/@daf/core/components/Screens/Admin/AdminViews/components/View/helpers.js +9 -17
- package/src/@daf/core/components/Screens/Admin/AdminViews/index.jsx +12 -16
- package/src/@daf/core/components/Screens/Admin/AppInvitation/index.jsx +124 -99
- package/src/@daf/core/components/Screens/Admin/adminRoutes.js +44 -28
- package/src/@daf/hooks/useAdminDashboard.js +7 -4
- package/src/@daf/hooks/useSources.js +2 -1
- package/src/@daf/pages/Events/columns.js +15 -3
- package/src/@daf/pages/Locations/MineSite/columns.js +18 -1
- package/src/@daf/pages/TablePage/columns.js +2 -0
- package/src/@daf/pages/TablePage/hook.js +0 -2
- package/src/@daf/pages/View/hooks/useViewActions.js +13 -0
- package/src/@daf/pages/View/hooks/useViewPermissions.js +16 -0
- package/src/@daf/pages/View/index.jsx +32 -4
- package/src/@daf/services/AdminService.js +80 -8
- package/src/@daf/services/DashboardService.js +3 -3
- package/src/@daf/utils/filters.js +13 -15
- package/src/constants/locales/en/translation.js +24 -4
- package/src/constants/locales/fr/translation.js +17 -0
- package/src/constants/locales/sp/translation.js +28 -7
- package/src/helpers/copyToClipboard.js +60 -0
- package/src/@daf/core/components/Screens/Admin/AdminScreens/SubjectsView.jsx +0 -395
- package/src/@daf/core/components/Screens/Admin/AdminViews/EditLocation/configTransformer.js +0 -137
- package/src/@daf/core/components/Screens/Admin/AdminViews/EditLocation/index.js +0 -9
- package/src/@daf/core/components/Screens/Admin/AdminViews/EditLocation/index.jsx +0 -196
- package/src/@daf/core/components/Screens/Admin/AdminViews/EditStakeholder/configTransformer.js +0 -216
- package/src/@daf/core/components/Screens/Admin/AdminViews/EditStakeholder/index.js +0 -7
- package/src/@daf/core/components/Screens/Admin/AdminViews/EditStakeholder/index.jsx +0 -184
- package/src/@daf/core/components/Screens/Admin/AdminViews/ViewLocation/config.js +0 -64
- package/src/@daf/core/components/Screens/Admin/AdminViews/ViewLocation/helpers.js +0 -10
- package/src/@daf/core/components/Screens/Admin/AdminViews/ViewLocation/index.jsx +0 -77
- package/src/@daf/core/components/Screens/Admin/AdminViews/ViewStakeholder/config.js +0 -51
- package/src/@daf/core/components/Screens/Admin/AdminViews/ViewStakeholder/helpers.js +0 -0
- package/src/@daf/core/components/Screens/Admin/AdminViews/ViewStakeholder/index.jsx +0 -76
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
import { useEffect, useMemo, useState } from "react";
|
|
2
|
-
import { useForms } from "../../../../../context/Forms";
|
|
3
|
-
import { EditForm } from "../../../../EditForm/form.jsx";
|
|
4
|
-
import { transformConfigToEditForm } from "./configTransformer.js";
|
|
5
|
-
import { getMainApiUrl, getAppHeader as getBaseAppHeader } from "../../../../../../services/BaseService.js";
|
|
6
|
-
import { convertUndefinedToNull } from "../../../../../../utils/object.js";
|
|
7
|
-
|
|
8
|
-
export default function EditLocation({
|
|
9
|
-
t,
|
|
10
|
-
conf,
|
|
11
|
-
data = {},
|
|
12
|
-
formOptions = {},
|
|
13
|
-
MainForm,
|
|
14
|
-
setData = () => {},
|
|
15
|
-
isChanged,
|
|
16
|
-
setIsChanged,
|
|
17
|
-
goToView,
|
|
18
|
-
getApiBaseUrl = getMainApiUrl,
|
|
19
|
-
getAppHeader = getBaseAppHeader,
|
|
20
|
-
user = null,
|
|
21
|
-
goTo = () => {},
|
|
22
|
-
query = null,
|
|
23
|
-
app = null,
|
|
24
|
-
}) {
|
|
25
|
-
console.log('EditLocation - Props received:', {
|
|
26
|
-
conf,
|
|
27
|
-
data,
|
|
28
|
-
formOptions,
|
|
29
|
-
isChanged,
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
const { addCheck, removeCheck } = useForms();
|
|
33
|
-
|
|
34
|
-
const [inputsMeta, setInputsMeta] = useState({});
|
|
35
|
-
const [linkingForms, setLinkingForms] = useState({});
|
|
36
|
-
const [errors, setErrors] = useState({});
|
|
37
|
-
const [ajaxForms, setAjaxForms] = useState({});
|
|
38
|
-
const [ajaxOptions, setAjaxOptions] = useState({});
|
|
39
|
-
|
|
40
|
-
useEffect(() => {
|
|
41
|
-
if (isChanged) {
|
|
42
|
-
addCheck(() => goToView());
|
|
43
|
-
} else {
|
|
44
|
-
removeCheck();
|
|
45
|
-
}
|
|
46
|
-
}, [isChanged, addCheck, removeCheck, goToView]);
|
|
47
|
-
|
|
48
|
-
const editFormConfig = useMemo(() => {
|
|
49
|
-
console.log('EditLocation - Transforming config:', {
|
|
50
|
-
conf,
|
|
51
|
-
formOptions,
|
|
52
|
-
});
|
|
53
|
-
const transformed = transformConfigToEditForm(conf, formOptions, t);
|
|
54
|
-
console.log('EditLocation - Transformed editFormConfig:', transformed);
|
|
55
|
-
return transformed;
|
|
56
|
-
}, [conf, formOptions, t]);
|
|
57
|
-
|
|
58
|
-
const onValuesChange = (changedValues, allValues) => {
|
|
59
|
-
console.log('EditLocation - Values changed:', {
|
|
60
|
-
changedValues,
|
|
61
|
-
allValues,
|
|
62
|
-
});
|
|
63
|
-
expectations
|
|
64
|
-
const convertedValues = convertUndefinedToNull(allValues);
|
|
65
|
-
|
|
66
|
-
setIsChanged(true);
|
|
67
|
-
setData(convertedValues);
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const changeInputMeta = ({ key, type, value, otherValues = {} }) => {
|
|
71
|
-
console.log('EditLocation - changeInputMeta:', { key, type, value, otherValues });
|
|
72
|
-
|
|
73
|
-
setInputsMeta((prev) => ({
|
|
74
|
-
...prev,
|
|
75
|
-
[key]: { ...(prev[key] || {}), ...value },
|
|
76
|
-
}));
|
|
77
|
-
|
|
78
|
-
const otherValuesKeys = Object.keys(otherValues);
|
|
79
|
-
if (otherValuesKeys.length) {
|
|
80
|
-
otherValuesKeys.forEach((k) => {
|
|
81
|
-
MainForm.setFieldValue(k, otherValues[k]);
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
const updatedData = {
|
|
85
|
-
...data,
|
|
86
|
-
...otherValues,
|
|
87
|
-
};
|
|
88
|
-
setData(updatedData);
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
const changeLinking = ({ key, linkingKey, value }) => {
|
|
93
|
-
console.log('EditLocation - changeLinking:', { key, linkingKey, value });
|
|
94
|
-
|
|
95
|
-
const updatedLinking = {
|
|
96
|
-
...linkingForms,
|
|
97
|
-
[key]: {
|
|
98
|
-
...(linkingForms[key] || {}),
|
|
99
|
-
[linkingKey]: value,
|
|
100
|
-
},
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
setLinkingForms(updatedLinking);
|
|
104
|
-
|
|
105
|
-
const updatedData = {
|
|
106
|
-
...data,
|
|
107
|
-
linking: {
|
|
108
|
-
...(data?.linking || {}),
|
|
109
|
-
[key]: {
|
|
110
|
-
...((data?.linking || {})[key] || {}),
|
|
111
|
-
[linkingKey]: value,
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
setData(updatedData);
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
const changeErrors = (newErrors) => {
|
|
120
|
-
console.log('EditLocation - changeErrors:', newErrors);
|
|
121
|
-
setErrors(newErrors);
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
const changeAjaxForms = (newAjaxForms) => {
|
|
125
|
-
console.log('EditLocation - changeAjaxForms:', newAjaxForms);
|
|
126
|
-
setAjaxForms(newAjaxForms);
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
const changeAjaxOptions = (newAjaxOptions) => {
|
|
130
|
-
console.log('EditLocation - changeAjaxOptions:', newAjaxOptions);
|
|
131
|
-
setAjaxOptions(newAjaxOptions);
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
if (!editFormConfig) {
|
|
135
|
-
console.error('EditLocation - No editFormConfig generated!');
|
|
136
|
-
return null;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
const definition = (
|
|
141
|
-
<>
|
|
142
|
-
<div className="group">
|
|
143
|
-
<div className="daf-title with-subtitle">
|
|
144
|
-
<h1>{t(conf.title)}</h1>
|
|
145
|
-
{conf.description && (
|
|
146
|
-
<p style={{
|
|
147
|
-
color: '#8c8c8c',
|
|
148
|
-
fontSize: '14px',
|
|
149
|
-
marginTop: '8px',
|
|
150
|
-
marginBottom: '0',
|
|
151
|
-
lineHeight: '1.5'
|
|
152
|
-
}}>
|
|
153
|
-
{t(conf.description)}
|
|
154
|
-
</p>
|
|
155
|
-
)}
|
|
156
|
-
</div>
|
|
157
|
-
</div>
|
|
158
|
-
</>
|
|
159
|
-
);
|
|
160
|
-
|
|
161
|
-
return (
|
|
162
|
-
<div className="form-edit flex-row">
|
|
163
|
-
<EditForm
|
|
164
|
-
form={editFormConfig}
|
|
165
|
-
data={data}
|
|
166
|
-
allData={data}
|
|
167
|
-
MainForm={MainForm}
|
|
168
|
-
onValuesChange={onValuesChange}
|
|
169
|
-
t={t}
|
|
170
|
-
definition={definition}
|
|
171
|
-
plainForms={{}}
|
|
172
|
-
linkingForms={linkingForms}
|
|
173
|
-
inputsMeta={inputsMeta}
|
|
174
|
-
changeInputMeta={changeInputMeta}
|
|
175
|
-
changeLinking={changeLinking}
|
|
176
|
-
errors={errors}
|
|
177
|
-
changeErrors={changeErrors}
|
|
178
|
-
staticWidth="614px"
|
|
179
|
-
fullWidth={false}
|
|
180
|
-
noConvert={false}
|
|
181
|
-
getApiBaseUrl={getApiBaseUrl}
|
|
182
|
-
getAppHeader={getAppHeader}
|
|
183
|
-
getMainApiUrl={getMainApiUrl}
|
|
184
|
-
user={user}
|
|
185
|
-
ajaxForms={ajaxForms}
|
|
186
|
-
ajaxOptions={ajaxOptions}
|
|
187
|
-
changeAjaxForms={changeAjaxForms}
|
|
188
|
-
changeAjaxOptions={changeAjaxOptions}
|
|
189
|
-
app={app}
|
|
190
|
-
query={query}
|
|
191
|
-
goTo={goTo}
|
|
192
|
-
/>
|
|
193
|
-
</div>
|
|
194
|
-
);
|
|
195
|
-
}
|
|
196
|
-
|
package/src/@daf/core/components/Screens/Admin/AdminViews/EditStakeholder/configTransformer.js
DELETED
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Transforms simple config format to EditForm's expected format
|
|
3
|
-
*
|
|
4
|
-
* Simple config format:
|
|
5
|
-
* {
|
|
6
|
-
* title: "Core Data",
|
|
7
|
-
* key: "core-data",
|
|
8
|
-
* items: [
|
|
9
|
-
* { label: "Name", key: "name", type: "select", optionsName: "category" }
|
|
10
|
-
* ]
|
|
11
|
-
* }
|
|
12
|
-
*
|
|
13
|
-
* EditForm format:
|
|
14
|
-
* {
|
|
15
|
-
* id: "core-data",
|
|
16
|
-
* options: {
|
|
17
|
-
* name: {
|
|
18
|
-
* type: "select",
|
|
19
|
-
* label: "Name",
|
|
20
|
-
* options: [...],
|
|
21
|
-
* meta: {}
|
|
22
|
-
* }
|
|
23
|
-
* }
|
|
24
|
-
* }
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Transforms a config item to EditForm option format
|
|
29
|
-
* @param {Object} item - Config item
|
|
30
|
-
* @param {Object} formOptions - Available form options (countries, categories, etc.)
|
|
31
|
-
* @param {Function} t - Translation function
|
|
32
|
-
* @returns {Object} EditForm option configuration
|
|
33
|
-
*/
|
|
34
|
-
export function transformConfigItem(item, formOptions = {}, t = (s) => s) {
|
|
35
|
-
const {
|
|
36
|
-
key,
|
|
37
|
-
label,
|
|
38
|
-
type,
|
|
39
|
-
optionsName,
|
|
40
|
-
level,
|
|
41
|
-
placeholder,
|
|
42
|
-
rules,
|
|
43
|
-
showFormIf,
|
|
44
|
-
disabled,
|
|
45
|
-
defaultValue,
|
|
46
|
-
meta: configMeta = {},
|
|
47
|
-
...rest
|
|
48
|
-
} = item;
|
|
49
|
-
|
|
50
|
-
const option = {
|
|
51
|
-
type: type || "text",
|
|
52
|
-
label: label,
|
|
53
|
-
meta: { ...configMeta },
|
|
54
|
-
...rest,
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
if (placeholder) {
|
|
58
|
-
option.placeholder = placeholder;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (rules && Array.isArray(rules)) {
|
|
62
|
-
option.rules = rules;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (showFormIf) {
|
|
66
|
-
option.showFormIf = showFormIf;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (disabled !== undefined) {
|
|
70
|
-
option.disabled = disabled;
|
|
71
|
-
option.meta.disableEdit = disabled;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (defaultValue !== undefined) {
|
|
75
|
-
option.meta.defaultValue = defaultValue;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (type === "select" || type === "multiselect") {
|
|
79
|
-
if (optionsName && formOptions[optionsName]) {
|
|
80
|
-
option.options = formOptions[optionsName].map((opt) => {
|
|
81
|
-
if (typeof opt === 'object' && opt !== null) {
|
|
82
|
-
return {
|
|
83
|
-
value: opt.value,
|
|
84
|
-
label: t(opt.label || opt.value),
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
return {
|
|
88
|
-
value: opt,
|
|
89
|
-
label: t(opt),
|
|
90
|
-
};
|
|
91
|
-
});
|
|
92
|
-
} else if (level && formOptions[level]) {
|
|
93
|
-
option.options = formOptions[level].map((opt) => {
|
|
94
|
-
if (typeof opt === 'object' && opt !== null) {
|
|
95
|
-
return {
|
|
96
|
-
value: opt.value,
|
|
97
|
-
label: t(opt.label || opt.value),
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
return {
|
|
101
|
-
value: opt,
|
|
102
|
-
label: t(opt),
|
|
103
|
-
};
|
|
104
|
-
});
|
|
105
|
-
} else {
|
|
106
|
-
option.options = [];
|
|
107
|
-
console.warn(`No options found for field "${key}" with optionsName="${optionsName}" or level="${level}"`);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
if (type === "multiselect") {
|
|
111
|
-
option.mode = "multiple";
|
|
112
|
-
option.type = "select";
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
if (type === "ajaxSelect") {
|
|
117
|
-
const { entity, method, mapper, filters } = item;
|
|
118
|
-
|
|
119
|
-
if (!entity || !method || !mapper) {
|
|
120
|
-
console.error(`ajaxSelect field "${key}" is missing required properties (entity, method, or mapper)`);
|
|
121
|
-
option.type = "text";
|
|
122
|
-
option.disabled = true;
|
|
123
|
-
} else {
|
|
124
|
-
const filtersString = filters ? JSON.stringify(filters) : "{}";
|
|
125
|
-
const mapperString = JSON.stringify(mapper);
|
|
126
|
-
option.meta.call = `${entity}::${method}(${filtersString})::${mapperString}`;
|
|
127
|
-
option.type = "ajaxSelect";
|
|
128
|
-
|
|
129
|
-
// Disable "add new" functionality if noAddNew is set
|
|
130
|
-
if (option.meta.noAddNew) {
|
|
131
|
-
option.onNewSetValue = false;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
if (type === "administrative") {
|
|
137
|
-
option.type = "text";
|
|
138
|
-
option.disabled = true;
|
|
139
|
-
option.meta.disableEdit = false;
|
|
140
|
-
if (level) {
|
|
141
|
-
option.meta.level = level;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
if (type === "input") {
|
|
146
|
-
option.type = "text";
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
if (type === "switch" || type === "checkbox") {
|
|
150
|
-
option.type = type;
|
|
151
|
-
if (defaultValue === undefined) {
|
|
152
|
-
option.meta.defaultValue = false;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
if (type === "date" || type === "datetime" || type === "year") {
|
|
157
|
-
option.type = type;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
if (type === "textarea") {
|
|
161
|
-
option.type = "textarea";
|
|
162
|
-
option.rows = item.rows || 4;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
if (type === "number") {
|
|
166
|
-
option.type = "text";
|
|
167
|
-
option.meta.inputType = "number";
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
if (option.position === undefined) {
|
|
171
|
-
option.position = 0;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
return option;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Transforms simple config format to EditForm format
|
|
180
|
-
* @param {Object} conf - Simple config object
|
|
181
|
-
* @param {Object} formOptions - Available form options
|
|
182
|
-
* @param {Function} t - Translation function
|
|
183
|
-
* @returns {Object} EditForm configuration
|
|
184
|
-
*/
|
|
185
|
-
export function transformConfigToEditForm(conf, formOptions = {}, t = (s) => s) {
|
|
186
|
-
if (!conf || !conf.items || !Array.isArray(conf.items)) {
|
|
187
|
-
return null;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
const options = {};
|
|
191
|
-
conf.items.forEach((item, index) => {
|
|
192
|
-
const transformedOption = transformConfigItem(item, formOptions, t);
|
|
193
|
-
transformedOption.position = item.position !== undefined ? item.position : index;
|
|
194
|
-
options[item.key] = transformedOption;
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
return {
|
|
198
|
-
id: conf.key || "edit-form",
|
|
199
|
-
introText: "",
|
|
200
|
-
formTitles: conf.formTitles || {},
|
|
201
|
-
options,
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* Extracts field keys from config for filtering form data
|
|
207
|
-
* @param {Object} conf - Simple config object
|
|
208
|
-
* @returns {Array} Array of field keys
|
|
209
|
-
*/
|
|
210
|
-
export function getConfigFieldKeys(conf) {
|
|
211
|
-
if (!conf || !conf.items || !Array.isArray(conf.items)) {
|
|
212
|
-
return [];
|
|
213
|
-
}
|
|
214
|
-
return conf.items.map((item) => item.key);
|
|
215
|
-
}
|
|
216
|
-
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import { useEffect, useMemo, useState } from "react";
|
|
2
|
-
import { useForms } from "../../../../../context/Forms";
|
|
3
|
-
import { EditForm } from "../../../../EditForm/form.jsx";
|
|
4
|
-
import { transformConfigToEditForm } from "./configTransformer.js";
|
|
5
|
-
import { getMainApiUrl, getAppHeader as getBaseAppHeader } from "../../../../../../services/BaseService.js";
|
|
6
|
-
import { convertUndefinedToNull } from "../../../../../../utils/object.js";
|
|
7
|
-
|
|
8
|
-
export default function EditStakeholder({
|
|
9
|
-
t,
|
|
10
|
-
conf,
|
|
11
|
-
data = {},
|
|
12
|
-
formOptions = {},
|
|
13
|
-
MainForm,
|
|
14
|
-
setData = () => {},
|
|
15
|
-
isChanged,
|
|
16
|
-
setIsChanged,
|
|
17
|
-
goToView,
|
|
18
|
-
getApiBaseUrl = getMainApiUrl,
|
|
19
|
-
getAppHeader = getBaseAppHeader,
|
|
20
|
-
user = null,
|
|
21
|
-
goTo = () => {},
|
|
22
|
-
query = null,
|
|
23
|
-
app = null,
|
|
24
|
-
}) {
|
|
25
|
-
const { addCheck, removeCheck } = useForms();
|
|
26
|
-
|
|
27
|
-
const [inputsMeta, setInputsMeta] = useState({});
|
|
28
|
-
const [linkingForms, setLinkingForms] = useState({});
|
|
29
|
-
const [errors, setErrors] = useState({});
|
|
30
|
-
const [ajaxForms, setAjaxForms] = useState({});
|
|
31
|
-
const [ajaxOptions, setAjaxOptions] = useState({});
|
|
32
|
-
|
|
33
|
-
console.log('EditStakeholder - Data received:', data);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
useEffect(() => {
|
|
38
|
-
if (isChanged) {
|
|
39
|
-
addCheck(() => goToView());
|
|
40
|
-
} else {
|
|
41
|
-
removeCheck();
|
|
42
|
-
}
|
|
43
|
-
}, [isChanged, addCheck, removeCheck, goToView]);
|
|
44
|
-
|
|
45
|
-
const editFormConfig = useMemo(() => {
|
|
46
|
-
return transformConfigToEditForm(conf, formOptions, t);
|
|
47
|
-
}, [conf, formOptions, t]);
|
|
48
|
-
|
|
49
|
-
const onValuesChange = (changedValues, allValues) => {
|
|
50
|
-
console.log('EditStakeholder - Values changed:', {
|
|
51
|
-
changedValues,
|
|
52
|
-
allValues,
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
const convertedValues = convertUndefinedToNull(allValues);
|
|
56
|
-
|
|
57
|
-
setIsChanged(true);
|
|
58
|
-
setData(convertedValues);
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
const changeInputMeta = ({ key, type, value, otherValues = {} }) => {
|
|
62
|
-
console.log('EditStakeholder - changeInputMeta:', { key, type, value, otherValues });
|
|
63
|
-
|
|
64
|
-
setInputsMeta((prev) => ({
|
|
65
|
-
...prev,
|
|
66
|
-
[key]: { ...(prev[key] || {}), ...value },
|
|
67
|
-
}));
|
|
68
|
-
|
|
69
|
-
const otherValuesKeys = Object.keys(otherValues);
|
|
70
|
-
if (otherValuesKeys.length) {
|
|
71
|
-
otherValuesKeys.forEach((k) => {
|
|
72
|
-
MainForm.setFieldValue(k, otherValues[k]);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
const updatedData = {
|
|
76
|
-
...data,
|
|
77
|
-
...otherValues,
|
|
78
|
-
};
|
|
79
|
-
setData(updatedData);
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
const changeLinking = ({ key, linkingKey, value }) => {
|
|
84
|
-
console.log('EditStakeholder - changeLinking:', { key, linkingKey, value });
|
|
85
|
-
|
|
86
|
-
const updatedLinking = {
|
|
87
|
-
...linkingForms,
|
|
88
|
-
[key]: {
|
|
89
|
-
...(linkingForms[key] || {}),
|
|
90
|
-
[linkingKey]: value,
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
setLinkingForms(updatedLinking);
|
|
95
|
-
|
|
96
|
-
const updatedData = {
|
|
97
|
-
...data,
|
|
98
|
-
linking: {
|
|
99
|
-
...(data?.linking || {}),
|
|
100
|
-
[key]: {
|
|
101
|
-
...((data?.linking || {})[key] || {}),
|
|
102
|
-
[linkingKey]: value,
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
setData(updatedData);
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
const changeErrors = (newErrors) => {
|
|
111
|
-
console.log('EditStakeholder - changeErrors:', newErrors);
|
|
112
|
-
setErrors(newErrors);
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
const changeAjaxForms = (newAjaxForms) => {
|
|
116
|
-
console.log('EditStakeholder - changeAjaxForms:', newAjaxForms);
|
|
117
|
-
setAjaxForms(newAjaxForms);
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
const changeAjaxOptions = (newAjaxOptions) => {
|
|
121
|
-
console.log('EditStakeholder - changeAjaxOptions:', newAjaxOptions);
|
|
122
|
-
setAjaxOptions(newAjaxOptions);
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
if (!editFormConfig) {
|
|
126
|
-
return null;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
const definition = (
|
|
130
|
-
<>
|
|
131
|
-
<div className="group">
|
|
132
|
-
<div className="daf-title with-subtitle">
|
|
133
|
-
<h1>{t(conf.title)}</h1>
|
|
134
|
-
{conf.description && (
|
|
135
|
-
<p style={{
|
|
136
|
-
color: '#8c8c8c',
|
|
137
|
-
fontSize: '14px',
|
|
138
|
-
marginTop: '8px',
|
|
139
|
-
marginBottom: '0',
|
|
140
|
-
lineHeight: '1.5'
|
|
141
|
-
}}>
|
|
142
|
-
{t(conf.description)}
|
|
143
|
-
</p>
|
|
144
|
-
)}
|
|
145
|
-
</div>
|
|
146
|
-
</div>
|
|
147
|
-
</>
|
|
148
|
-
);
|
|
149
|
-
|
|
150
|
-
return (
|
|
151
|
-
<div className="form-edit flex-row">
|
|
152
|
-
<EditForm
|
|
153
|
-
form={editFormConfig}
|
|
154
|
-
data={data}
|
|
155
|
-
allData={data}
|
|
156
|
-
MainForm={MainForm}
|
|
157
|
-
onValuesChange={onValuesChange}
|
|
158
|
-
t={t}
|
|
159
|
-
definition={definition}
|
|
160
|
-
plainForms={{}}
|
|
161
|
-
linkingForms={linkingForms}
|
|
162
|
-
inputsMeta={inputsMeta}
|
|
163
|
-
changeInputMeta={changeInputMeta}
|
|
164
|
-
changeLinking={changeLinking}
|
|
165
|
-
errors={errors}
|
|
166
|
-
changeErrors={changeErrors}
|
|
167
|
-
staticWidth="614px"
|
|
168
|
-
fullWidth={false}
|
|
169
|
-
noConvert={false}
|
|
170
|
-
getApiBaseUrl={getApiBaseUrl}
|
|
171
|
-
getAppHeader={getAppHeader}
|
|
172
|
-
getMainApiUrl={getMainApiUrl}
|
|
173
|
-
user={user}
|
|
174
|
-
ajaxForms={ajaxForms}
|
|
175
|
-
ajaxOptions={ajaxOptions}
|
|
176
|
-
changeAjaxForms={changeAjaxForms}
|
|
177
|
-
changeAjaxOptions={changeAjaxOptions}
|
|
178
|
-
app={app}
|
|
179
|
-
query={query}
|
|
180
|
-
goTo={goTo}
|
|
181
|
-
/>
|
|
182
|
-
</div>
|
|
183
|
-
);
|
|
184
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
export const config = [
|
|
2
|
-
{
|
|
3
|
-
label: "Core Data",
|
|
4
|
-
key: "core-data",
|
|
5
|
-
title: "Core Data",
|
|
6
|
-
description: "this-data-is-used-to-identify-the-location.Changing-it-will-affect-the-subject-itself,any-forms-where-it-appears-and-any-related-or-linked-subjects.",
|
|
7
|
-
items: [
|
|
8
|
-
{
|
|
9
|
-
label: "Name",
|
|
10
|
-
key: "name",
|
|
11
|
-
type: "text",
|
|
12
|
-
placeholder: "Enter location name",
|
|
13
|
-
rules: [
|
|
14
|
-
{ required: true, message: "errors::Name is required" }
|
|
15
|
-
]
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
label: "Category",
|
|
19
|
-
key: "category",
|
|
20
|
-
type: "select",
|
|
21
|
-
optionsName: "categories",
|
|
22
|
-
placeholder: "Select a category",
|
|
23
|
-
rules: [
|
|
24
|
-
{ required: true, message: "errors::Category is required" }
|
|
25
|
-
]
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
label: "Country",
|
|
29
|
-
key: "country",
|
|
30
|
-
type: "select",
|
|
31
|
-
optionsName: "countries",
|
|
32
|
-
placeholder: "Select a country",
|
|
33
|
-
rules: [
|
|
34
|
-
{ required: true, message: "errors::Country is required" }
|
|
35
|
-
]
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
label: "Administrative Level 1",
|
|
39
|
-
key: "administrativeLevel1",
|
|
40
|
-
type: "ajaxSelect",
|
|
41
|
-
entity: "AdministrativeLevel",
|
|
42
|
-
method: "getOptions",
|
|
43
|
-
optionsName: "level_1",
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
label: "Administrative Level 2",
|
|
53
|
-
key: "administrativeLevel2",
|
|
54
|
-
type: "ajaxSelect",
|
|
55
|
-
entity: "AdministrativeLevel",
|
|
56
|
-
method: "getOptions",
|
|
57
|
-
optionsName: "level_2",
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
},
|
|
62
|
-
],
|
|
63
|
-
},
|
|
64
|
-
];
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { getAdminLevelName } from "../../../../../../../helpers/adminLevels.js";
|
|
2
|
-
|
|
3
|
-
export const getAdministrativeLevel1 = (location) => {
|
|
4
|
-
return getAdminLevelName(location?.linking?.SCL, "level_1");
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
export const getAdministrativeLevel2 = (location) => {
|
|
8
|
-
return getAdminLevelName(location?.linking?.SCL, "level_2");
|
|
9
|
-
};
|
|
10
|
-
|