@visns-studio/visns-components 5.15.28 → 5.15.30
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
CHANGED
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"react-dom": "^17.0.0 || ^18.0.0"
|
|
95
95
|
},
|
|
96
96
|
"name": "@visns-studio/visns-components",
|
|
97
|
-
"version": "5.15.
|
|
97
|
+
"version": "5.15.30",
|
|
98
98
|
"description": "Various packages to assist in the development of our Custom Applications.",
|
|
99
99
|
"main": "src/index.js",
|
|
100
100
|
"files": [
|
|
@@ -541,12 +541,52 @@ const DataGrid = forwardRef(
|
|
|
541
541
|
const [gridColumns, setGridColumns] = useState([]);
|
|
542
542
|
const [columnsMetadata, setColumnsMetadata] = useState({});
|
|
543
543
|
const gridRef = useRef(null);
|
|
544
|
-
|
|
544
|
+
|
|
545
|
+
// Get default limit from userProfile preferences, tableSetting, or default to 25
|
|
546
|
+
const getDefaultLimit = () => {
|
|
547
|
+
console.log('[DataGrid] getDefaultLimit called:', {
|
|
548
|
+
userProfile_rows_per_page: userProfile?.rows_per_page,
|
|
549
|
+
userProfile_settings_rows_per_page: userProfile?.settings?.rows_per_page,
|
|
550
|
+
tableSetting_pageSize: tableSetting?.pageSize,
|
|
551
|
+
userProfile: userProfile,
|
|
552
|
+
});
|
|
553
|
+
if (userProfile?.rows_per_page) return userProfile.rows_per_page;
|
|
554
|
+
if (userProfile?.settings?.rows_per_page) return userProfile.settings.rows_per_page;
|
|
555
|
+
if (tableSetting?.pageSize) return tableSetting.pageSize;
|
|
556
|
+
return 25;
|
|
557
|
+
};
|
|
558
|
+
|
|
559
|
+
const [limit, setLimit] = useState(() => {
|
|
560
|
+
const initialLimit = getDefaultLimit();
|
|
561
|
+
console.log('[DataGrid] Initial limit set to:', initialLimit);
|
|
562
|
+
return initialLimit;
|
|
563
|
+
});
|
|
545
564
|
const [search, setSearch] = useState('');
|
|
546
565
|
const [selected, setSelected] = useState({});
|
|
547
566
|
const [inputDebounceTimers] = useState({});
|
|
548
567
|
const [localInputValues, setLocalInputValues] = useState({});
|
|
549
568
|
const localInputValuesRef = useRef({}); // Add this ref to track values
|
|
569
|
+
const initialLimitApplied = useRef(false); // Track if we've applied user's rows_per_page preference
|
|
570
|
+
|
|
571
|
+
// Effect to update limit when userProfile becomes available (for async loaded profiles)
|
|
572
|
+
useEffect(() => {
|
|
573
|
+
console.log('[DataGrid] useEffect triggered:', {
|
|
574
|
+
initialLimitApplied: initialLimitApplied.current,
|
|
575
|
+
userProfile_rows_per_page: userProfile?.rows_per_page,
|
|
576
|
+
userProfile_settings_rows_per_page: userProfile?.settings?.rows_per_page,
|
|
577
|
+
currentLimit: limit,
|
|
578
|
+
});
|
|
579
|
+
// Only apply the user's preference once, when userProfile first becomes available
|
|
580
|
+
if (!initialLimitApplied.current) {
|
|
581
|
+
const userLimit = userProfile?.rows_per_page || userProfile?.settings?.rows_per_page;
|
|
582
|
+
console.log('[DataGrid] Checking userLimit:', userLimit);
|
|
583
|
+
if (userLimit && userLimit > 0) {
|
|
584
|
+
console.log('[DataGrid] Setting limit to userLimit:', userLimit);
|
|
585
|
+
setLimit(userLimit);
|
|
586
|
+
initialLimitApplied.current = true;
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
}, [userProfile?.rows_per_page, userProfile?.settings?.rows_per_page]);
|
|
550
590
|
|
|
551
591
|
/** Auto Refresh States */
|
|
552
592
|
const [autoRefreshEnabled, setAutoRefreshEnabled] = useState(false);
|
|
@@ -3340,7 +3380,18 @@ const DataGrid = forwardRef(
|
|
|
3340
3380
|
const minHeight = getMinimumHeight();
|
|
3341
3381
|
setGridStyle((prevState) => ({ ...prevState, minHeight }));
|
|
3342
3382
|
|
|
3343
|
-
|
|
3383
|
+
// Priority for limit:
|
|
3384
|
+
// 1. User's rows_per_page preference (already applied via initialLimitApplied ref)
|
|
3385
|
+
// 2. ajaxSetting.take if >= 35
|
|
3386
|
+
// 3. Calculated rows based on height (fallback)
|
|
3387
|
+
|
|
3388
|
+
// Only auto-calculate limit if user hasn't set a preference
|
|
3389
|
+
const userPreferredLimit = userProfile?.rows_per_page || userProfile?.settings?.rows_per_page;
|
|
3390
|
+
|
|
3391
|
+
if (userPreferredLimit && userPreferredLimit > 0) {
|
|
3392
|
+
// User has a preference, don't override it
|
|
3393
|
+
console.log('[DataGrid] Respecting user preference, not auto-calculating limit:', userPreferredLimit);
|
|
3394
|
+
} else if (ajaxSetting?.take >= 35) {
|
|
3344
3395
|
setLimit(ajaxSetting.take);
|
|
3345
3396
|
} else {
|
|
3346
3397
|
const calculateRows = (height) =>
|
|
@@ -3349,7 +3400,7 @@ const DataGrid = forwardRef(
|
|
|
3349
3400
|
const rowCount = calculateRows(minHeight);
|
|
3350
3401
|
setLimit(rowCount);
|
|
3351
3402
|
}
|
|
3352
|
-
}, [dataCount, gridHeight, window.innerHeight]);
|
|
3403
|
+
}, [dataCount, gridHeight, window.innerHeight, userProfile?.rows_per_page, userProfile?.settings?.rows_per_page]);
|
|
3353
3404
|
|
|
3354
3405
|
useEffect(() => {
|
|
3355
3406
|
const debouncedHandleResize = debounce(() => {
|
package/src/components/Form.jsx
CHANGED
|
@@ -1684,6 +1684,7 @@ function Form({
|
|
|
1684
1684
|
}
|
|
1685
1685
|
if (closeModal) {
|
|
1686
1686
|
closeModal();
|
|
1687
|
+
let saveAnotherFailed = false;
|
|
1687
1688
|
if (type === 'saveAnother') {
|
|
1688
1689
|
const { saveAnother } =
|
|
1689
1690
|
formSettings?.update ||
|
|
@@ -1725,6 +1726,13 @@ function Form({
|
|
|
1725
1726
|
res.data.data || res.data;
|
|
1726
1727
|
fetchTable(createdItem);
|
|
1727
1728
|
}
|
|
1729
|
+
} else {
|
|
1730
|
+
saveAnotherFailed = true;
|
|
1731
|
+
if (fetchTable) {
|
|
1732
|
+
const createdItem =
|
|
1733
|
+
res.data.data || res.data;
|
|
1734
|
+
fetchTable(createdItem);
|
|
1735
|
+
}
|
|
1728
1736
|
}
|
|
1729
1737
|
} else {
|
|
1730
1738
|
fetchData();
|
|
@@ -1741,12 +1749,14 @@ function Form({
|
|
|
1741
1749
|
}
|
|
1742
1750
|
}
|
|
1743
1751
|
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1752
|
+
if (!saveAnotherFailed) {
|
|
1753
|
+
toast.success(
|
|
1754
|
+
formSettings?.save?.toast?.success ||
|
|
1755
|
+
(method === 'POST'
|
|
1756
|
+
? 'Entry successfully saved into the system.'
|
|
1757
|
+
: 'Entry successfully updated.')
|
|
1758
|
+
);
|
|
1759
|
+
}
|
|
1750
1760
|
} else {
|
|
1751
1761
|
toast.success(
|
|
1752
1762
|
formSettings?.save?.toast?.success ||
|
|
@@ -1712,6 +1712,11 @@ export const renderTimerColumn = ({
|
|
|
1712
1712
|
</CellWithTooltip>
|
|
1713
1713
|
);
|
|
1714
1714
|
} else {
|
|
1715
|
+
// If groupOnly is set, don't render the timer button on individual rows
|
|
1716
|
+
if (column.groupOnly) {
|
|
1717
|
+
return null;
|
|
1718
|
+
}
|
|
1719
|
+
|
|
1715
1720
|
let shouldRenderButton = false;
|
|
1716
1721
|
|
|
1717
1722
|
if (
|