@visns-studio/visns-components 2.9.4 → 2.9.6
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.
|
@@ -60,7 +60,7 @@ function VisnsDropZone({ fetchData, files, settings }) {
|
|
|
60
60
|
},
|
|
61
61
|
function (result) {
|
|
62
62
|
if (result.error === '') {
|
|
63
|
-
if (fetchData) {
|
|
63
|
+
if (typeof fetchData === 'function') {
|
|
64
64
|
fetchData();
|
|
65
65
|
|
|
66
66
|
toast.success(
|
|
@@ -82,7 +82,7 @@ function VisnsDropZone({ fetchData, files, settings }) {
|
|
|
82
82
|
|
|
83
83
|
const handleDownload = (id) => {
|
|
84
84
|
if (id && id > 0 && settings.model && settings.model !== '') {
|
|
85
|
-
window.open(`/ajax/
|
|
85
|
+
window.open(`/ajax/files/download/${id}/${settings.model}`);
|
|
86
86
|
} else {
|
|
87
87
|
toast.warning('Issue with downloading the selected file.');
|
|
88
88
|
}
|
|
@@ -108,6 +108,7 @@ function VisnsDropZone({ fetchData, files, settings }) {
|
|
|
108
108
|
setModalData((prevState) => ({
|
|
109
109
|
...prevState,
|
|
110
110
|
id: res.data.id,
|
|
111
|
+
file_name: res.data.file_name,
|
|
111
112
|
title: res.data.file_title,
|
|
112
113
|
description: res.data.file_description,
|
|
113
114
|
}));
|
|
@@ -119,7 +120,6 @@ function VisnsDropZone({ fetchData, files, settings }) {
|
|
|
119
120
|
};
|
|
120
121
|
|
|
121
122
|
const handleDelete = (id, name) => {
|
|
122
|
-
console.info(id, name);
|
|
123
123
|
if (id && id > 0) {
|
|
124
124
|
confirmAlert({
|
|
125
125
|
title: 'Confirm to Delete File',
|
|
@@ -129,14 +129,14 @@ function VisnsDropZone({ fetchData, files, settings }) {
|
|
|
129
129
|
label: 'Yes',
|
|
130
130
|
onClick: () => {
|
|
131
131
|
CustomFetch(
|
|
132
|
-
`/ajax/
|
|
132
|
+
`/ajax/files/delete`,
|
|
133
133
|
'POST',
|
|
134
134
|
{
|
|
135
135
|
file_id: id,
|
|
136
136
|
},
|
|
137
137
|
function (result) {
|
|
138
138
|
if (result.error === '') {
|
|
139
|
-
if (fetchData) {
|
|
139
|
+
if (typeof fetchData === 'function') {
|
|
140
140
|
fetchData();
|
|
141
141
|
}
|
|
142
142
|
}
|
|
@@ -165,6 +165,7 @@ function VisnsDropZone({ fetchData, files, settings }) {
|
|
|
165
165
|
`/ajax/files/${modalData.id}`,
|
|
166
166
|
'PUT',
|
|
167
167
|
{
|
|
168
|
+
file_name: modalData.file_name,
|
|
168
169
|
file_title: modalData.title,
|
|
169
170
|
file_description: modalData.description,
|
|
170
171
|
}
|
|
@@ -173,6 +174,10 @@ function VisnsDropZone({ fetchData, files, settings }) {
|
|
|
173
174
|
if (res.data.error === '') {
|
|
174
175
|
toast.success('File metadata has been successfully updated.');
|
|
175
176
|
modalClose();
|
|
177
|
+
|
|
178
|
+
if (typeof fetchData === 'function') {
|
|
179
|
+
fetchData();
|
|
180
|
+
}
|
|
176
181
|
} else {
|
|
177
182
|
toast.error(res.data.error);
|
|
178
183
|
}
|
|
@@ -184,7 +189,7 @@ function VisnsDropZone({ fetchData, files, settings }) {
|
|
|
184
189
|
useEffect(() => {
|
|
185
190
|
if (data.length > 0) {
|
|
186
191
|
CustomFetch(
|
|
187
|
-
'/ajax/
|
|
192
|
+
'/ajax/files/sort_update',
|
|
188
193
|
'POST',
|
|
189
194
|
{
|
|
190
195
|
list: data,
|
|
@@ -199,6 +204,10 @@ function VisnsDropZone({ fetchData, files, settings }) {
|
|
|
199
204
|
}
|
|
200
205
|
}, [data]);
|
|
201
206
|
|
|
207
|
+
useEffect(() => {
|
|
208
|
+
setData(files);
|
|
209
|
+
}, [files]);
|
|
210
|
+
|
|
202
211
|
return (
|
|
203
212
|
<>
|
|
204
213
|
{settings.type === 'gallery' ? (
|
package/components/cms/Field.jsx
CHANGED
|
@@ -13,6 +13,35 @@ const SortableItem = ({
|
|
|
13
13
|
handleDelete,
|
|
14
14
|
value,
|
|
15
15
|
}) => {
|
|
16
|
+
const renderImage = (d) => {
|
|
17
|
+
let htmlContainer = '';
|
|
18
|
+
if (d.hasOwnProperty('image_url') && d.image_url !== '') {
|
|
19
|
+
htmlContainer = (
|
|
20
|
+
<div className="sortimg">
|
|
21
|
+
<img src={d.image_url} />
|
|
22
|
+
</div>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (d.hasOwnProperty('file_url') && d.file_url !== '') {
|
|
27
|
+
htmlContainer = (
|
|
28
|
+
<div className="sortimg">
|
|
29
|
+
<img src={d.file_url} />
|
|
30
|
+
</div>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (htmlContainer === '') {
|
|
35
|
+
htmlContainer = (
|
|
36
|
+
<div className="sortimg">
|
|
37
|
+
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEsAAABLCAYAAAA4TnrqAAACoUlEQVR4Xu3cO47CMBAAUNMhGiQ6qDkv5+Ac1BwBUUKHRIOgYteg7AaS+Ds/O0OFSPyZp/FEQZYn+/3+uVgszHQ6NfrpF7jf7+ZyuZjJ8Xh82i/r9drM53P1+hK4Xq/mcDgYm1CT0+n0nM1mrx8U7FOqgbIut9vtjbVcLk37gmaY6Xicz+d/LGuqYO/M6nPoYCnYcML0Yo0ZzLWyBrHGCOYrQU6sMYH5oKyFF2sMYCFQwVg1g4VCRWHVCBYDFY1VE1gsVBJWDWApUMlYJYOlQmVhlQiWA5WNVRJYLhQIVglgEFBgWJLBoKBAsSSCQUKBY0kCg4ZCwZIAhgGFhsUJhgWFisUBhgmFjkUJhg1FgkUBRgFFhoUJRgVFioUBRglFjgUJRg3FggUBxgHFhpUDxgXFipUCxgnFjhUDxg0lAisETAKUGCwXmBQoUVh9YJKgxGG1wezmOru3QNJOxKC9DjYIys/vTsQXlAVbrVaUQzvHEofVLD3NLE+OfNcorVkDYEMwksBELEMfiO86VVFjxwqFCL0PE44VKxYg9n5oODas1MBT20HAsWDlBpzbPhWOHAsqUKh+YuBIsaADhO7PB0eGhRUYVr99cCRY2AFh99/AoWNRBUIxDioWRQDt5YI9HhoW9sSHijHmuChYmBP2PbFC/tMP6YOkwHNDNUFizAM0szAmmJoFGBkGhiUNCiPDQLCkQkGDZWNJh4IEy8IqBQoKLBmrNCgIsCSsUqFywaKxSofKAYvCqgUqFSwYqzaoFLAgrFqhYsG8WLVDxYDpWTStl09fYgxi+RrmvOBKbuuKuxdrrFC+JdnBGjuUC+wDS6E+C8S3xx+WnibZraTb7dY8Hg+z2+3MZrN5nyap55S6HzlNhr3OKdUTcP3P5+YE3B/mgEymnzCGDgAAAABJRU5ErkJggg==" />
|
|
38
|
+
</div>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return htmlContainer;
|
|
43
|
+
};
|
|
44
|
+
|
|
16
45
|
return (
|
|
17
46
|
<li
|
|
18
47
|
onClick={(e) => {
|
|
@@ -24,19 +53,13 @@ const SortableItem = ({
|
|
|
24
53
|
}}
|
|
25
54
|
>
|
|
26
55
|
<DragHandle />
|
|
27
|
-
{value.label
|
|
56
|
+
{value.label
|
|
57
|
+
? value.label
|
|
58
|
+
: value.file_title
|
|
59
|
+
? value.file_title
|
|
60
|
+
: value.file_name}
|
|
28
61
|
|
|
29
|
-
{value
|
|
30
|
-
<div className="sortimg">
|
|
31
|
-
<img src={value.image_url} />
|
|
32
|
-
</div>
|
|
33
|
-
) : null}
|
|
34
|
-
|
|
35
|
-
{value.hasOwnProperty('file_url') && value.file_url !== '' ? (
|
|
36
|
-
<div className="sortimg">
|
|
37
|
-
<img src={value.file_url} />
|
|
38
|
-
</div>
|
|
39
|
-
) : null}
|
|
62
|
+
{renderImage(value)}
|
|
40
63
|
|
|
41
64
|
{handleEdit &&
|
|
42
65
|
value.hasOwnProperty('file_title') &&
|
package/components/crm/Field.jsx
CHANGED
|
@@ -10,10 +10,11 @@ import { NumericFormat, PatternFormat } from 'react-number-format';
|
|
|
10
10
|
import { Copy } from 'akar-icons';
|
|
11
11
|
|
|
12
12
|
import CustomFetch from './Fetch';
|
|
13
|
+
import MultiSelect from './MultiSelect';
|
|
13
14
|
import Select from './Select';
|
|
14
15
|
import VisnsAsyncSelect from './AsyncSelect';
|
|
15
|
-
import MultiSelect from './MultiSelect';
|
|
16
16
|
import VisnsAutocomplete from './Autocomplete';
|
|
17
|
+
import VisnsDropZone from '../cms/DropZone';
|
|
17
18
|
|
|
18
19
|
import 'react-toggle/style.css';
|
|
19
20
|
import 'react-quill/dist/quill.snow.css';
|
|
@@ -22,6 +23,8 @@ import 'react-datepicker/dist/react-datepicker.css';
|
|
|
22
23
|
function Field({
|
|
23
24
|
autocompleteCallback,
|
|
24
25
|
childDropdownCallback,
|
|
26
|
+
fetchData,
|
|
27
|
+
formData,
|
|
25
28
|
inputValue,
|
|
26
29
|
inputClass,
|
|
27
30
|
mapbox,
|
|
@@ -219,6 +222,7 @@ function Field({
|
|
|
219
222
|
'copytoclipboard',
|
|
220
223
|
'date',
|
|
221
224
|
'datetime',
|
|
225
|
+
'gallery',
|
|
222
226
|
'multi-dropdown',
|
|
223
227
|
'multi-dropdown-ajax',
|
|
224
228
|
'plaindate',
|
|
@@ -665,6 +669,29 @@ function Field({
|
|
|
665
669
|
onChange={onChange}
|
|
666
670
|
/>
|
|
667
671
|
);
|
|
672
|
+
case 'gallery':
|
|
673
|
+
let htmlContainer = '';
|
|
674
|
+
|
|
675
|
+
if (formData[settings.key] && formData[settings.key] > 0) {
|
|
676
|
+
const dropzoneUrl = `${settings.url}/${
|
|
677
|
+
formData[settings.key]
|
|
678
|
+
}`;
|
|
679
|
+
|
|
680
|
+
htmlContainer = (
|
|
681
|
+
<VisnsDropZone
|
|
682
|
+
fetchData={fetchData}
|
|
683
|
+
files={formData[settings.id]}
|
|
684
|
+
settings={{
|
|
685
|
+
url: dropzoneUrl,
|
|
686
|
+
method: settings.method,
|
|
687
|
+
type: 'gallery',
|
|
688
|
+
data: settings.data,
|
|
689
|
+
}}
|
|
690
|
+
/>
|
|
691
|
+
);
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
return htmlContainer;
|
|
668
695
|
case 'richeditor':
|
|
669
696
|
return (
|
|
670
697
|
<ReactQuill
|
|
@@ -691,6 +718,7 @@ function Field({
|
|
|
691
718
|
'copytoclipboard',
|
|
692
719
|
'date',
|
|
693
720
|
'datetime',
|
|
721
|
+
'gallery',
|
|
694
722
|
'line-break',
|
|
695
723
|
'multi-dropdown',
|
|
696
724
|
'multi-dropdown-ajax',
|
package/components/crm/Form.jsx
CHANGED
|
@@ -555,7 +555,7 @@ function Form({
|
|
|
555
555
|
}
|
|
556
556
|
};
|
|
557
557
|
|
|
558
|
-
|
|
558
|
+
const fetchData = async () => {
|
|
559
559
|
let _formData = { ...formData }; // Create a new object instead of assigning a reference
|
|
560
560
|
|
|
561
561
|
if (formSettings.fields.length > 0) {
|
|
@@ -576,249 +576,237 @@ function Form({
|
|
|
576
576
|
});
|
|
577
577
|
}
|
|
578
578
|
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
: result;
|
|
590
|
-
|
|
591
|
-
const updatedFormData = { ..._formData }; // Create a new object to update properties
|
|
579
|
+
if (formType !== 'create' && columnId > 0) {
|
|
580
|
+
try {
|
|
581
|
+
const result = await CustomFetch(
|
|
582
|
+
`${formSettings.url}/${columnId}`,
|
|
583
|
+
'GET',
|
|
584
|
+
{}
|
|
585
|
+
);
|
|
586
|
+
const data = result.hasOwnProperty('data')
|
|
587
|
+
? result.data
|
|
588
|
+
: result;
|
|
592
589
|
|
|
593
|
-
|
|
594
|
-
let tempRes = '';
|
|
595
|
-
let tempResKey = '';
|
|
596
|
-
let field = formSettings.fields.find(
|
|
597
|
-
(f) => f.id === item
|
|
598
|
-
);
|
|
599
|
-
|
|
600
|
-
if (data[item] === undefined) {
|
|
601
|
-
if (field && field.hasOwnProperty('relation')) {
|
|
602
|
-
let tempRes = data[field.relation];
|
|
590
|
+
const updatedFormData = { ..._formData }; // Create a new object to update properties
|
|
603
591
|
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
'async-dropdown-ajax',
|
|
609
|
-
].includes(field.type) &&
|
|
610
|
-
Array.isArray(tempRes)
|
|
611
|
-
) {
|
|
612
|
-
tempRes = tempRes.map((a) => ({
|
|
613
|
-
value: a.name,
|
|
614
|
-
label: a.name,
|
|
615
|
-
}));
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
if (tempRes) {
|
|
619
|
-
const relationFrom = field.hasOwnProperty(
|
|
620
|
-
'relation_from'
|
|
621
|
-
)
|
|
622
|
-
? field.relation_from
|
|
623
|
-
: field.id;
|
|
624
|
-
tempRes = Array.isArray(tempRes)
|
|
625
|
-
? tempRes[0][relationFrom]
|
|
626
|
-
: tempRes[relationFrom];
|
|
627
|
-
} else {
|
|
628
|
-
tempRes = '';
|
|
629
|
-
}
|
|
592
|
+
Object.keys(updatedFormData).forEach((item) => {
|
|
593
|
+
let tempRes = '';
|
|
594
|
+
let tempResKey = '';
|
|
595
|
+
let field = formSettings.fields.find((f) => f.id === item);
|
|
630
596
|
|
|
631
|
-
|
|
632
|
-
|
|
597
|
+
if (data[item] === undefined) {
|
|
598
|
+
if (field && field.hasOwnProperty('relation')) {
|
|
599
|
+
let tempRes = data[field.relation];
|
|
633
600
|
|
|
634
601
|
if (
|
|
635
|
-
field &&
|
|
636
|
-
field.hasOwnProperty('relation') &&
|
|
637
602
|
[
|
|
638
603
|
'multi-dropdown',
|
|
639
604
|
'multi-dropdown-ajax',
|
|
640
605
|
'async-dropdown-ajax',
|
|
641
|
-
].includes(field.type)
|
|
606
|
+
].includes(field.type) &&
|
|
607
|
+
Array.isArray(tempRes)
|
|
642
608
|
) {
|
|
643
|
-
|
|
644
|
-
|
|
609
|
+
tempRes = tempRes.map((a) => ({
|
|
610
|
+
value: a.name,
|
|
611
|
+
label: a.name,
|
|
612
|
+
}));
|
|
613
|
+
}
|
|
645
614
|
|
|
646
|
-
|
|
647
|
-
|
|
615
|
+
if (tempRes) {
|
|
616
|
+
const relationFrom = field.hasOwnProperty(
|
|
617
|
+
'relation_from'
|
|
648
618
|
)
|
|
649
|
-
? field.
|
|
650
|
-
:
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
619
|
+
? field.relation_from
|
|
620
|
+
: field.id;
|
|
621
|
+
tempRes = Array.isArray(tempRes)
|
|
622
|
+
? tempRes[0][relationFrom]
|
|
623
|
+
: tempRes[relationFrom];
|
|
624
|
+
} else {
|
|
625
|
+
tempRes = '';
|
|
626
|
+
}
|
|
654
627
|
|
|
655
|
-
|
|
656
|
-
|
|
628
|
+
updatedFormData[item] = tempRes;
|
|
629
|
+
}
|
|
657
630
|
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
631
|
+
if (
|
|
632
|
+
field &&
|
|
633
|
+
field.hasOwnProperty('relation') &&
|
|
634
|
+
[
|
|
635
|
+
'multi-dropdown',
|
|
636
|
+
'multi-dropdown-ajax',
|
|
637
|
+
'async-dropdown-ajax',
|
|
638
|
+
].includes(field.type)
|
|
639
|
+
) {
|
|
640
|
+
let tempObj = data;
|
|
641
|
+
let tempRes = {};
|
|
642
|
+
|
|
643
|
+
const relationLength = Array.isArray(field.relation)
|
|
644
|
+
? field.relation.length
|
|
645
|
+
: 1;
|
|
646
|
+
for (let i = 0; i < relationLength; i++) {
|
|
647
|
+
tempObj = tempObj[field.relation[i]];
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
if (tempObj !== undefined && tempObj !== null) {
|
|
651
|
+
let labelValue;
|
|
666
652
|
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
653
|
+
if (Array.isArray(field.relationName)) {
|
|
654
|
+
labelValue = field.relationName.map(
|
|
655
|
+
(name) => `${tempObj[name]} `
|
|
656
|
+
);
|
|
657
|
+
} else {
|
|
658
|
+
labelValue = tempObj[field.relationName];
|
|
671
659
|
}
|
|
672
660
|
|
|
673
|
-
|
|
661
|
+
tempRes = {
|
|
662
|
+
value: tempObj.id,
|
|
663
|
+
label: labelValue,
|
|
664
|
+
};
|
|
674
665
|
}
|
|
675
666
|
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
field.hasOwnProperty('relation') &&
|
|
679
|
-
['address', 'text'].includes(field.type)
|
|
680
|
-
) {
|
|
681
|
-
let tempObj = data;
|
|
682
|
-
let tempRes = '';
|
|
683
|
-
|
|
684
|
-
const relationLength = Array.isArray(
|
|
685
|
-
field.relation
|
|
686
|
-
)
|
|
687
|
-
? field.relation.length
|
|
688
|
-
: 1;
|
|
689
|
-
for (let i = 0; i < relationLength; i++) {
|
|
690
|
-
tempObj = tempObj[field.relation[i]];
|
|
691
|
-
}
|
|
667
|
+
updatedFormData[field.id] = tempRes;
|
|
668
|
+
}
|
|
692
669
|
|
|
693
|
-
|
|
694
|
-
|
|
670
|
+
if (
|
|
671
|
+
field &&
|
|
672
|
+
field.hasOwnProperty('relation') &&
|
|
673
|
+
['address', 'text'].includes(field.type)
|
|
674
|
+
) {
|
|
675
|
+
let tempObj = data;
|
|
676
|
+
let tempRes = '';
|
|
677
|
+
|
|
678
|
+
const relationLength = Array.isArray(field.relation)
|
|
679
|
+
? field.relation.length
|
|
680
|
+
: 1;
|
|
681
|
+
for (let i = 0; i < relationLength; i++) {
|
|
682
|
+
tempObj = tempObj[field.relation[i]];
|
|
683
|
+
}
|
|
695
684
|
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
(name) => `${tempObj[name]} `
|
|
699
|
-
);
|
|
700
|
-
} else {
|
|
701
|
-
labelValue =
|
|
702
|
-
tempObj[field.relationName];
|
|
703
|
-
}
|
|
685
|
+
if (tempObj !== undefined && tempObj !== null) {
|
|
686
|
+
let labelValue;
|
|
704
687
|
|
|
705
|
-
|
|
688
|
+
if (Array.isArray(field.relationName)) {
|
|
689
|
+
labelValue = field.relationName.map(
|
|
690
|
+
(name) => `${tempObj[name]} `
|
|
691
|
+
);
|
|
692
|
+
} else {
|
|
693
|
+
labelValue = tempObj[field.relationName];
|
|
706
694
|
}
|
|
707
695
|
|
|
708
|
-
|
|
696
|
+
tempRes = labelValue;
|
|
709
697
|
}
|
|
710
698
|
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
let keys = item.split('.');
|
|
699
|
+
updatedFormData[field.id] = tempRes;
|
|
700
|
+
}
|
|
714
701
|
|
|
715
|
-
|
|
716
|
-
|
|
702
|
+
if (item.includes('.')) {
|
|
703
|
+
// Split the item string by the dot
|
|
704
|
+
let keys = item.split('.');
|
|
717
705
|
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
}
|
|
706
|
+
// Access the nested property
|
|
707
|
+
let value = data;
|
|
721
708
|
|
|
722
|
-
|
|
723
|
-
|
|
709
|
+
for (let key of keys) {
|
|
710
|
+
value = value[key];
|
|
724
711
|
}
|
|
725
|
-
} else {
|
|
726
|
-
if (
|
|
727
|
-
field &&
|
|
728
|
-
['date', 'datetime', 'time'].includes(
|
|
729
|
-
field.type
|
|
730
|
-
)
|
|
731
|
-
) {
|
|
732
|
-
if (data[item] === null || data[item] === '') {
|
|
733
|
-
updatedFormData[item] = '';
|
|
734
|
-
} else {
|
|
735
|
-
const momentDate = moment(data[item]);
|
|
736
|
-
updatedFormData[item] = momentDate.isValid()
|
|
737
|
-
? momentDate.toDate()
|
|
738
|
-
: null;
|
|
739
|
-
}
|
|
740
|
-
} else if (
|
|
741
|
-
field &&
|
|
742
|
-
field.hasOwnProperty('relation') &&
|
|
743
|
-
!field.multi
|
|
744
|
-
) {
|
|
745
|
-
const relationTypes = [
|
|
746
|
-
'multi-dropdown',
|
|
747
|
-
'multi-dropdown-ajax',
|
|
748
|
-
'async-dropdown-ajax',
|
|
749
|
-
];
|
|
750
712
|
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
713
|
+
// Update the updatedFormData object
|
|
714
|
+
updatedFormData[item] = value;
|
|
715
|
+
}
|
|
716
|
+
} else {
|
|
717
|
+
if (
|
|
718
|
+
field &&
|
|
719
|
+
['date', 'datetime', 'time'].includes(field.type)
|
|
720
|
+
) {
|
|
721
|
+
if (data[item] === null || data[item] === '') {
|
|
722
|
+
updatedFormData[item] = '';
|
|
723
|
+
} else {
|
|
724
|
+
const momentDate = moment(data[item]);
|
|
725
|
+
updatedFormData[item] = momentDate.isValid()
|
|
726
|
+
? momentDate.toDate()
|
|
727
|
+
: null;
|
|
728
|
+
}
|
|
729
|
+
} else if (
|
|
730
|
+
field &&
|
|
731
|
+
field.hasOwnProperty('relation') &&
|
|
732
|
+
!field.multi
|
|
733
|
+
) {
|
|
734
|
+
const relationTypes = [
|
|
735
|
+
'multi-dropdown',
|
|
736
|
+
'multi-dropdown-ajax',
|
|
737
|
+
'async-dropdown-ajax',
|
|
738
|
+
];
|
|
739
|
+
|
|
740
|
+
if (relationTypes.includes(field.type)) {
|
|
741
|
+
let relationLength = Array.isArray(
|
|
742
|
+
field.relation
|
|
743
|
+
)
|
|
744
|
+
? field.relation.length
|
|
745
|
+
: 1;
|
|
746
|
+
let tempObj = data;
|
|
747
|
+
let relationFound = false;
|
|
767
748
|
|
|
768
|
-
|
|
769
|
-
|
|
749
|
+
for (let i = 0; i < relationLength; i++) {
|
|
750
|
+
if (tempObj[field.relation[i]]) {
|
|
751
|
+
relationFound = true;
|
|
752
|
+
tempObj = tempObj[field.relation[i]];
|
|
770
753
|
}
|
|
754
|
+
}
|
|
771
755
|
|
|
772
|
-
|
|
756
|
+
if (relationFound === false) {
|
|
757
|
+
tempObj = {};
|
|
758
|
+
}
|
|
773
759
|
|
|
774
|
-
|
|
775
|
-
labelValue = field.relationName.map(
|
|
776
|
-
(name) => `${tempObj[name]} `
|
|
777
|
-
);
|
|
778
|
-
} else {
|
|
779
|
-
labelValue =
|
|
780
|
-
tempObj[field.relationName];
|
|
781
|
-
}
|
|
760
|
+
let labelValue;
|
|
782
761
|
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
label: labelValue,
|
|
790
|
-
}
|
|
791
|
-
: {};
|
|
792
|
-
|
|
793
|
-
tempResKey = field.id;
|
|
762
|
+
if (Array.isArray(field.relationName)) {
|
|
763
|
+
labelValue = field.relationName.map(
|
|
764
|
+
(name) => `${tempObj[name]} `
|
|
765
|
+
);
|
|
766
|
+
} else {
|
|
767
|
+
labelValue = tempObj[field.relationName];
|
|
794
768
|
}
|
|
795
|
-
|
|
796
|
-
|
|
769
|
+
|
|
770
|
+
tempRes =
|
|
771
|
+
tempObj !== undefined &&
|
|
772
|
+
tempObj !== null &&
|
|
773
|
+
tempObj.id
|
|
774
|
+
? {
|
|
775
|
+
value: tempObj.id,
|
|
776
|
+
label: labelValue,
|
|
777
|
+
}
|
|
778
|
+
: {};
|
|
779
|
+
|
|
780
|
+
tempResKey = field.id;
|
|
797
781
|
}
|
|
782
|
+
} else {
|
|
783
|
+
updatedFormData[item] = data[item];
|
|
798
784
|
}
|
|
785
|
+
}
|
|
799
786
|
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
787
|
+
if (
|
|
788
|
+
item === tempResKey &&
|
|
789
|
+
tempRes &&
|
|
790
|
+
tempRes.hasOwnProperty('value') &&
|
|
791
|
+
tempRes.hasOwnProperty('label')
|
|
792
|
+
) {
|
|
793
|
+
updatedFormData[item] = tempRes;
|
|
794
|
+
}
|
|
795
|
+
});
|
|
809
796
|
|
|
810
|
-
|
|
797
|
+
setFormData(updatedFormData);
|
|
811
798
|
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
}
|
|
817
|
-
} else {
|
|
818
|
-
setFormData(_formData);
|
|
799
|
+
setFetchTrigger(!fetchTrigger);
|
|
800
|
+
} catch (error) {
|
|
801
|
+
// Handle error here
|
|
802
|
+
toast.error('Failed to fetch data:', error);
|
|
819
803
|
}
|
|
820
|
-
}
|
|
804
|
+
} else {
|
|
805
|
+
setFormData(_formData);
|
|
806
|
+
}
|
|
807
|
+
};
|
|
821
808
|
|
|
809
|
+
useEffect(() => {
|
|
822
810
|
fetchData();
|
|
823
811
|
}, [formSettings]);
|
|
824
812
|
|
|
@@ -901,7 +889,20 @@ function Form({
|
|
|
901
889
|
default:
|
|
902
890
|
return (
|
|
903
891
|
<Field
|
|
904
|
-
|
|
892
|
+
autocompleteCallback={
|
|
893
|
+
autocompleteSelect
|
|
894
|
+
}
|
|
895
|
+
childDropdownCallback={
|
|
896
|
+
childDropdownCallback
|
|
897
|
+
}
|
|
898
|
+
fetchData={fetchData}
|
|
899
|
+
formData={formData}
|
|
900
|
+
inputClass={inputClass}
|
|
901
|
+
inputValue={
|
|
902
|
+
item.hasOwnProperty('key')
|
|
903
|
+
? formData[item.key]
|
|
904
|
+
: formData[item.id]
|
|
905
|
+
}
|
|
905
906
|
key={
|
|
906
907
|
index +
|
|
907
908
|
'-fields-' +
|
|
@@ -909,29 +910,18 @@ function Form({
|
|
|
909
910
|
? item.id + '-' + item.key
|
|
910
911
|
: item.id)
|
|
911
912
|
}
|
|
912
|
-
|
|
913
|
-
item.hasOwnProperty('key')
|
|
914
|
-
? formData[item.key]
|
|
915
|
-
: formData[item.id]
|
|
916
|
-
}
|
|
917
|
-
inputClass={inputClass}
|
|
913
|
+
mapbox={mapbox}
|
|
918
914
|
onChange={handleChange}
|
|
919
915
|
onChangeDate={handleChangeDate}
|
|
920
|
-
onChangeSelect={handleChangeSelect}
|
|
921
|
-
onChangeRicheditor={
|
|
922
|
-
handleChangeRicheditor
|
|
923
|
-
}
|
|
924
|
-
onChangeToggle={handleChangeToggle}
|
|
925
916
|
onChangeNumberFormat={
|
|
926
917
|
handleChangeNumberFormat
|
|
927
918
|
}
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
}
|
|
931
|
-
childDropdownCallback={
|
|
932
|
-
childDropdownCallback
|
|
919
|
+
onChangeRicheditor={
|
|
920
|
+
handleChangeRicheditor
|
|
933
921
|
}
|
|
934
|
-
|
|
922
|
+
onChangeSelect={handleChangeSelect}
|
|
923
|
+
onChangeToggle={handleChangeToggle}
|
|
924
|
+
settings={item}
|
|
935
925
|
setFormData={setFormData}
|
|
936
926
|
style={style}
|
|
937
927
|
uploadProgress={uploadProgress}
|
|
@@ -989,7 +979,19 @@ function Form({
|
|
|
989
979
|
}
|
|
990
980
|
return (
|
|
991
981
|
<Field
|
|
992
|
-
|
|
982
|
+
autocompleteCallback={
|
|
983
|
+
autocompleteSelect
|
|
984
|
+
}
|
|
985
|
+
childDropdownCallback={
|
|
986
|
+
childDropdownCallback
|
|
987
|
+
}
|
|
988
|
+
fetchData={fetchData}
|
|
989
|
+
inputClass={inputClass}
|
|
990
|
+
inputValue={
|
|
991
|
+
item.hasOwnProperty('key')
|
|
992
|
+
? formData[item.key]
|
|
993
|
+
: formData[item.id]
|
|
994
|
+
}
|
|
993
995
|
key={
|
|
994
996
|
index +
|
|
995
997
|
'-fields-' +
|
|
@@ -997,33 +999,22 @@ function Form({
|
|
|
997
999
|
? item.id + '-' + item.key
|
|
998
1000
|
: item.id)
|
|
999
1001
|
}
|
|
1000
|
-
|
|
1001
|
-
item.hasOwnProperty('key')
|
|
1002
|
-
? formData[item.key]
|
|
1003
|
-
: formData[item.id]
|
|
1004
|
-
}
|
|
1005
|
-
inputClass={inputClass}
|
|
1002
|
+
mapbox={mapbox}
|
|
1006
1003
|
onChange={handleChange}
|
|
1007
1004
|
onChangeColour={handleChangeColour}
|
|
1008
1005
|
onChangeDate={handleChangeDate}
|
|
1009
|
-
onChangeSelect={handleChangeSelect}
|
|
1010
|
-
onChangeRicheditor={
|
|
1011
|
-
handleChangeRicheditor
|
|
1012
|
-
}
|
|
1013
|
-
onChangeToggle={handleChangeToggle}
|
|
1014
1006
|
onChangeNumberFormat={
|
|
1015
1007
|
handleChangeNumberFormat
|
|
1016
1008
|
}
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
}
|
|
1020
|
-
childDropdownCallback={
|
|
1021
|
-
childDropdownCallback
|
|
1009
|
+
onChangeRicheditor={
|
|
1010
|
+
handleChangeRicheditor
|
|
1022
1011
|
}
|
|
1023
|
-
|
|
1024
|
-
|
|
1012
|
+
onChangeSelect={handleChangeSelect}
|
|
1013
|
+
onChangeToggle={handleChangeToggle}
|
|
1014
|
+
settings={item}
|
|
1025
1015
|
setFormData={setFormData}
|
|
1026
1016
|
style={style}
|
|
1017
|
+
uploadProgress={uploadProgress}
|
|
1027
1018
|
/>
|
|
1028
1019
|
);
|
|
1029
1020
|
})}
|
|
@@ -265,7 +265,7 @@ function GenericDetail({ setting, urlParam, userProfile }) {
|
|
|
265
265
|
case 'dropzone':
|
|
266
266
|
const downloadFile = (id) => {
|
|
267
267
|
window.open(
|
|
268
|
-
`/ajax/
|
|
268
|
+
`/ajax/files/download/${id}/${activeTabConfig.folder}`
|
|
269
269
|
);
|
|
270
270
|
};
|
|
271
271
|
|
package/package.json
CHANGED