@visns-studio/visns-components 3.1.6 → 3.1.8
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.
|
@@ -13,6 +13,8 @@ import moment from 'moment';
|
|
|
13
13
|
import numeral from 'numeral';
|
|
14
14
|
import Popup from 'reactjs-popup';
|
|
15
15
|
import parse from 'html-react-parser';
|
|
16
|
+
import { saveAs } from 'file-saver';
|
|
17
|
+
import pluralize from 'pluralize';
|
|
16
18
|
import NumberFilter from '@inovua/reactdatagrid-community/NumberFilter';
|
|
17
19
|
import SelectFilter from '@inovua/reactdatagrid-community/SelectFilter';
|
|
18
20
|
import DateFilter from '@inovua/reactdatagrid-community/DateFilter';
|
|
@@ -28,6 +30,7 @@ import {
|
|
|
28
30
|
CloudDownload,
|
|
29
31
|
Copy,
|
|
30
32
|
Edit,
|
|
33
|
+
Envelope,
|
|
31
34
|
Folder,
|
|
32
35
|
Inbox,
|
|
33
36
|
Network,
|
|
@@ -42,6 +45,7 @@ import '@inovua/reactdatagrid-community/index.css';
|
|
|
42
45
|
import 'react-confirm-alert/src/react-confirm-alert.css';
|
|
43
46
|
|
|
44
47
|
import CustomFetch from './Fetch';
|
|
48
|
+
import Download from './Download';
|
|
45
49
|
import Form from './Form';
|
|
46
50
|
import _ from 'lodash';
|
|
47
51
|
|
|
@@ -191,6 +195,33 @@ const DataGrid = forwardRef(
|
|
|
191
195
|
},
|
|
192
196
|
}));
|
|
193
197
|
|
|
198
|
+
const handleDownload = async (d) => {
|
|
199
|
+
try {
|
|
200
|
+
toast.success('Starting download please wait...');
|
|
201
|
+
|
|
202
|
+
const res = await Download(
|
|
203
|
+
`/ajax/files/download/${d.id}/null`,
|
|
204
|
+
'GET',
|
|
205
|
+
{}
|
|
206
|
+
);
|
|
207
|
+
|
|
208
|
+
if (res.data.error) {
|
|
209
|
+
toast.error(res.data.error);
|
|
210
|
+
} else {
|
|
211
|
+
// Assuming the response contains a Blob or similar data
|
|
212
|
+
if (res.data && res.data instanceof Blob) {
|
|
213
|
+
const fileName = `${d.file_name}`;
|
|
214
|
+
saveAs(res.data, fileName);
|
|
215
|
+
} else {
|
|
216
|
+
// Handle the case where the response is not a Blob
|
|
217
|
+
toast.error('Invalid file format received.');
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
} catch (error) {
|
|
221
|
+
console.info(error);
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
|
|
194
225
|
const handleTimer = async (id, key) => {
|
|
195
226
|
try {
|
|
196
227
|
const res = await CustomFetch(`${form.url}/${id}`, 'PUT', {
|
|
@@ -385,6 +416,11 @@ const DataGrid = forwardRef(
|
|
|
385
416
|
],
|
|
386
417
|
});
|
|
387
418
|
break;
|
|
419
|
+
case 'envelope':
|
|
420
|
+
CustomFetch(s.url, 'POST', { id: d[s.key] }, (result) => {
|
|
421
|
+
toast.success(result.message);
|
|
422
|
+
});
|
|
423
|
+
break;
|
|
388
424
|
case 'sound':
|
|
389
425
|
const soundRelation = s.relation.reduce((acc, id) => {
|
|
390
426
|
if (acc === '') {
|
|
@@ -570,6 +606,29 @@ const DataGrid = forwardRef(
|
|
|
570
606
|
};
|
|
571
607
|
}, []);
|
|
572
608
|
|
|
609
|
+
const exportTrigger = async () => {
|
|
610
|
+
try {
|
|
611
|
+
toast.success('Starting export please wait...');
|
|
612
|
+
|
|
613
|
+
const res = await Download(form.export.url, 'POST', {});
|
|
614
|
+
|
|
615
|
+
if (res.data.error) {
|
|
616
|
+
toast.error(res.data.error);
|
|
617
|
+
} else {
|
|
618
|
+
// Assuming the response contains a Blob or similar data
|
|
619
|
+
if (res.data && res.data instanceof Blob) {
|
|
620
|
+
const fileName = `${form.export.filename}`;
|
|
621
|
+
saveAs(res.data, fileName);
|
|
622
|
+
} else {
|
|
623
|
+
// Handle the case where the response is not a Blob
|
|
624
|
+
toast.error('Invalid file format received.');
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
} catch (error) {
|
|
628
|
+
console.info(error);
|
|
629
|
+
}
|
|
630
|
+
};
|
|
631
|
+
|
|
573
632
|
const sortTrigger = () => {
|
|
574
633
|
const url = form.url.replace('/ajax', '');
|
|
575
634
|
|
|
@@ -594,6 +653,11 @@ const DataGrid = forwardRef(
|
|
|
594
653
|
|
|
595
654
|
return (
|
|
596
655
|
<div className="filterAction--alt">
|
|
656
|
+
{form.export && form.export.url && (
|
|
657
|
+
<button className="btn" onClick={exportTrigger}>
|
|
658
|
+
Export
|
|
659
|
+
</button>
|
|
660
|
+
)}
|
|
597
661
|
{form.sort && form.sort.title && (
|
|
598
662
|
<button className="btn" onClick={sortTrigger}>
|
|
599
663
|
<div className="icon-plus"></div> Sort Order
|
|
@@ -838,6 +902,8 @@ const DataGrid = forwardRef(
|
|
|
838
902
|
return getIconComponent(Copy);
|
|
839
903
|
case 'delete':
|
|
840
904
|
return getIconComponent(Backspace);
|
|
905
|
+
case 'envelope':
|
|
906
|
+
return getIconComponent(Envelope);
|
|
841
907
|
case 'family':
|
|
842
908
|
return getIconComponent(Network);
|
|
843
909
|
case 'primary':
|
|
@@ -909,6 +975,7 @@ const DataGrid = forwardRef(
|
|
|
909
975
|
link: column.link ?? {},
|
|
910
976
|
minWidth: column.minWidth ?? undefined,
|
|
911
977
|
maxWidth: column.maxWidth ?? undefined,
|
|
978
|
+
textAlign: column.textAlign ?? undefined,
|
|
912
979
|
textVerticalAlign:
|
|
913
980
|
style && style.text_vertical_align
|
|
914
981
|
? style.text_vertical_align
|
|
@@ -1295,7 +1362,14 @@ const DataGrid = forwardRef(
|
|
|
1295
1362
|
render: ({ data }) => {
|
|
1296
1363
|
if (data && data[column.id]) {
|
|
1297
1364
|
return (
|
|
1298
|
-
<span
|
|
1365
|
+
<span
|
|
1366
|
+
onClick={(e) => {
|
|
1367
|
+
e.stopPropagation();
|
|
1368
|
+
e.preventDefault();
|
|
1369
|
+
|
|
1370
|
+
handleDownload(data[column.id]);
|
|
1371
|
+
}}
|
|
1372
|
+
>
|
|
1299
1373
|
<CloudDownload
|
|
1300
1374
|
data-tooltip-id="system-tooltip"
|
|
1301
1375
|
data-tooltip-content="Download File"
|
package/components/crm/Field.jsx
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React, { useEffect, useRef, useState } from 'react';
|
|
2
2
|
import DatePicker from 'react-datepicker';
|
|
3
3
|
import _ from 'lodash';
|
|
4
|
-
import ReactQuill from 'react-quill';
|
|
5
4
|
import Toggle from 'react-toggle';
|
|
6
5
|
import moment from 'moment';
|
|
7
6
|
import { BlockPicker } from 'react-color';
|
package/components/crm/Form.jsx
CHANGED
|
@@ -2,6 +2,7 @@ import React, { useState, useEffect } from 'react';
|
|
|
2
2
|
import { useNavigate } from 'react-router-dom';
|
|
3
3
|
import { motion } from 'framer-motion';
|
|
4
4
|
import { toast } from 'react-toastify';
|
|
5
|
+
import { saveAs } from 'file-saver';
|
|
5
6
|
import moment from 'moment';
|
|
6
7
|
import parse from 'html-react-parser';
|
|
7
8
|
import _ from 'lodash';
|
|
@@ -11,6 +12,7 @@ import { CircleX } from 'akar-icons';
|
|
|
11
12
|
import '@inovua/reactdatagrid-community/index.css';
|
|
12
13
|
|
|
13
14
|
import CustomFetch from './Fetch';
|
|
15
|
+
import Download from './Download';
|
|
14
16
|
import Field from './Field';
|
|
15
17
|
import Table from './DataGrid';
|
|
16
18
|
|
|
@@ -377,8 +379,34 @@ function Form({
|
|
|
377
379
|
);
|
|
378
380
|
};
|
|
379
381
|
|
|
382
|
+
const handleDownload = async (e) => {
|
|
383
|
+
try {
|
|
384
|
+
if (e) {
|
|
385
|
+
e.preventDefault();
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
const extension = formSettings.download.extension;
|
|
389
|
+
const filename = formSettings.download.filename;
|
|
390
|
+
const method = 'POST';
|
|
391
|
+
const url = formSettings.download.url;
|
|
392
|
+
|
|
393
|
+
const res = await Download(url, method, formData);
|
|
394
|
+
|
|
395
|
+
// Using file-saver to save the file
|
|
396
|
+
const blob = new Blob([res.data], {
|
|
397
|
+
type: 'application/octet-stream',
|
|
398
|
+
});
|
|
399
|
+
saveAs(blob, `${filename}.${extension}`);
|
|
400
|
+
} catch (error) {
|
|
401
|
+
console.error(error);
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
|
|
380
405
|
const handleSubmit = (e) => {
|
|
381
|
-
e
|
|
406
|
+
if (e) {
|
|
407
|
+
e.preventDefault();
|
|
408
|
+
}
|
|
409
|
+
|
|
382
410
|
let fields = formSettings.fields;
|
|
383
411
|
let _inputClass = inputClass;
|
|
384
412
|
let validation = '';
|
|
@@ -1098,6 +1126,12 @@ function Form({
|
|
|
1098
1126
|
)}
|
|
1099
1127
|
</form>
|
|
1100
1128
|
<div className="polActions">
|
|
1129
|
+
{formSettings?.download?.button?.label && (
|
|
1130
|
+
<button className="btn" onClick={handleDownload}>
|
|
1131
|
+
{formSettings.download.button.label}
|
|
1132
|
+
</button>
|
|
1133
|
+
)}
|
|
1134
|
+
|
|
1101
1135
|
<button className="btn" onClick={handleSubmit}>
|
|
1102
1136
|
{formSettings?.save?.button?.label
|
|
1103
1137
|
? formSettings.save.button.label
|
package/package.json
CHANGED
|
@@ -7,12 +7,14 @@
|
|
|
7
7
|
"array-move": "^4.0.0",
|
|
8
8
|
"awesome-debounce-promise": "^2.1.0",
|
|
9
9
|
"axios": "^1.6.5",
|
|
10
|
+
"file-saver": "^2.0.5",
|
|
10
11
|
"framer-motion": "^10.18.0",
|
|
11
12
|
"html-react-parser": "^5.1.1",
|
|
12
13
|
"lodash": "^4.17.21",
|
|
13
14
|
"moment": "^2.30.1",
|
|
14
15
|
"motion": "^10.17.0",
|
|
15
16
|
"numeral": "^2.0.6",
|
|
17
|
+
"pluralize": "^8.0.0",
|
|
16
18
|
"quill-image-uploader": "^1.3.0",
|
|
17
19
|
"react-color": "^2.19.3",
|
|
18
20
|
"react-confirm-alert": "^3.0.6",
|
|
@@ -28,9 +30,9 @@
|
|
|
28
30
|
"react-slugify": "^3.0.3",
|
|
29
31
|
"react-sortable-hoc": "^2.0.0",
|
|
30
32
|
"react-to-print": "^2.14.15",
|
|
31
|
-
"react-toastify": "^10.0.
|
|
33
|
+
"react-toastify": "^10.0.4",
|
|
32
34
|
"react-toggle": "^4.1.3",
|
|
33
|
-
"react-tooltip": "^5.
|
|
35
|
+
"react-tooltip": "^5.26.0",
|
|
34
36
|
"react-window": "^1.8.10",
|
|
35
37
|
"reactjs-popup": "^2.0.6",
|
|
36
38
|
"truncate": "^3.0.0",
|
|
@@ -46,7 +48,7 @@
|
|
|
46
48
|
"react-dom": "^17.0.1"
|
|
47
49
|
},
|
|
48
50
|
"name": "@visns-studio/visns-components",
|
|
49
|
-
"version": "3.1.
|
|
51
|
+
"version": "3.1.8",
|
|
50
52
|
"description": "Various packages to assist in the development of our Custom Applications.",
|
|
51
53
|
"main": "index.js",
|
|
52
54
|
"scripts": {
|