@visns-studio/visns-components 5.0.21 → 5.0.23
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
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"react-dom": "^17.0.0 || ^18.0.0"
|
|
78
78
|
},
|
|
79
79
|
"name": "@visns-studio/visns-components",
|
|
80
|
-
"version": "5.0.
|
|
80
|
+
"version": "5.0.23",
|
|
81
81
|
"description": "Various packages to assist in the development of our Custom Applications.",
|
|
82
82
|
"main": "src/index.js",
|
|
83
83
|
"files": [
|
|
@@ -31,15 +31,18 @@ import { toast } from 'react-toastify';
|
|
|
31
31
|
import {
|
|
32
32
|
Alarm,
|
|
33
33
|
ArrowCounterClockwise,
|
|
34
|
+
ArrowCycle,
|
|
34
35
|
Backspace,
|
|
35
36
|
Check,
|
|
36
37
|
CircleCheck,
|
|
37
38
|
CircleX,
|
|
38
39
|
Clock,
|
|
39
40
|
CloudDownload,
|
|
41
|
+
CloudUpload,
|
|
40
42
|
Copy,
|
|
41
43
|
Edit,
|
|
42
44
|
Envelope,
|
|
45
|
+
File,
|
|
43
46
|
Folder,
|
|
44
47
|
Image,
|
|
45
48
|
Inbox,
|
|
@@ -82,25 +85,32 @@ const loadData = async (
|
|
|
82
85
|
|
|
83
86
|
if (filterValue) {
|
|
84
87
|
filterValue.forEach((fv) => {
|
|
85
|
-
const identifier = fv.
|
|
88
|
+
const identifier = fv.whereHas?.column || fv.key || fv.name;
|
|
86
89
|
const existingIndex = params.where.findIndex(
|
|
87
90
|
(w) => w.id === identifier
|
|
88
91
|
);
|
|
89
92
|
|
|
90
|
-
if (
|
|
93
|
+
if (
|
|
94
|
+
fv.value !== undefined &&
|
|
95
|
+
fv.value !== null &&
|
|
96
|
+
fv.value !== ''
|
|
97
|
+
) {
|
|
98
|
+
const tempParamsObject = {
|
|
99
|
+
id: identifier,
|
|
100
|
+
value: fv.value,
|
|
101
|
+
operator: fv.operator,
|
|
102
|
+
...(fv.whereHas?.relation && {
|
|
103
|
+
whereHas: fv.whereHas.relation,
|
|
104
|
+
}),
|
|
105
|
+
};
|
|
106
|
+
|
|
91
107
|
if (existingIndex !== -1) {
|
|
92
|
-
params.where[existingIndex]
|
|
108
|
+
params.where[existingIndex] = tempParamsObject;
|
|
93
109
|
} else {
|
|
94
|
-
params.where.push(
|
|
95
|
-
id: identifier,
|
|
96
|
-
value: fv.value,
|
|
97
|
-
operator: fv.operator,
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
} else {
|
|
101
|
-
if (existingIndex !== -1) {
|
|
102
|
-
params.where.splice(existingIndex, 1);
|
|
110
|
+
params.where.push(tempParamsObject);
|
|
103
111
|
}
|
|
112
|
+
} else if (existingIndex !== -1) {
|
|
113
|
+
params.where.splice(existingIndex, 1);
|
|
104
114
|
}
|
|
105
115
|
});
|
|
106
116
|
}
|
|
@@ -376,6 +386,11 @@ const DataGrid = forwardRef(
|
|
|
376
386
|
const handleSettingClick = (s, d) => {
|
|
377
387
|
switch (s.id) {
|
|
378
388
|
case 'activate':
|
|
389
|
+
case 'arrowCycle':
|
|
390
|
+
case 'cloudUpload':
|
|
391
|
+
case 'envelope':
|
|
392
|
+
case 'file':
|
|
393
|
+
case 'image':
|
|
379
394
|
CustomFetch(s.url, 'POST', { id: d[s.key] }, (result) => {
|
|
380
395
|
toast.success(result.message);
|
|
381
396
|
});
|
|
@@ -500,11 +515,6 @@ const DataGrid = forwardRef(
|
|
|
500
515
|
],
|
|
501
516
|
});
|
|
502
517
|
break;
|
|
503
|
-
case 'envelope':
|
|
504
|
-
CustomFetch(s.url, 'POST', { id: d[s.key] }, (result) => {
|
|
505
|
-
toast.success(result.message);
|
|
506
|
-
});
|
|
507
|
-
break;
|
|
508
518
|
case 'gallery':
|
|
509
519
|
// Function to access nested property using a series of keys
|
|
510
520
|
const getNestedValue = (data, keys) =>
|
|
@@ -1100,6 +1110,10 @@ const DataGrid = forwardRef(
|
|
|
1100
1110
|
return getIconComponent(CircleCheck);
|
|
1101
1111
|
case 'archive':
|
|
1102
1112
|
return getIconComponent(ShippingBoxV1);
|
|
1113
|
+
case 'arrowCycle':
|
|
1114
|
+
return getIconComponent(ArrowCycle);
|
|
1115
|
+
case 'cloudUpload':
|
|
1116
|
+
return getIconComponent(CloudUpload);
|
|
1103
1117
|
case 'oauth2':
|
|
1104
1118
|
return getIconComponent(LockOn);
|
|
1105
1119
|
case 'clone':
|
|
@@ -1114,8 +1128,12 @@ const DataGrid = forwardRef(
|
|
|
1114
1128
|
return getIconComponent(Envelope);
|
|
1115
1129
|
case 'family':
|
|
1116
1130
|
return getIconComponent(Network);
|
|
1131
|
+
case 'file':
|
|
1132
|
+
return getIconComponent(File);
|
|
1117
1133
|
case 'gallery':
|
|
1118
1134
|
return getIconComponent(Image);
|
|
1135
|
+
case 'image':
|
|
1136
|
+
return getIconComponent(Image);
|
|
1119
1137
|
case 'link':
|
|
1120
1138
|
return getIconComponent(LinkOut);
|
|
1121
1139
|
case 'primary':
|
|
@@ -2487,6 +2505,7 @@ const DataGrid = forwardRef(
|
|
|
2487
2505
|
operator: column.filter.operator,
|
|
2488
2506
|
type: column.filter.type,
|
|
2489
2507
|
value: filterValue,
|
|
2508
|
+
whereHas: column.filter.whereHas || {},
|
|
2490
2509
|
reset: column.filter.reset
|
|
2491
2510
|
? column.filter.reset
|
|
2492
2511
|
: [],
|
|
@@ -166,29 +166,36 @@ function Field({
|
|
|
166
166
|
if (_inputValue > 0) {
|
|
167
167
|
if (Array.isArray(s.child)) {
|
|
168
168
|
s.child.forEach((a) => {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
169
|
+
if (a) {
|
|
170
|
+
filter = {
|
|
171
|
+
where: [
|
|
172
|
+
{
|
|
173
|
+
id: s.id,
|
|
174
|
+
value: _inputValue,
|
|
175
|
+
},
|
|
176
|
+
],
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
if (a.fields) {
|
|
180
|
+
filter.fields = a.fields;
|
|
181
|
+
}
|
|
177
182
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
183
|
+
if (a.orderBy) {
|
|
184
|
+
filter.orderBy = a.orderBy;
|
|
185
|
+
}
|
|
181
186
|
|
|
182
|
-
|
|
183
|
-
|
|
187
|
+
CustomFetch(
|
|
188
|
+
a.url,
|
|
189
|
+
'POST',
|
|
190
|
+
filter,
|
|
191
|
+
function (result) {
|
|
192
|
+
childDropdownCallback({
|
|
193
|
+
id: a.id,
|
|
194
|
+
data: result.data,
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
);
|
|
184
198
|
}
|
|
185
|
-
|
|
186
|
-
CustomFetch(a.url, 'POST', filter, function (result) {
|
|
187
|
-
childDropdownCallback({
|
|
188
|
-
id: a.id,
|
|
189
|
-
data: result.data,
|
|
190
|
-
});
|
|
191
|
-
});
|
|
192
199
|
});
|
|
193
200
|
} else {
|
|
194
201
|
filter = {
|
|
@@ -208,8 +215,8 @@ function Field({
|
|
|
208
215
|
filter.orderBy = s.orderBy;
|
|
209
216
|
}
|
|
210
217
|
|
|
211
|
-
if (
|
|
212
|
-
forEach(
|
|
218
|
+
if (s.where) {
|
|
219
|
+
forEach(s.where, (w) => {
|
|
213
220
|
filter.where.push(w);
|
|
214
221
|
});
|
|
215
222
|
}
|
|
@@ -22,13 +22,27 @@ function MultiSelect({
|
|
|
22
22
|
const prevInputValueRef = useRef();
|
|
23
23
|
|
|
24
24
|
useEffect(() => {
|
|
25
|
-
const _options =
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
const _options =
|
|
26
|
+
Array.isArray(options) && options.length > 0
|
|
27
|
+
? options.map((a) => {
|
|
28
|
+
if (a && typeof a === 'object') {
|
|
29
|
+
return {
|
|
30
|
+
value: a.id || 'unknown-id',
|
|
31
|
+
label:
|
|
32
|
+
a.label ||
|
|
33
|
+
a.name ||
|
|
34
|
+
a.description ||
|
|
35
|
+
'Unknown',
|
|
36
|
+
...a,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
console.warn('Invalid item in options array:', a);
|
|
40
|
+
return {
|
|
41
|
+
value: 'unknown-id',
|
|
42
|
+
label: 'Unknown',
|
|
43
|
+
};
|
|
44
|
+
})
|
|
45
|
+
: [];
|
|
32
46
|
setSelectOptions(_options);
|
|
33
47
|
}, [options]);
|
|
34
48
|
|
|
@@ -57,7 +71,6 @@ function MultiSelect({
|
|
|
57
71
|
},
|
|
58
72
|
]
|
|
59
73
|
: [];
|
|
60
|
-
|
|
61
74
|
setSelectValue(_values);
|
|
62
75
|
prevInputValueRef.current = inputValue;
|
|
63
76
|
}
|