@visns-studio/visns-components 4.7.7 → 4.7.9
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/package.json
CHANGED
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"react-dom": "^17.0.0 || ^18.0.0"
|
|
76
76
|
},
|
|
77
77
|
"name": "@visns-studio/visns-components",
|
|
78
|
-
"version": "4.7.
|
|
78
|
+
"version": "4.7.9",
|
|
79
79
|
"description": "Various packages to assist in the development of our Custom Applications.",
|
|
80
80
|
"main": "src/index.js",
|
|
81
81
|
"files": [
|
|
@@ -25,6 +25,7 @@ import VisnsDropZone from '../cms/DropZone';
|
|
|
25
25
|
|
|
26
26
|
import 'react-toggle/style.css';
|
|
27
27
|
import 'react-datepicker/dist/react-datepicker.css';
|
|
28
|
+
import Item from '../cms/sorting/Item';
|
|
28
29
|
|
|
29
30
|
function Field({
|
|
30
31
|
api,
|
|
@@ -32,6 +33,7 @@ function Field({
|
|
|
32
33
|
childDropdownCallback,
|
|
33
34
|
fetchData,
|
|
34
35
|
formData,
|
|
36
|
+
formSettings,
|
|
35
37
|
inputValue,
|
|
36
38
|
inputClass,
|
|
37
39
|
mapbox,
|
|
@@ -153,83 +155,71 @@ function Field({
|
|
|
153
155
|
}
|
|
154
156
|
}, [settings, counter]);
|
|
155
157
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
let filter = {};
|
|
159
|
-
|
|
160
|
-
if (settings.child && inputValue) {
|
|
161
|
-
let _inputValue = inputValue.value
|
|
162
|
-
? inputValue.value
|
|
163
|
-
: inputValue;
|
|
164
|
-
|
|
165
|
-
if (_inputValue > 0) {
|
|
166
|
-
if (Array.isArray(settings.child)) {
|
|
167
|
-
settings.child.forEach((a) => {
|
|
168
|
-
filter = {
|
|
169
|
-
where: [
|
|
170
|
-
{
|
|
171
|
-
id: settings.id,
|
|
172
|
-
value: _inputValue,
|
|
173
|
-
},
|
|
174
|
-
],
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
if (a.fields) {
|
|
178
|
-
filter.fields = a.fields;
|
|
179
|
-
}
|
|
158
|
+
const fetchChildDropdownData = (s, v) => {
|
|
159
|
+
let filter = {};
|
|
180
160
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}
|
|
161
|
+
if (s.child && v) {
|
|
162
|
+
let _inputValue = v.value ? v.value : v;
|
|
184
163
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
filter,
|
|
189
|
-
function (result) {
|
|
190
|
-
childDropdownCallback({
|
|
191
|
-
id: a.id,
|
|
192
|
-
data: result.data,
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
);
|
|
196
|
-
});
|
|
197
|
-
} else {
|
|
164
|
+
if (_inputValue > 0) {
|
|
165
|
+
if (Array.isArray(s.child)) {
|
|
166
|
+
s.child.forEach((a) => {
|
|
198
167
|
filter = {
|
|
199
168
|
where: [
|
|
200
169
|
{
|
|
201
|
-
id:
|
|
170
|
+
id: s.id,
|
|
202
171
|
value: _inputValue,
|
|
203
172
|
},
|
|
204
173
|
],
|
|
205
174
|
};
|
|
206
175
|
|
|
207
|
-
if (
|
|
208
|
-
filter.fields =
|
|
176
|
+
if (a.fields) {
|
|
177
|
+
filter.fields = a.fields;
|
|
209
178
|
}
|
|
210
179
|
|
|
211
|
-
if (
|
|
212
|
-
filter.orderBy =
|
|
180
|
+
if (a.orderBy) {
|
|
181
|
+
filter.orderBy = a.orderBy;
|
|
213
182
|
}
|
|
214
183
|
|
|
215
|
-
CustomFetch(
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
184
|
+
CustomFetch(a.url, 'POST', filter, function (result) {
|
|
185
|
+
childDropdownCallback({
|
|
186
|
+
id: a.id,
|
|
187
|
+
data: result.data,
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
} else {
|
|
192
|
+
filter = {
|
|
193
|
+
where: [
|
|
194
|
+
{
|
|
195
|
+
id: s.id,
|
|
196
|
+
value: _inputValue,
|
|
197
|
+
},
|
|
198
|
+
],
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
if (s.fields) {
|
|
202
|
+
filter.fields = s.fields;
|
|
226
203
|
}
|
|
204
|
+
|
|
205
|
+
if (s.orderBy) {
|
|
206
|
+
filter.orderBy = s.orderBy;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
CustomFetch(s.child.url, 'POST', filter, function (result) {
|
|
210
|
+
childDropdownCallback({
|
|
211
|
+
id: s.child.id,
|
|
212
|
+
data: result.data,
|
|
213
|
+
});
|
|
214
|
+
});
|
|
227
215
|
}
|
|
228
216
|
}
|
|
229
|
-
}
|
|
217
|
+
}
|
|
218
|
+
};
|
|
230
219
|
|
|
231
|
-
|
|
232
|
-
|
|
220
|
+
useEffect(() => {
|
|
221
|
+
fetchChildDropdownData(settings, inputValue);
|
|
222
|
+
}, [inputValue, settings]);
|
|
233
223
|
|
|
234
224
|
useEffect(() => {
|
|
235
225
|
const processOptions = () => {
|
|
@@ -259,7 +249,7 @@ function Field({
|
|
|
259
249
|
};
|
|
260
250
|
|
|
261
251
|
processOptions();
|
|
262
|
-
}, [settings.options, settings]);
|
|
252
|
+
}, [settings.options, settings, counter]);
|
|
263
253
|
|
|
264
254
|
const renderLabel = () => {
|
|
265
255
|
if (
|
|
@@ -1582,13 +1572,29 @@ function Field({
|
|
|
1582
1572
|
|
|
1583
1573
|
const handleAddEntry = (form) => {
|
|
1584
1574
|
if (form) {
|
|
1585
|
-
let f = form;
|
|
1575
|
+
let f = { ...form }; // Create a copy of the form object to avoid direct mutation
|
|
1586
1576
|
|
|
1587
1577
|
form.fields.forEach((item, itemKey) => {
|
|
1588
|
-
if (item.hasOwnProperty('dataId')
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1578
|
+
if (item.hasOwnProperty('dataId')) {
|
|
1579
|
+
let value;
|
|
1580
|
+
|
|
1581
|
+
if (Array.isArray(item.dataId)) {
|
|
1582
|
+
// If dataId is an array, nest the keys to access formData
|
|
1583
|
+
value = item.dataId.reduce((acc, key) => {
|
|
1584
|
+
return acc && acc[key] ? acc[key] : undefined;
|
|
1585
|
+
}, formData);
|
|
1586
|
+
} else {
|
|
1587
|
+
// If dataId is not an array, access formData directly
|
|
1588
|
+
value = formData[item.dataId]
|
|
1589
|
+
? formData[item.dataId].value ||
|
|
1590
|
+
formData[item.dataId]
|
|
1591
|
+
: undefined;
|
|
1592
|
+
}
|
|
1593
|
+
|
|
1594
|
+
// Set the value if it exists
|
|
1595
|
+
if (value !== undefined) {
|
|
1596
|
+
f.fields[itemKey].value = value;
|
|
1597
|
+
}
|
|
1592
1598
|
}
|
|
1593
1599
|
});
|
|
1594
1600
|
|
|
@@ -1601,6 +1607,21 @@ function Field({
|
|
|
1601
1607
|
setCounter(counter + 1);
|
|
1602
1608
|
};
|
|
1603
1609
|
|
|
1610
|
+
useEffect(() => {
|
|
1611
|
+
if (counter > 0) {
|
|
1612
|
+
if (settings.create.parent_id !== '') {
|
|
1613
|
+
formSettings.fields.forEach((item) => {
|
|
1614
|
+
if (item.id === settings.create.parent_id) {
|
|
1615
|
+
fetchChildDropdownData(
|
|
1616
|
+
item,
|
|
1617
|
+
formData[settings.create.parent_id]
|
|
1618
|
+
);
|
|
1619
|
+
}
|
|
1620
|
+
});
|
|
1621
|
+
}
|
|
1622
|
+
}
|
|
1623
|
+
}, [counter]);
|
|
1624
|
+
|
|
1604
1625
|
return (
|
|
1605
1626
|
<div className={formItemClass} style={formItemStyle}>
|
|
1606
1627
|
<label className={styles.fi__label}>
|
|
@@ -693,8 +693,6 @@ function Form({
|
|
|
693
693
|
return acc;
|
|
694
694
|
}, {});
|
|
695
695
|
|
|
696
|
-
console.info(payload);
|
|
697
|
-
|
|
698
696
|
const res = await CustomFetch(url, method, payload);
|
|
699
697
|
|
|
700
698
|
if (res.data.error === '') {
|
|
@@ -1158,6 +1156,7 @@ function Form({
|
|
|
1158
1156
|
}
|
|
1159
1157
|
fetchData={fetchData}
|
|
1160
1158
|
formData={formData}
|
|
1159
|
+
formSettings={formSettings}
|
|
1161
1160
|
inputClass={inputClass}
|
|
1162
1161
|
inputValue={renderInputValue(
|
|
1163
1162
|
item,
|
|
@@ -1302,6 +1301,7 @@ function Form({
|
|
|
1302
1301
|
}
|
|
1303
1302
|
fetchData={fetchData}
|
|
1304
1303
|
formData={formData}
|
|
1304
|
+
formSettings={formSettings}
|
|
1305
1305
|
inputClass={inputClass}
|
|
1306
1306
|
inputValue={renderInputValue(
|
|
1307
1307
|
item,
|