@visns-studio/visns-components 1.7.6 → 1.8.1
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/components/crm/visns-data-grid.jsx +22 -24
- package/components/crm/visns-fetch.jsx +70 -62
- package/components/crm/visns-field.jsx +462 -690
- package/components/crm/visns-form.jsx +348 -440
- package/package.json +1 -1
|
@@ -327,35 +327,33 @@ const DataGrid = forwardRef(
|
|
|
327
327
|
).indexOf(cellElement);
|
|
328
328
|
|
|
329
329
|
if (columnIndex === rowProps.columns.length - 1) {
|
|
330
|
+
// Handle last column click
|
|
330
331
|
} else {
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
"/" +
|
|
332
|
+
const column = rowProps.columns[columnIndex];
|
|
333
|
+
|
|
334
|
+
if (column.link && column.link.url) {
|
|
335
|
+
const fileRelationArray = column.id.split(".");
|
|
336
|
+
const linkUrl = column.link.url;
|
|
337
|
+
const linkKey = rowProps.columns[columnIndex].link.key;
|
|
338
|
+
const rowData = rowProps.data[linkKey];
|
|
339
|
+
|
|
340
|
+
if (column.link.folder) {
|
|
341
|
+
const linkFolder =
|
|
342
342
|
rowProps.columns[columnIndex].link.folder;
|
|
343
|
+
|
|
344
|
+
if (rowProps.data[fileRelationArray[0]]) {
|
|
345
|
+
window.location.href = `${linkUrl}${rowData}/${linkFolder}`;
|
|
346
|
+
}
|
|
343
347
|
} else {
|
|
344
|
-
navigate(
|
|
345
|
-
`${rowProps.columns[columnIndex].link.url}${
|
|
346
|
-
rowProps.data[
|
|
347
|
-
rowProps.columns[columnIndex].link.key
|
|
348
|
-
]
|
|
349
|
-
}`
|
|
350
|
-
);
|
|
348
|
+
navigate(`${linkUrl}${rowData}`);
|
|
351
349
|
}
|
|
352
|
-
} else if (
|
|
350
|
+
} else if (column.link && column.link.popup) {
|
|
351
|
+
const linkPopup = column.link.popup;
|
|
352
|
+
const linkKey = rowProps.columns[columnIndex].link.key;
|
|
353
|
+
const rowData = rowProps.data[linkKey];
|
|
354
|
+
|
|
353
355
|
window.open(
|
|
354
|
-
`${
|
|
355
|
-
rowProps.data[
|
|
356
|
-
rowProps.columns[columnIndex].link.key
|
|
357
|
-
]
|
|
358
|
-
}`,
|
|
356
|
+
`${linkPopup}/${rowData}`,
|
|
359
357
|
"",
|
|
360
358
|
"width=1440,height=1024,menubar=1,resizable=1,status=1,titlebar=1,toolbar=1"
|
|
361
359
|
);
|
|
@@ -4,77 +4,85 @@ import { trackPromise } from "react-promise-tracker";
|
|
|
4
4
|
import { toast } from "react-toastify";
|
|
5
5
|
import parse from "html-react-parser";
|
|
6
6
|
|
|
7
|
-
const CustomFetch =
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
const CustomFetch = (
|
|
8
|
+
url,
|
|
9
|
+
method,
|
|
10
|
+
formData,
|
|
11
|
+
successCallback = null,
|
|
12
|
+
errorCallback = null
|
|
13
13
|
) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
const baseUrl = "";
|
|
15
|
+
const headers = {
|
|
16
|
+
"Content-Type": "application/json",
|
|
17
|
+
};
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
if (method.toUpperCase() === "PUT" || method.toUpperCase() === "PATCH") {
|
|
20
|
+
formData = {
|
|
21
|
+
...formData,
|
|
22
|
+
_method: method,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
const options = {
|
|
27
|
+
method: method,
|
|
28
|
+
data: formData,
|
|
29
|
+
headers: headers,
|
|
30
|
+
url: baseUrl + url,
|
|
31
|
+
};
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
return trackPromise(
|
|
34
|
+
new Promise((resolve, reject) => {
|
|
35
|
+
axios(options)
|
|
36
|
+
.then((response) => {
|
|
37
|
+
if (successCallback) {
|
|
38
|
+
successCallback(response.data);
|
|
39
|
+
} else {
|
|
40
|
+
const error = response.data.error;
|
|
35
41
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
let errorMessage = "";
|
|
42
|
+
if (error && error !== "") {
|
|
43
|
+
toast.error(<div>{parse(error)}</div>);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
resolve(response);
|
|
47
|
+
})
|
|
48
|
+
.catch((error) => {
|
|
49
|
+
let errorMessage = "";
|
|
45
50
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
if (
|
|
52
|
+
error.response &&
|
|
53
|
+
error.response.data &&
|
|
54
|
+
error.response.data.message
|
|
55
|
+
) {
|
|
56
|
+
const { data } = error.response;
|
|
52
57
|
|
|
53
|
-
|
|
54
|
-
|
|
58
|
+
if (data.errors) {
|
|
59
|
+
const { errors } = data;
|
|
55
60
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
61
|
+
Object.values(errors).forEach((errorArray) => {
|
|
62
|
+
errorArray.forEach((errorMsg) => {
|
|
63
|
+
errorMessage += `${errorMsg}<br />`;
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
} else {
|
|
67
|
+
if (data.message === "CSRF token mismatch.") {
|
|
68
|
+
window.location.replace("/login");
|
|
69
|
+
} else {
|
|
70
|
+
errorMessage = data.message;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
} else {
|
|
74
|
+
errorMessage = error.message;
|
|
75
|
+
}
|
|
71
76
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
77
|
+
if (errorCallback) {
|
|
78
|
+
errorCallback(errorMessage);
|
|
79
|
+
} else {
|
|
80
|
+
toast.error(<div>{parse(errorMessage)}</div>);
|
|
81
|
+
}
|
|
82
|
+
reject(error);
|
|
83
|
+
});
|
|
84
|
+
})
|
|
85
|
+
);
|
|
78
86
|
};
|
|
79
87
|
|
|
80
88
|
export default CustomFetch;
|