@visns-studio/visns-components 4.10.42 → 4.10.44
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 +1 -1
- package/src/components/crm/DataGrid.jsx +50 -10
- package/src/components/crm/Form.jsx +0 -1
- package/src/components/crm/QuickAction.jsx +0 -1
- package/src/components/crm/generic/GenericAuth.jsx +6 -2
- package/src/components/crm/generic/GenericDetail.jsx +33 -21
- package/src/components/crm/generic/GenericIndex.jsx +2 -1
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": "4.10.
|
|
80
|
+
"version": "4.10.44",
|
|
81
81
|
"description": "Various packages to assist in the development of our Custom Applications.",
|
|
82
82
|
"main": "src/index.js",
|
|
83
83
|
"files": [
|
|
@@ -94,6 +94,7 @@ const loadData = async (
|
|
|
94
94
|
id: identifier,
|
|
95
95
|
value: fv.value,
|
|
96
96
|
operator: fv.operator,
|
|
97
|
+
whereHas: fv.whereHas || [],
|
|
97
98
|
});
|
|
98
99
|
}
|
|
99
100
|
} else {
|
|
@@ -571,20 +572,11 @@ const DataGrid = forwardRef(
|
|
|
571
572
|
break;
|
|
572
573
|
case 'form':
|
|
573
574
|
if (s.key) {
|
|
574
|
-
console.info('Form Setting Data:', formSettingData);
|
|
575
575
|
let fsd = s.form;
|
|
576
576
|
|
|
577
577
|
if (fsd.fields && fsd.fields.length > 0) {
|
|
578
|
-
console.info(
|
|
579
|
-
'Form Setting Data Fields:',
|
|
580
|
-
fsd.fields.length
|
|
581
|
-
);
|
|
582
578
|
fsd.fields.forEach((fItem, fKey) => {
|
|
583
579
|
if (fItem.id === s.key) {
|
|
584
|
-
console.info(
|
|
585
|
-
'Form Setting Data Fields ID:',
|
|
586
|
-
fItem.id
|
|
587
|
-
);
|
|
588
580
|
fsd.fields[fKey].value = d.id;
|
|
589
581
|
}
|
|
590
582
|
});
|
|
@@ -765,7 +757,9 @@ const DataGrid = forwardRef(
|
|
|
765
757
|
} else {
|
|
766
758
|
const column = rowProps.columns[columnIndex];
|
|
767
759
|
|
|
768
|
-
|
|
760
|
+
const excludedColumnTypes = ['dropdown', 'text_input'];
|
|
761
|
+
|
|
762
|
+
if (!excludedColumnTypes.includes(column.type)) {
|
|
769
763
|
if (column.id !== '__checkbox-column') {
|
|
770
764
|
if (column.link && column.link.hasOwnProperty('url')) {
|
|
771
765
|
if (column.link.url) {
|
|
@@ -2344,6 +2338,51 @@ const DataGrid = forwardRef(
|
|
|
2344
2338
|
return <span>{stage}</span>;
|
|
2345
2339
|
},
|
|
2346
2340
|
};
|
|
2341
|
+
case 'text_input':
|
|
2342
|
+
columnId = Array.isArray(column.id)
|
|
2343
|
+
? column.id.join('-')
|
|
2344
|
+
: column.id;
|
|
2345
|
+
|
|
2346
|
+
return {
|
|
2347
|
+
...commonProps,
|
|
2348
|
+
name: columnId,
|
|
2349
|
+
render: ({ data }) => {
|
|
2350
|
+
const debouncedOnChange = debounce(
|
|
2351
|
+
(name, value) => {
|
|
2352
|
+
if (
|
|
2353
|
+
column.update?.key &&
|
|
2354
|
+
column.update?.url &&
|
|
2355
|
+
column.update?.method
|
|
2356
|
+
) {
|
|
2357
|
+
handleDropdownUpdate(
|
|
2358
|
+
column.update.key,
|
|
2359
|
+
`${column.update.url}/${data.id}`,
|
|
2360
|
+
column.update.method,
|
|
2361
|
+
value
|
|
2362
|
+
);
|
|
2363
|
+
}
|
|
2364
|
+
},
|
|
2365
|
+
1000
|
|
2366
|
+
);
|
|
2367
|
+
|
|
2368
|
+
const handleChange = (e) => {
|
|
2369
|
+
const { name, value } = e.target;
|
|
2370
|
+
debouncedOnChange(name, value);
|
|
2371
|
+
};
|
|
2372
|
+
|
|
2373
|
+
return (
|
|
2374
|
+
<input
|
|
2375
|
+
name={column.id}
|
|
2376
|
+
defaultValue={
|
|
2377
|
+
data[column.id] || ''
|
|
2378
|
+
}
|
|
2379
|
+
style={{ padding: '7px' }}
|
|
2380
|
+
onChange={handleChange}
|
|
2381
|
+
type="text"
|
|
2382
|
+
/>
|
|
2383
|
+
);
|
|
2384
|
+
},
|
|
2385
|
+
};
|
|
2347
2386
|
case 'time':
|
|
2348
2387
|
return {
|
|
2349
2388
|
...commonProps,
|
|
@@ -2600,6 +2639,7 @@ const DataGrid = forwardRef(
|
|
|
2600
2639
|
name: filterName,
|
|
2601
2640
|
operator: column.filter.operator,
|
|
2602
2641
|
type: column.filter.type,
|
|
2642
|
+
whereHas: column.filter.whereHas || [],
|
|
2603
2643
|
value: filterValue,
|
|
2604
2644
|
reset: column.filter.reset
|
|
2605
2645
|
? column.filter.reset
|
|
@@ -619,7 +619,6 @@ function Form({
|
|
|
619
619
|
validation += `${item.label} is a required field.<br/>`;
|
|
620
620
|
_inputClass[item.id] = styles.inputError;
|
|
621
621
|
} else {
|
|
622
|
-
console.info('b', formData, item.id);
|
|
623
622
|
validation += `${item.label} is a required field.<br/>`;
|
|
624
623
|
_inputClass[item.id] = styles.inputError;
|
|
625
624
|
}
|
|
@@ -51,8 +51,12 @@ const GenericAuth = ({
|
|
|
51
51
|
const updateAuthStatus = async () => {
|
|
52
52
|
try {
|
|
53
53
|
const { data } = await CustomFetch('/ajax/user/profile', 'GET');
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
|
|
55
|
+
if (data && data.id) {
|
|
56
|
+
setUserProfile(data);
|
|
57
|
+
setIsAuthenticated(true);
|
|
58
|
+
}
|
|
59
|
+
|
|
56
60
|
setIsLoading(false);
|
|
57
61
|
|
|
58
62
|
if (location.pathname.split('/')[1] === 'login') {
|
|
@@ -192,6 +192,7 @@ function GenericDetail({
|
|
|
192
192
|
relationKey,
|
|
193
193
|
size,
|
|
194
194
|
truncateLength,
|
|
195
|
+
checkboxLabel,
|
|
195
196
|
} = item;
|
|
196
197
|
const value =
|
|
197
198
|
relation && relation.length > 0 && type !== 'total'
|
|
@@ -264,16 +265,22 @@ function GenericDetail({
|
|
|
264
265
|
return '';
|
|
265
266
|
}
|
|
266
267
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
268
|
+
// Create a lookup map for checkbox labels if it exists
|
|
269
|
+
const labelMap = checkboxLabel
|
|
270
|
+
? checkboxLabel.reduce((map, item) => {
|
|
271
|
+
map[item.id] = item.label;
|
|
272
|
+
return map;
|
|
273
|
+
}, {})
|
|
274
|
+
: {};
|
|
274
275
|
|
|
275
276
|
const keys = Object.keys(value)
|
|
276
|
-
.filter(
|
|
277
|
+
.filter(
|
|
278
|
+
(key) =>
|
|
279
|
+
(typeof value[key] === 'boolean' ||
|
|
280
|
+
typeof value[key] === 'string') &&
|
|
281
|
+
value[key] &&
|
|
282
|
+
key !== 'notes'
|
|
283
|
+
)
|
|
277
284
|
.sort((a, b) => {
|
|
278
285
|
if (a === 'other') return 1;
|
|
279
286
|
if (b === 'other') return -1;
|
|
@@ -281,25 +288,30 @@ function GenericDetail({
|
|
|
281
288
|
});
|
|
282
289
|
|
|
283
290
|
const formattedKeys = keys.map((key) => {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
type
|
|
291
|
-
);
|
|
292
|
-
|
|
293
|
-
if (otherValue) {
|
|
294
|
-
formattedKey += `: ${otherValue}`;
|
|
295
|
-
}
|
|
291
|
+
// Use the label if available; otherwise, fallback to the formatted key
|
|
292
|
+
let label = labelMap[key] || formatKey(key);
|
|
293
|
+
|
|
294
|
+
// If the value is a string, append it directly to the label
|
|
295
|
+
if (typeof value[key] === 'string') {
|
|
296
|
+
return `${label}: ${value[key]}`;
|
|
296
297
|
}
|
|
297
|
-
|
|
298
|
+
|
|
299
|
+
// Return the label for boolean values
|
|
300
|
+
return label;
|
|
298
301
|
});
|
|
299
302
|
|
|
300
303
|
return formattedKeys.join(', ');
|
|
301
304
|
};
|
|
302
305
|
|
|
306
|
+
// Helper function to format the key as a fallback
|
|
307
|
+
const formatKey = (key) => {
|
|
308
|
+
return key
|
|
309
|
+
.toLowerCase()
|
|
310
|
+
.split('_')
|
|
311
|
+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
|
|
312
|
+
.join(' ');
|
|
313
|
+
};
|
|
314
|
+
|
|
303
315
|
const renderDate = () => formatDateValue(value);
|
|
304
316
|
|
|
305
317
|
const renderDateTime = () => formatDateTimeValue(value);
|
|
@@ -4,6 +4,7 @@ import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
|
4
4
|
import { Outlet } from 'react-router-dom';
|
|
5
5
|
import { toast } from 'react-toastify';
|
|
6
6
|
import { saveAs } from 'file-saver';
|
|
7
|
+
import parse from 'html-react-parser';
|
|
7
8
|
import _ from 'lodash';
|
|
8
9
|
import moment from 'moment';
|
|
9
10
|
|
|
@@ -387,7 +388,7 @@ function GenericIndex({
|
|
|
387
388
|
: styles.crmtitleSimple
|
|
388
389
|
}`}
|
|
389
390
|
>
|
|
390
|
-
<h1>{setting.page?.title}</h1>
|
|
391
|
+
<h1>{parse(setting.page?.title)}</h1>
|
|
391
392
|
<div className={styles.titleInfo}>
|
|
392
393
|
<span>
|
|
393
394
|
[<strong>{total}</strong> Total{' '}
|