@visns-studio/visns-components 3.1.7 → 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.
@@ -454,7 +454,6 @@ const DataGrid = ({
454
454
  let date;
455
455
  let filterEditor = null;
456
456
  let filterEditorProps = null;
457
- let fileUrl = null;
458
457
  let icons = [];
459
458
  let relationName;
460
459
  let selectedDataSource = null;
@@ -222,6 +222,7 @@ function VisnsDropZone({ fetchData, files, settings }) {
222
222
  handleDelete={handleDelete}
223
223
  handleEdit={handleEdit}
224
224
  useDragHandle
225
+ showImage={true}
225
226
  />
226
227
  ) : null}
227
228
  </div>
@@ -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"
@@ -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/package.json CHANGED
@@ -14,6 +14,7 @@
14
14
  "moment": "^2.30.1",
15
15
  "motion": "^10.17.0",
16
16
  "numeral": "^2.0.6",
17
+ "pluralize": "^8.0.0",
17
18
  "quill-image-uploader": "^1.3.0",
18
19
  "react-color": "^2.19.3",
19
20
  "react-confirm-alert": "^3.0.6",
@@ -29,9 +30,9 @@
29
30
  "react-slugify": "^3.0.3",
30
31
  "react-sortable-hoc": "^2.0.0",
31
32
  "react-to-print": "^2.14.15",
32
- "react-toastify": "^10.0.0",
33
+ "react-toastify": "^10.0.4",
33
34
  "react-toggle": "^4.1.3",
34
- "react-tooltip": "^5.25.1",
35
+ "react-tooltip": "^5.26.0",
35
36
  "react-window": "^1.8.10",
36
37
  "reactjs-popup": "^2.0.6",
37
38
  "truncate": "^3.0.0",
@@ -47,7 +48,7 @@
47
48
  "react-dom": "^17.0.1"
48
49
  },
49
50
  "name": "@visns-studio/visns-components",
50
- "version": "3.1.7",
51
+ "version": "3.1.8",
51
52
  "description": "Various packages to assist in the development of our Custom Applications.",
52
53
  "main": "index.js",
53
54
  "scripts": {